From f7dda0396aa447d035b0d60f073f8de093e25492 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 3 Feb 2024 13:53:07 +0100 Subject: [PATCH] Skip some unnecessary plugin scanning steps Signed-off-by: falkTX --- resources/ui/carla_settings.ui | 2 +- source/backend/utils/PluginDiscovery.cpp | 86 ++++++++++++++++++++++++- source/frontend/pluginlist/pluginlistdialog.cpp | 41 ++++++++---- 3 files changed, 113 insertions(+), 16 deletions(-) diff --git a/resources/ui/carla_settings.ui b/resources/ui/carla_settings.ui index 224d66a0b..0e485507d 100644 --- a/resources/ui/carla_settings.ui +++ b/resources/ui/carla_settings.ui @@ -1008,7 +1008,7 @@ Maximum number of parameters to allow in the built-in 'Edit' dialog - 1000 + 2000 diff --git a/source/backend/utils/PluginDiscovery.cpp b/source/backend/utils/PluginDiscovery.cpp index 9392d92a0..acd5c2ca0 100644 --- a/source/backend/utils/PluginDiscovery.cpp +++ b/source/backend/utils/PluginDiscovery.cpp @@ -111,6 +111,7 @@ public: fDiscoveryCallback(discoveryCb), fCheckCacheCallback(checkCacheCb), fCallbackPtr(callbackPtr), + fPluginPath(nullptr), fPluginsFoundInBinary(false), fBinaryIndex(0), fBinaryCount(static_cast(binaries.size())), @@ -129,12 +130,14 @@ public: const PluginType ptype, const CarlaPluginDiscoveryCallback discoveryCb, const CarlaPluginCheckCacheCallback checkCacheCb, - void* const callbackPtr) + void* const callbackPtr, + const char* const pluginPath = nullptr) : fBinaryType(btype), fPluginType(ptype), fDiscoveryCallback(discoveryCb), fCheckCacheCallback(checkCacheCb), fCallbackPtr(callbackPtr), + fPluginPath(pluginPath != nullptr ? carla_strdup_safe(pluginPath) : nullptr), fPluginsFoundInBinary(false), fBinaryIndex(0), fBinaryCount(1), @@ -153,6 +156,7 @@ public: std::free(fNextLabel); std::free(fNextMaker); std::free(fNextName); + delete[] fPluginPath; } bool idle() @@ -385,6 +389,7 @@ private: const CarlaPluginDiscoveryCallback fDiscoveryCallback; const CarlaPluginCheckCacheCallback fCheckCacheCallback; void* const fCallbackPtr; + const char* fPluginPath; bool fPluginsFoundInBinary; uint fBinaryIndex; @@ -469,6 +474,66 @@ private: if (fBinaries.empty()) { + if (fBinaryType == CB::BINARY_NATIVE) + { + switch (fPluginType) + { + default: + break; + case CB::PLUGIN_INTERNAL: + case CB::PLUGIN_LV2: + case CB::PLUGIN_JSFX: + case CB::PLUGIN_SFZ: + if (const uint count = carla_get_cached_plugin_count(fPluginType, fPluginPath)) + { + for (uint i=0; ivalid) + continue; + + char* filename = nullptr; + CarlaPluginDiscoveryInfo info = {}; + info.btype = CB::BINARY_NATIVE; + info.ptype = fPluginType; + info.metadata.name = pinfo->name; + info.metadata.maker = pinfo->maker; + info.metadata.category = pinfo->category; + info.metadata.hints = pinfo->hints; + info.io.audioIns = pinfo->audioIns; + info.io.audioOuts = pinfo->audioOuts; + info.io.cvIns = pinfo->cvIns; + info.io.cvOuts = pinfo->cvOuts; + info.io.midiIns = pinfo->midiIns; + info.io.midiOuts = pinfo->midiOuts; + info.io.parameterIns = pinfo->parameterIns; + info.io.parameterOuts = pinfo->parameterOuts; + + if (fPluginType == CB::PLUGIN_LV2) + { + const char* const slash = std::strchr(pinfo->label, CARLA_OS_SEP); + CARLA_SAFE_ASSERT_BREAK(slash != nullptr); + filename = strdup(pinfo->label); + filename[slash - pinfo->label] = '\0'; + info.filename = filename; + info.label = slash + 1; + } + else + { + info.filename = gPluginsDiscoveryNullCharPtr; + info.label = pinfo->label; + } + + fDiscoveryCallback(fCallbackPtr, &info, nullptr); + + std::free(filename); + } + } + return; + } + } + #ifndef CARLA_OS_WIN if (helperTool.isNotEmpty()) startPipeServer(helperTool.toRawUTF8(), fDiscoveryTool, getPluginTypeAsString(fPluginType), ":all"); @@ -666,20 +731,35 @@ CarlaPluginDiscoveryHandle carla_plugin_discovery_start(const char* const discov switch (ptype) { + case CB::PLUGIN_INTERNAL: + case CB::PLUGIN_LV2: + case CB::PLUGIN_SFZ: + case CB::PLUGIN_JSFX: + case CB::PLUGIN_DLS: + case CB::PLUGIN_GIG: + case CB::PLUGIN_SF2: + CARLA_SAFE_ASSERT_UINT_RETURN(btype == CB::BINARY_NATIVE, btype, nullptr); + break; + default: + break; + } + + switch (ptype) + { case CB::PLUGIN_NONE: case CB::PLUGIN_JACK: case CB::PLUGIN_TYPE_COUNT: return nullptr; + case CB::PLUGIN_LV2: case CB::PLUGIN_SFZ: case CB::PLUGIN_JSFX: { const CarlaScopedEnvVar csev("CARLA_DISCOVERY_PATH", pluginPath); - return new CarlaPluginDiscovery(discoveryTool, btype, ptype, discoveryCb, checkCacheCb, callbackPtr); + return new CarlaPluginDiscovery(discoveryTool, btype, ptype, discoveryCb, checkCacheCb, callbackPtr, pluginPath); } case CB::PLUGIN_INTERNAL: - case CB::PLUGIN_LV2: case CB::PLUGIN_AU: return new CarlaPluginDiscovery(discoveryTool, btype, ptype, discoveryCb, checkCacheCb, callbackPtr); diff --git a/source/frontend/pluginlist/pluginlistdialog.cpp b/source/frontend/pluginlist/pluginlistdialog.cpp index 053d48a15..f3dafac2f 100644 --- a/source/frontend/pluginlist/pluginlistdialog.cpp +++ b/source/frontend/pluginlist/pluginlistdialog.cpp @@ -696,7 +696,7 @@ struct PluginListDialog::PrivateData { if (btype == BINARY_NATIVE) { btype = BINARY_WIN32; - ptype = PLUGIN_INTERNAL; + ptype = PLUGIN_NONE; tool = carla_get_library_folder(); tool += CARLA_OS_SEP_STR "carla-discovery-win32.exe"; @@ -714,7 +714,7 @@ struct PluginListDialog::PrivateData { if (btype == BINARY_NATIVE) { btype = BINARY_POSIX32; - ptype = PLUGIN_INTERNAL; + ptype = PLUGIN_NONE; tool = carla_get_library_folder(); tool += CARLA_OS_SEP_STR "carla-discovery-posix32"; @@ -731,7 +731,7 @@ struct PluginListDialog::PrivateData { if (btype == BINARY_NATIVE || btype == BINARY_POSIX32) { btype = BINARY_WIN64; - ptype = PLUGIN_INTERNAL; + ptype = PLUGIN_NONE; tool = carla_get_library_folder(); tool += CARLA_OS_SEP_STR "carla-discovery-win64.exe"; @@ -743,7 +743,7 @@ struct PluginListDialog::PrivateData { if (btype != BINARY_WIN32) { btype = BINARY_WIN32; - ptype = PLUGIN_INTERNAL; + ptype = PLUGIN_NONE; tool = carla_get_library_folder(); tool += CARLA_OS_SEP_STR "carla-discovery-win32.exe"; @@ -1221,10 +1221,14 @@ void PluginListDialog::timerEvent(QTimerEvent* const event) break; case PLUGIN_DSSI: #endif - ui.label->setText(tr("Discovering LV2 plugins...")); - path = p->paths.lv2; - p->discovery.ptype = PLUGIN_LV2; - break; + if (p->discovery.btype == BINARY_NATIVE && p->paths.lv2.isNotEmpty()) + { + ui.label->setText(tr("Discovering LV2 plugins...")); + path = p->paths.lv2; + p->discovery.ptype = PLUGIN_LV2; + break; + } + [[fallthrough]]; case PLUGIN_LV2: ui.label->setText(tr("Discovering VST2 plugins...")); path = p->paths.vst2; @@ -1281,11 +1285,24 @@ void PluginListDialog::timerEvent(QTimerEvent* const event) case PLUGIN_SFZ: #endif default: - // discovery complete - #ifndef CARLA_FRONTEND_ONLY_EMBEDDABLE_PLUGINS - if (! p->discovery.nextTool()) - #endif + // discovery complete? + for (;;) + { + #ifndef CARLA_FRONTEND_ONLY_EMBEDDABLE_PLUGINS + if (p->discovery.nextTool()) + { + // tool has nothing to search, go to next one + if (p->discovery.ptype == PLUGIN_NONE) + continue; + + // there is still to do, break out of loop + break; + } + #endif + refreshPluginsStop(); + break; + } } if (p->timerId == 0) -- 2.11.4.GIT