diff --git a/include/Lv2Manager.h b/include/Lv2Manager.h index 6261d70f6..585fdafc5 100644 --- a/include/Lv2Manager.h +++ b/include/Lv2Manager.h @@ -131,6 +131,11 @@ public: } bool isFeatureSupported(const char* featName) const; + static const std::set& getPluginBlacklist() + { + return pluginBlacklist; + } + private: // general data bool m_debug; //!< if set, debug output will be printed @@ -144,6 +149,9 @@ private: // URID cache for fast URID access Lv2UridCache m_uridCache; + // static + static const std::set pluginBlacklist; + // functions bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr); }; diff --git a/src/core/lv2/Lv2Manager.cpp b/src/core/lv2/Lv2Manager.cpp index b1f03079b..4dbb30e18 100644 --- a/src/core/lv2/Lv2Manager.cpp +++ b/src/core/lv2/Lv2Manager.cpp @@ -26,6 +26,7 @@ #ifdef LMMS_HAVE_LV2 +#include #include #include #include @@ -36,6 +37,7 @@ #include #include "ConfigManager.h" +#include "Engine.h" #include "Plugin.h" #include "PluginFactory.h" #include "Lv2ControlBase.h" @@ -44,6 +46,13 @@ +const std::set Lv2Manager::pluginBlacklist = +{ +}; + + + + Lv2Manager::Lv2Manager() : m_uridCache(m_uridMap) { @@ -100,6 +109,7 @@ void Lv2Manager::initPlugins() QElapsedTimer timer; timer.start(); + unsigned blacklisted = 0; LILV_FOREACH(plugins, itr, plugins) { const LilvPlugin* curPlug = lilv_plugins_get(plugins, itr); @@ -111,6 +121,15 @@ void Lv2Manager::initPlugins() m_lv2InfoMap[lilv_node_as_uri(lilv_plugin_get_uri(curPlug))] = std::move(info); if(issues.empty()) { ++pluginsLoaded; } + else + { + if(std::any_of(issues.begin(), issues.end(), + [](const PluginIssue& iss) { + return iss.type() == PluginIssueType::blacklisted; })) + { + ++blacklisted; + } + } ++pluginCount; } @@ -133,6 +152,22 @@ void Lv2Manager::initPlugins() " environment variable \"LMMS_LV2_DEBUG\" to nonempty."; } } + + // TODO: might be better in the LMMS core + if(Engine::ignorePluginBlacklist()) + { + qWarning() << + "WARNING! Plugin blacklist disabled! If you want to use the blacklist,\n" + " please set environment variable \"LMMS_IGNORE_BLACKLIST\" to empty or\n" + " do not set it."; + } + else if(blacklisted > 0) + { + qDebug() << + "Lv2 Plugins blacklisted:" << blacklisted << "of" << pluginCount << "\n" + " If you want to ignore the blacklist (dangerous!), please set\n" + " environment variable \"LMMS_IGNORE_BLACKLIST\" to nonempty."; + } } diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 925dca5bd..ee310a504 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -65,6 +65,19 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, unsigned audioChannels[maxCount] = { 0, 0 }; // audio input and output count unsigned midiChannels[maxCount] = { 0, 0 }; // MIDI input and output count + const char* pluginUri = lilv_node_as_uri(lilv_plugin_get_uri(plugin)); + //qDebug() << "Checking plugin" << pluginUri << "..."; + + // TODO: manage a global blacklist outside of the code + // for now, this will help + // this is only a fix for the meantime + const auto& pluginBlacklist = Lv2Manager::getPluginBlacklist(); + if (!Engine::ignorePluginBlacklist() && + pluginBlacklist.find(pluginUri) != pluginBlacklist.end()) + { + issues.emplace_back(blacklisted); + } + for (unsigned portNum = 0; portNum < maxPorts; ++portNum) { Lv2Ports::Meta meta;