From 03f74e99eaceb94d59c9f3b77121bd5e696407bf Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 30 Sep 2019 11:38:00 +0100 Subject: [PATCH] Allow engine to load vst shells with id 0, using the first plugin Signed-off-by: falkTX --- source/backend/plugin/CarlaPluginVST2.cpp | 37 +++++++++++++++++++++++ source/discovery/carla-discovery.cpp | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index 6a0444e2a..41bb2ef3a 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -2394,6 +2394,43 @@ public: dispatcher(effSetBlockSize, 0, iBufferSize); dispatcher(effOpen); + const bool isShell = (dispatcher(effGetPlugCategory) == kPlugCategShell); + + if (sCurrentUniqueId == 0 && isShell) + { + char strBuf[STR_MAX+1]; + carla_zeroChars(strBuf, STR_MAX+1); + + sCurrentUniqueId = dispatcher(effShellGetNextPlugin, 0, 0, strBuf); + + dispatcher(effClose); + fEffect = nullptr; + + sLastCarlaPluginVST2 = this; + + try { + fEffect = vstFn(carla_vst_audioMasterCallback); + } CARLA_SAFE_EXCEPTION_RETURN("Vst init", false); + + sLastCarlaPluginVST2 = nullptr; + sCurrentUniqueId = 0; + + dispatcher(effIdentify); + dispatcher(effSetProcessPrecision, 0, kVstProcessPrecision32); + dispatcher(effSetBlockSizeAndSampleRate, 0, iBufferSize, nullptr, fSampleRate); + dispatcher(effSetSampleRate, 0, 0, nullptr, fSampleRate); + dispatcher(effSetBlockSize, 0, iBufferSize); + dispatcher(effOpen); + } + + if (sCurrentUniqueId == 0 && !isShell) + { + dispatcher(effClose); + fEffect = nullptr; + pData->engine->setLastError("Plugin is not valid (no unique ID after being open)"); + return false; + } + // --------------------------------------------------------------- // get info diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 04a71172b..9825815b4 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -1037,7 +1037,7 @@ static void do_vst_check(lib_t& libHandle, const char* const filename, const boo if (effect->numPrograms > 0) effect->dispatcher(effect, effSetProgram, 0, 0, nullptr, 0.0f); - const bool isShell = (effect->dispatcher(effect, effGetPlugCategory, 0, 0, nullptr, 0.0f) == kPlugCategShell); + const bool isShell = (effect->dispatcher(effect, effGetPlugCategory, 0, 0, nullptr, 0.0f) == kPlugCategShell); if (effect->uniqueID == 0 && !isShell) {