Browse Source

AU plugins working; Always return valid in carla_get_cached_plugin_info

tags/1.9.5
falkTX 10 years ago
parent
commit
5fd388ed02
6 changed files with 76 additions and 62 deletions
  1. +38
    -29
      source/backend/CarlaHostCommon.cpp
  2. +1
    -0
      source/backend/CarlaStandalone.cpp
  3. +1
    -1
      source/backend/plugin/AuPlugin.cpp
  4. +32
    -28
      source/backend/plugin/JucePlugin.cpp
  5. +2
    -0
      source/utils/CarlaBackendUtils.hpp
  6. +2
    -4
      source/utils/CarlaStateUtils.cpp

+ 38
- 29
source/backend/CarlaHostCommon.cpp View File

@@ -26,6 +26,7 @@

#ifdef CARLA_OS_MAC
# include "juce_audio_processors.h"
using juce::AudioUnitPluginFormat;
using juce::StringArray;
#endif

@@ -36,11 +37,13 @@ namespace CB = CarlaBackend;

static const char* const gNullCharPtr = "";

#ifdef CARLA_COMMON_NEED_CHECKSTRINGPTR
static void checkStringPtr(const char*& charPtr) noexcept
{
if (charPtr == nullptr)
charPtr = gNullCharPtr;
}
#endif

// -------------------------------------------------------------------------------------------------------------------
// Constructors
@@ -294,13 +297,13 @@ uint carla_get_cached_plugin_count(PluginType ptype, const char* pluginPath)
static bool initiated = false;

if (initiated)
return gCachedAuPluginResults.size();
return static_cast<uint>(gCachedAuPluginResults.size());

initiated = true;

AudioUnitPluginFormat auFormat;
gCachedAuPluginResults = auFormat.searchPathsForPlugins(juce::FileSearchPath(), false);
return gCachedAuPluginResults.size();

return static_cast<uint>(gCachedAuPluginResults.size());
#else
return 0;
#endif
@@ -313,7 +316,6 @@ uint carla_get_cached_plugin_count(PluginType ptype, const char* pluginPath)

const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint index)
{
CARLA_SAFE_ASSERT_RETURN(ptype == CB::PLUGIN_INTERNAL || ptype == CB::PLUGIN_LV2 || ptype == CB::PLUGIN_AU, nullptr);
carla_debug("carla_get_cached_plugin_info(%i:%s, %i)", ptype, CB::PluginType2Str(ptype), index);

static CarlaCachedPluginInfo info;
@@ -323,7 +325,7 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint
case CB::PLUGIN_INTERNAL: {
#ifndef BUILD_BRIDGE
const NativePluginDescriptor* const desc(CarlaPlugin::getNativePluginDescriptor(index));
CARLA_SAFE_ASSERT_RETURN(desc != nullptr, nullptr);
CARLA_SAFE_ASSERT_BREAK(desc != nullptr);

info.category = static_cast<CB::PluginCategory>(desc->category);
info.hints = 0x0;
@@ -339,19 +341,19 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint
if (desc->hints & ::PLUGIN_NEEDS_SINGLE_THREAD)
info.hints |= CB::PLUGIN_NEEDS_SINGLE_THREAD;

info.audioIns = desc->audioIns;
info.audioOuts = desc->audioOuts;
info.midiIns = desc->midiIns;
info.midiOuts = desc->midiOuts;
info.audioIns = desc->audioIns;
info.audioOuts = desc->audioOuts;
info.midiIns = desc->midiIns;
info.midiOuts = desc->midiOuts;
info.parameterIns = desc->paramIns;
info.parameterOuts = desc->paramOuts;
info.name = desc->name;
info.label = desc->label;
info.maker = desc->maker;
info.copyright = desc->copyright;
info.name = desc->name;
info.label = desc->label;
info.maker = desc->maker;
info.copyright = desc->copyright;
return &info;
#else
return nullptr;
break;
#endif
}

@@ -359,10 +361,10 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint
Lv2WorldClass& lv2World(Lv2WorldClass::getInstance());

const LilvPlugin* const cPlugin(lv2World.getPluginFromIndex(index));
CARLA_SAFE_ASSERT_RETURN(cPlugin != nullptr, nullptr);
CARLA_SAFE_ASSERT_BREAK(cPlugin != nullptr);

Lilv::Plugin lilvPlugin(cPlugin);
CARLA_SAFE_ASSERT_RETURN(lilvPlugin.get_uri().is_uri(), nullptr);
CARLA_SAFE_ASSERT_BREAK(lilvPlugin.get_uri().is_uri());

// features
info.hints = 0x0;
@@ -636,22 +638,22 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint
case CB::PLUGIN_AU: {
#ifdef CARLA_OS_MAC
const int indexi(static_cast<int>(index));
CARLA_SAFE_ASSERT_RETURN(indexi < gCachedAuPluginResults.size(), nullptr);
CARLA_SAFE_ASSERT_BREAK(indexi < gCachedAuPluginResults.size());

using namespace juce;

String pluginId(gCachedAuPluginResults[indexi]);
OwnedArray<PluginDescription> results;

AudioPluginFormat& auFormat = *(AudioPluginFormat*)0;
AudioUnitPluginFormat auFormat;
auFormat.findAllTypesForFile(results, pluginId);
CARLA_SAFE_ASSERT_RETURN(results.size() > 0, nullptr);
CARLA_SAFE_ASSERT_BREAK(results.size() > 0);
CARLA_SAFE_ASSERT(results.size() == 1);

PluginDescription* const desc(results[0]);
CARLA_SAFE_ASSERT_RETURN(desc != nullptr, nullptr);
CARLA_SAFE_ASSERT_BREAK(desc != nullptr);

info.category = CB::PLUGIN_CATEGORY_NONE;
info.category = CB::getPluginCategoryFromName(desc->category.toRawUTF8());
info.hints = 0x0;

if (desc->isInstrument)
@@ -679,19 +681,26 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint

return &info;
#else
return nullptr;
break;
#endif
}

default:
return nullptr;
break;
}

checkStringPtr(info.name);
checkStringPtr(info.label);
checkStringPtr(info.maker);
checkStringPtr(info.copyright);

info.category = CB::PLUGIN_CATEGORY_NONE;
info.hints = 0x0;
info.audioIns = 0;
info.audioOuts = 0;
info.midiIns = 0;
info.midiOuts = 0;
info.parameterIns = 0;
info.parameterOuts = 0;
info.name = gNullCharPtr;
info.label = gNullCharPtr;
info.maker = gNullCharPtr;
info.copyright = gNullCharPtr;
return &info;
}



+ 1
- 0
source/backend/CarlaStandalone.cpp View File

@@ -358,6 +358,7 @@ static CarlaNSM gNSM;
// -------------------------------------------------------------------------------------------------------------------
// API

#define CARLA_COMMON_NEED_CHECKSTRINGPTR
#include "CarlaHostCommon.cpp"

// -------------------------------------------------------------------------------------------------------------------


+ 1
- 1
source/backend/plugin/AuPlugin.cpp View File

@@ -25,7 +25,7 @@ CARLA_BACKEND_START_NAMESPACE

CarlaPlugin* CarlaPlugin::newAU(const Initializer& init)
{
carla_debug("CarlaPlugin::newAU({%p, \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.uniqueId);
carla_debug("CarlaPlugin::newAU({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "})", init.engine, init.filename, init.name, init.label, init.uniqueId);

#if defined(CARLA_OS_MAC)
return newJuce(init, "AU");


+ 32
- 28
source/backend/plugin/JucePlugin.cpp View File

@@ -170,7 +170,10 @@ public:

void getLabel(char* const strBuf) const noexcept override
{
std::strncpy(strBuf, fDesc.name.toRawUTF8(), STR_MAX);
if (fDesc.pluginFormatName == "AU" || fDesc.pluginFormatName == "AudioUnit")
std::strncpy(strBuf, fDesc.fileOrIdentifier.toRawUTF8(), STR_MAX);
else
std::strncpy(strBuf, fDesc.name.toRawUTF8(), STR_MAX);
}

void getMaker(char* const strBuf) const noexcept override
@@ -1036,7 +1039,7 @@ protected:
// -------------------------------------------------------------------

public:
bool init(const char* const filename, const char* const name, /*const char* const label, */const int64_t uniqueId, const char* const format)
bool init(const char* const filename, const char* const name, const char* const label, const int64_t uniqueId, const char* const format)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

@@ -1049,44 +1052,45 @@ public:
return false;
}

if (filename == nullptr || filename[0] == '\0')
if (format == nullptr || format[0] == '\0')
{
pData->engine->setLastError("null filename");
pData->engine->setLastError("null format");
return false;
}

#if 0
if (label == nullptr || label[0] == '\0')
if (std::strcmp(format, "AU") == 0)
{
pData->engine->setLastError("null label");
return false;
}
#endif
if (label == nullptr || label[0] == '\0')
{
pData->engine->setLastError("null label");
return false;
}

if (format == nullptr || format[0] == '\0')
{
pData->engine->setLastError("null format");
return false;
fDesc.fileOrIdentifier = label;
}
else
{
if (filename == nullptr || filename[0] == '\0')
{
pData->engine->setLastError("null filename");
return false;
}

// ---------------------------------------------------------------
// fix path for wine usage

String jfilename(filename);
String jfilename(filename);

#ifdef CARLA_OS_WIN
if (jfilename.startsWith("/"))
{
jfilename.replace("/", "\\");
jfilename = "Z:" + jfilename;
}
if (jfilename.startsWith("/"))
{
jfilename.replace("/", "\\");
jfilename = "Z:" + jfilename;
}
#endif

//fDesc.name = fDesc.descriptiveName = label;
fDesc.uid = static_cast<int>(uniqueId);
fDesc.fileOrIdentifier = jfilename;
fDesc.pluginFormatName = format;
fDesc.fileOrIdentifier = jfilename;
fDesc.uid = static_cast<int>(uniqueId);
}

fDesc.pluginFormatName = format;
fFormatManager.addDefaultFormats();

String error;
@@ -1174,7 +1178,7 @@ CarlaPlugin* CarlaPlugin::newJuce(const Initializer& init, const char* const for
#if (defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN))
JucePlugin* const plugin(new JucePlugin(init.engine, init.id));

if (! plugin->init(init.filename, init.name, /*init.label,*/ init.uniqueId, format))
if (! plugin->init(init.filename, init.name, init.label, init.uniqueId, format))
{
delete plugin;
return nullptr;


+ 2
- 0
source/utils/CarlaBackendUtils.hpp View File

@@ -480,6 +480,8 @@ PluginType getPluginTypeFromString(const char* const ctype) noexcept
return PLUGIN_VST3;
if (stype == "au")
return PLUGIN_AU;
if (stype == "audiounit")
return PLUGIN_AU;
if (stype == "gig")
return PLUGIN_GIG;
if (stype == "sf2")


+ 2
- 4
source/utils/CarlaStateUtils.cpp View File

@@ -285,7 +285,7 @@ bool StateSave::fillFromXmlElement(const XmlElement* const xmlElement)
type = xmlSafeStringCharDup(text, false);
else if (tag.equalsIgnoreCase("name"))
name = xmlSafeStringCharDup(text, false);
else if (tag.equalsIgnoreCase("label") || tag.equalsIgnoreCase("uri"))
else if (tag.equalsIgnoreCase("label") || tag.equalsIgnoreCase("identifier") || tag.equalsIgnoreCase("uri"))
label = xmlSafeStringCharDup(text, false);
else if (tag.equalsIgnoreCase("binary") || tag.equalsIgnoreCase("bundle") || tag.equalsIgnoreCase("filename"))
binary = xmlSafeStringCharDup(text, false);
@@ -511,9 +511,7 @@ String StateSave::toString() const
infoXml << " <UniqueID>" << uniqueId << "</UniqueID>\n";
break;
case PLUGIN_AU:
// TODO?
infoXml << " <Binary>" << xmlSafeString(binary, true) << "</Binary>\n";
infoXml << " <UniqueID>" << uniqueId << "</UniqueID>\n";
infoXml << " <Identifier>" << xmlSafeString(label, true) << "</Identifier>\n";
break;
case PLUGIN_GIG:
case PLUGIN_SF2:


Loading…
Cancel
Save