Browse Source

Small update to discovery code, cleanup

tags/1.9.4
falkTX 11 years ago
parent
commit
fa64946edc
3 changed files with 59 additions and 36 deletions
  1. +1
    -0
      source/backend/plugin/VstPlugin.cpp
  2. +51
    -29
      source/discovery/carla-discovery.cpp
  3. +7
    -7
      source/utils/CarlaLibUtils.hpp

+ 1
- 0
source/backend/plugin/VstPlugin.cpp View File

@@ -1838,6 +1838,7 @@ protected:
case audioMasterNeedIdle: case audioMasterNeedIdle:
// Deprecated in VST SDK 2.4 // Deprecated in VST SDK 2.4
fNeedIdle = true; fNeedIdle = true;
ret = 1;
break; break;


case audioMasterSizeWindow: case audioMasterSizeWindow:


+ 51
- 29
source/discovery/carla-discovery.cpp View File

@@ -72,17 +72,20 @@ void print_lib_error(const char* const filename)
DISCOVERY_OUT("error", error); DISCOVERY_OUT("error", error);
} }


#ifdef WANT_VST
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// VST stuff // VST stuff


#ifdef WANT_VST
// Check if plugin needs idle
bool gVstNeedsIdle = false;

// Check if plugin wants midi // Check if plugin wants midi
bool gVstWantsMidi = false; bool gVstWantsMidi = false;


// Check if plugin is processing // Check if plugin is processing
bool gVstIsProcessing = false; bool gVstIsProcessing = false;


// Current uniqueId for vst shell plugins
// Current uniqueId for VST shell plugins
intptr_t gVstCurrentUniqueId = 0; intptr_t gVstCurrentUniqueId = 0;


// Supported Carla features // Supported Carla features
@@ -172,7 +175,11 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
timeInfo.timeSigDenominator = 4; timeInfo.timeSigDenominator = 4;
timeInfo.flags |= kVstTimeSigValid; timeInfo.flags |= kVstTimeSigValid;


#ifdef VESTIGE_HEADER
ret = getAddressFromPointer(&timeInfo); ret = getAddressFromPointer(&timeInfo);
#else
ret = ToVstPtr<VstTimeInfo_R>(&timeInfo);
#endif
break; break;


#if ! VST_FORCE_DEPRECATED #if ! VST_FORCE_DEPRECATED
@@ -189,6 +196,12 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
break; break;
#endif #endif


case audioMasterNeedIdle:
// Deprecated in VST SDK 2.4
gVstNeedsIdle = true;
ret = 1;
break;

case audioMasterGetSampleRate: case audioMasterGetSampleRate:
ret = kSampleRate; ret = kSampleRate;
break; break;
@@ -212,7 +225,7 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
break; break;


case audioMasterGetVendorString: case audioMasterGetVendorString:
if (ptr)
if (ptr != nullptr)
{ {
std::strcpy((char*)ptr, "falkTX"); std::strcpy((char*)ptr, "falkTX");
ret = 1; ret = 1;
@@ -220,7 +233,7 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
break; break;


case audioMasterGetProductString: case audioMasterGetProductString:
if (ptr)
if (ptr != nullptr)
{ {
std::strcpy((char*)ptr, "Carla-Discovery"); std::strcpy((char*)ptr, "Carla-Discovery");
ret = 1; ret = 1;
@@ -228,11 +241,11 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
break; break;


case audioMasterGetVendorVersion: case audioMasterGetVendorVersion:
ret = 0x050; // 0.5.0
ret = 0x1000; // 1.0.0
break; break;


case audioMasterCanDo: case audioMasterCanDo:
if (ptr)
if (ptr != nullptr)
ret = vstHostCanDo((const char*)ptr); ret = vstHostCanDo((const char*)ptr);
break; break;


@@ -254,21 +267,21 @@ intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode
} }
#endif #endif


#ifdef WANT_LINUXSAMPLER
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// LinuxSampler stuff // LinuxSampler stuff


#ifdef WANT_LINUXSAMPLER
class LinuxSamplerScopedEngine class LinuxSamplerScopedEngine
{ {
public: public:
LinuxSamplerScopedEngine(const char* const filename, const char* const stype) LinuxSamplerScopedEngine(const char* const filename, const char* const stype)
: engine(nullptr),
ins(nullptr)
: fEngine(nullptr),
fIns(nullptr)
{ {
using namespace LinuxSampler; using namespace LinuxSampler;


try { try {
engine = EngineFactory::Create(stype);
fEngine = EngineFactory::Create(stype);
} }
catch (const Exception& e) catch (const Exception& e)
{ {
@@ -276,12 +289,12 @@ public:
return; return;
} }


if (engine == nullptr)
if (fEngine == nullptr)
return; return;


ins = engine->GetInstrumentManager();
fIns = fEngine->GetInstrumentManager();


if (ins == nullptr)
if (fIns == nullptr)
{ {
DISCOVERY_OUT("error", "Failed to get LinuxSampler instrument manager"); DISCOVERY_OUT("error", "Failed to get LinuxSampler instrument manager");
return; return;
@@ -290,25 +303,35 @@ public:
std::vector<InstrumentManager::instrument_id_t> ids; std::vector<InstrumentManager::instrument_id_t> ids;


try { try {
ids = ins->GetInstrumentFileContent(filename);
ids = fIns->GetInstrumentFileContent(filename);
} }
catch (const Exception& e)
catch (const InstrumentManagerException& e)
{ {
DISCOVERY_OUT("error", e.what()); DISCOVERY_OUT("error", e.what());
return; return;
} }


if (ids.size() > 0)
if (ids.size() == 0)
return;

InstrumentManager::instrument_info_t info;

try {
info = fIns->GetInstrumentInfo(ids[0]);
}
catch (const InstrumentManagerException& e)
{ {
InstrumentManager::instrument_info_t info = ins->GetInstrumentInfo(ids[0]);
outputInfo(&info, ids.size());
DISCOVERY_OUT("error", e.what());
return;
} }

outputInfo(&info, ids.size());
} }


~LinuxSamplerScopedEngine() ~LinuxSamplerScopedEngine()
{ {
if (engine != nullptr)
LinuxSampler::EngineFactory::Destroy(engine);
if (fEngine != nullptr)
LinuxSampler::EngineFactory::Destroy(fEngine);
} }


static void outputInfo(LinuxSampler::InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr) static void outputInfo(LinuxSampler::InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr)
@@ -322,7 +345,7 @@ public:
DISCOVERY_OUT("maker", info->Artists); DISCOVERY_OUT("maker", info->Artists);
DISCOVERY_OUT("copyright", info->Artists); DISCOVERY_OUT("copyright", info->Artists);
} }
else
else if (basename != nullptr)
{ {
DISCOVERY_OUT("name", basename); DISCOVERY_OUT("name", basename);
DISCOVERY_OUT("label", basename); DISCOVERY_OUT("label", basename);
@@ -342,8 +365,8 @@ public:
} }


private: private:
LinuxSampler::Engine* engine;
LinuxSampler::InstrumentManager* ins;
LinuxSampler::Engine* fEngine;
LinuxSampler::InstrumentManager* fIns;


CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerScopedEngine) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LinuxSamplerScopedEngine)
}; };
@@ -1488,7 +1511,7 @@ int main(int argc, char* argv[])
{ {
handle = lib_open(filename); handle = lib_open(filename);


if (! handle)
if (handle == nullptr)
{ {
print_lib_error(filename); print_lib_error(filename);
return 1; return 1;
@@ -1496,15 +1519,14 @@ int main(int argc, char* argv[])
} }


// never do init for dssi-vst, takes too long and it's crashy // never do init for dssi-vst, takes too long and it's crashy
bool doInit = ! QString(filename).endsWith("dssi-vst.so", Qt::CaseInsensitive);
bool doInit = !QString(filename).endsWith("dssi-vst.so", Qt::CaseInsensitive);


if (doInit && getenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")) if (doInit && getenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS"))
doInit = false; doInit = false;


if (doInit && handle)
if (doInit && handle != nullptr)
{ {
// test fast loading & unloading DLL without initializing the plugin(s) // test fast loading & unloading DLL without initializing the plugin(s)

if (! lib_close(handle)) if (! lib_close(handle))
{ {
print_lib_error(filename); print_lib_error(filename);
@@ -1513,7 +1535,7 @@ int main(int argc, char* argv[])


handle = lib_open(filename); handle = lib_open(filename);


if (! handle)
if (handle == nullptr)
{ {
print_lib_error(filename); print_lib_error(filename);
return 1; return 1;
@@ -1548,7 +1570,7 @@ int main(int argc, char* argv[])
break; break;
} }


if (openLib && handle)
if (openLib && handle != nullptr)
lib_close(handle); lib_close(handle);


return 0; return 0;


+ 7
- 7
source/utils/CarlaLibUtils.hpp View File

@@ -30,7 +30,7 @@
static inline static inline
void* lib_open(const char* const filename) void* lib_open(const char* const filename)
{ {
CARLA_ASSERT(filename);
CARLA_ASSERT(filename != nullptr);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
return (void*)LoadLibraryA(filename); return (void*)LoadLibraryA(filename);
@@ -42,9 +42,9 @@ void* lib_open(const char* const filename)
static inline static inline
bool lib_close(void* const lib) bool lib_close(void* const lib)
{ {
CARLA_ASSERT(lib);
CARLA_ASSERT(lib != nullptr);


if (! lib)
if (lib == nullptr)
return false; return false;


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
@@ -57,10 +57,10 @@ bool lib_close(void* const lib)
static inline static inline
void* lib_symbol(void* const lib, const char* const symbol) void* lib_symbol(void* const lib, const char* const symbol)
{ {
CARLA_ASSERT(lib);
CARLA_ASSERT(symbol);
CARLA_ASSERT(lib != nullptr);
CARLA_ASSERT(symbol != nullptr);


if (! (lib && symbol))
if (lib == nullptr && symbol == nullptr)
return nullptr; return nullptr;


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
@@ -73,7 +73,7 @@ void* lib_symbol(void* const lib, const char* const symbol)
static inline static inline
const char* lib_error(const char* const filename) const char* lib_error(const char* const filename)
{ {
CARLA_ASSERT(filename);
CARLA_ASSERT(filename != nullptr);


#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
static char libError[2048]; static char libError[2048];


Loading…
Cancel
Save