From eee9db0e6befab9ddaf083d673b94751f859626f Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Wed, 3 Jul 2024 01:26:24 +0200 Subject: [PATCH 1/3] Remove term "blacklist" About the PR: * We use "blocked" as an abstract term, when there may be different reasons * If there is a concrete reason, we use a more concrete word like "unstable" or "not useful" * Double negations like "don't block" or "block unstable" are avoided Besides this, this PR * Lets `Lv2Manager` hide the full `std::set` of plugin URIs * Fixes occurences of "BuffersizeLessThan32" - it is less or equal --- include/Engine.h | 2 +- include/Lv2Manager.h | 24 +++++++++++++------ include/PluginIssue.h | 2 +- src/core/ConfigManager.cpp | 2 +- src/core/Engine.cpp | 6 ++--- src/core/PluginIssue.cpp | 8 +++---- src/core/lv2/Lv2Manager.cpp | 47 +++++++++++++++++++++++-------------- src/core/lv2/Lv2Proc.cpp | 24 +++++++++---------- 8 files changed, 68 insertions(+), 47 deletions(-) diff --git a/include/Engine.h b/include/Engine.h index ed4cbd93cbc..36d7329aba5 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -81,7 +81,7 @@ class LMMS_EXPORT Engine : public QObject return s_projectJournal; } - static bool ignorePluginBlacklist(); + static bool enableBlockedPlugins(); #ifdef LMMS_HAVE_LV2 static class Lv2Manager * getLv2Manager() diff --git a/include/Lv2Manager.h b/include/Lv2Manager.h index 58126a0a448..8a9f5168448 100644 --- a/include/Lv2Manager.h +++ b/include/Lv2Manager.h @@ -1,7 +1,7 @@ /* * Lv2Manager.h - Implementation of Lv2Manager class * - * Copyright (c) 2018-2023 Johannes Lorenz + * Copyright (c) 2018-2024 Johannes Lorenz * * This file is part of LMMS - https://lmms.io * @@ -131,14 +131,23 @@ class Lv2Manager AutoLilvNodes findNodes(const LilvNode *subject, const LilvNode *predicate, const LilvNode *object); - static const std::set& getPluginBlacklist() + static bool pluginIsUnstable(const char* pluginUri) { - return pluginBlacklist; + return unstablePlugins.find(pluginUri) != unstablePlugins.end(); } - static const std::set& getPluginBlacklistBuffersizeLessThan32() + static bool pluginIsOnlyUsefulWithUi(const char* pluginUri) { - return pluginBlacklistBuffersizeLessThan32; + return pluginsOnlyUsefulWithUi.find(pluginUri) != pluginsOnlyUsefulWithUi.end(); } + static bool pluginIsUnstableWithBuffersizeLessEqual32(const char* pluginUri) + { + return unstablePluginsBuffersizeLessEqual32.find(pluginUri) != + unstablePluginsBuffersizeLessEqual32.end(); + } + + //! Whether the user generally wants a UI (and we generally support that) + //! Since we do not generally support UI right now, this will always return false... + static bool wantUi(); private: // general data @@ -154,8 +163,9 @@ class Lv2Manager Lv2UridCache m_uridCache; // static - static const std::set - pluginBlacklist, pluginBlacklistBuffersizeLessThan32; + static const std::set unstablePlugins; + static const std::set pluginsOnlyUsefulWithUi; + static const std::set unstablePluginsBuffersizeLessEqual32; // functions bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr); diff --git a/include/PluginIssue.h b/include/PluginIssue.h index 01a4268ecc9..b0b9b194612 100644 --- a/include/PluginIssue.h +++ b/include/PluginIssue.h @@ -57,7 +57,7 @@ enum class PluginIssueType FeatureNotSupported, //!< plugin requires functionality LMMS can't offer // misc BadPortType, //!< port type not supported - Blacklisted, + Blocked, NoIssue }; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 19ce80ddb70..e404f794af0 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -512,7 +512,7 @@ void ConfigManager::loadConfigFile(const QString & configFile) cfg_file.close(); } - // Plugins are searched recursively, blacklist problematic locations + // Plugins are searched recursively, block problematic locations if( m_vstDir.isEmpty() || m_vstDir == QDir::separator() || m_vstDir == "/" || m_vstDir == ensureTrailingSlash( QDir::homePath() ) || !QDir( m_vstDir ).exists() ) diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index c1f609120e3..9c147a8ef01 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -126,9 +126,9 @@ void Engine::destroy() -bool Engine::ignorePluginBlacklist() +bool Engine::enableBlockedPlugins() { - const char* envVar = getenv("LMMS_IGNORE_BLACKLIST"); + const char* envVar = getenv("LMMS_BLOCKED_PLUGINS"); return (envVar && *envVar); } @@ -171,4 +171,4 @@ void *Engine::pickDndPluginKey() Engine * Engine::s_instanceOfMe = nullptr; -} // namespace lmms \ No newline at end of file +} // namespace lmms diff --git a/src/core/PluginIssue.cpp b/src/core/PluginIssue.cpp index c9cf3400faa..b40c4723ba4 100644 --- a/src/core/PluginIssue.cpp +++ b/src/core/PluginIssue.cpp @@ -1,7 +1,7 @@ /* - * PluginIssue.h - PluginIssue class + * PluginIssue.cpp - PluginIssue class implementation * - * Copyright (c) 2019 Johannes Lorenz + * Copyright (c) 2019-2024 Johannes Lorenz * * This file is part of LMMS - https://lmms.io * @@ -68,8 +68,8 @@ const char *PluginIssue::msgFor(const PluginIssueType &it) return "required feature not supported"; case PluginIssueType::BadPortType: return "unsupported port type"; - case PluginIssueType::Blacklisted: - return "blacklisted plugin"; + case PluginIssueType::Blocked: + return "blocked plugin"; case PluginIssueType::NoIssue: return nullptr; } diff --git a/src/core/lv2/Lv2Manager.cpp b/src/core/lv2/Lv2Manager.cpp index 1633b862616..5aae62de40c 100644 --- a/src/core/lv2/Lv2Manager.cpp +++ b/src/core/lv2/Lv2Manager.cpp @@ -1,7 +1,7 @@ /* * Lv2Manager.cpp - Implementation of Lv2Manager class * - * Copyright (c) 2018-2023 Johannes Lorenz + * Copyright (c) 2018-2024 Johannes Lorenz * * This file is part of LMMS - https://lmms.io * @@ -47,7 +47,7 @@ namespace lmms { -const std::set Lv2Manager::pluginBlacklist = +const std::set Lv2Manager::unstablePlugins = { // github.com/calf-studio-gear/calf, #278 "http://calf.sourceforge.net/plugins/Analyzer", @@ -67,7 +67,13 @@ const std::set Lv2Manager::pluginBlacklist = "http://drobilla.net/plugins/blop/square", "http://drobilla.net/plugins/blop/triangle", - // Visualization, meters, and scopes etc., won't work until we have gui support + // unstable + "urn:juced:DrumSynth" +}; + +const std::set Lv2Manager::pluginsOnlyUsefulWithUi = +{ + // Visualization, meters, and scopes etc., won't work if UI is disabled "http://distrho.sf.net/plugins/ProM", "http://distrho.sf.net/plugins/glBars", "http://gareus.org/oss/lv2/meters#spectr30mono", @@ -132,13 +138,10 @@ const std::set Lv2Manager::pluginBlacklist = "urn:juce:TalFilter2", "urn:juce:Vex", "http://zynaddsubfx.sourceforge.net", - "http://geontime.com/geonkick/single", - - // unstable - "urn:juced:DrumSynth" + "http://geontime.com/geonkick/single" }; -const std::set Lv2Manager::pluginBlacklistBuffersizeLessThan32 = +const std::set Lv2Manager::unstablePluginsBuffersizeLessEqual32 = { "http://moddevices.com/plugins/mod-devel/2Voices", "http://moddevices.com/plugins/mod-devel/Capo", @@ -237,7 +240,7 @@ void Lv2Manager::initPlugins() QElapsedTimer timer; timer.start(); - unsigned blacklisted = 0; + unsigned blocked = 0; LILV_FOREACH(plugins, itr, plugins) { const LilvPlugin* curPlug = lilv_plugins_get(plugins, itr); @@ -266,9 +269,9 @@ void Lv2Manager::initPlugins() { if(std::any_of(issues.begin(), issues.end(), [](const PluginIssue& iss) { - return iss.type() == PluginIssueType::Blacklisted; })) + return iss.type() == PluginIssueType::Blocked; })) { - ++blacklisted; + ++blocked; } } ++pluginCount; @@ -295,19 +298,19 @@ void Lv2Manager::initPlugins() } // TODO: might be better in the LMMS core - if(Engine::ignorePluginBlacklist()) + if(Engine::enableBlockedPlugins()) { qWarning() << - "WARNING! Plugin blacklist disabled! If you want to use the blacklist,\n" - " please set environment variable \"LMMS_IGNORE_BLACKLIST\" to empty or\n" + "WARNING! Blocked plugins enabled! If you want to disable them,\n" + " please set environment variable \"LMMS_BLOCKED_PLUGINS\" to empty or\n" " do not set it."; } - else if(blacklisted > 0) + else if(blocked > 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."; + "Blocked Lv2 Plugins:" << blocked << "of" << pluginCount << "\n" + " If you want to enable them (dangerous!), please set\n" + " environment variable \"LMMS_BLOCKED_PLUGINS\" to nonempty."; } } @@ -331,6 +334,14 @@ AutoLilvNodes Lv2Manager::findNodes(const LilvNode *subject, +bool Lv2Manager::wantUi() +{ + return false; +} + + + + // unused + untested yet bool Lv2Manager::isSubclassOf(const LilvPluginClass* clvss, const char* uriStr) { diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 7dfdbc7673c..f62c1266e43 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -1,7 +1,7 @@ /* * Lv2Proc.cpp - Lv2 processor class * - * Copyright (c) 2019-2022 Johannes Lorenz + * Copyright (c) 2019-2024 Johannes Lorenz * * This file is part of LMMS - https://lmms.io * @@ -74,21 +74,21 @@ Plugin::Type Lv2Proc::check(const LilvPlugin *plugin, 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 + // TODO: manage a global list of blocked plugins outside of the code // for now, this will help // this is only a fix for the meantime - if (!Engine::ignorePluginBlacklist()) + if (!Engine::enableBlockedPlugins()) { - const auto& pluginBlacklist = Lv2Manager::getPluginBlacklist(); - const auto& pluginBlacklist32 = Lv2Manager::getPluginBlacklistBuffersizeLessThan32(); - if(pluginBlacklist.find(pluginUri) != pluginBlacklist.end()) + if( // plugin unstable? + Lv2Manager::pluginIsUnstable(pluginUri) || + // plugins only useful with UI? + (!Lv2Manager::wantUi() && + Lv2Manager::pluginIsOnlyUsefulWithUi(pluginUri)) || + // plugin unstable with 32 or less fpp? + (Engine::audioEngine()->framesPerPeriod() <= 32 && + Lv2Manager::pluginIsUnstableWithBuffersizeLessEqual32(pluginUri)) ) { - issues.emplace_back(PluginIssueType::Blacklisted); - } - else if(Engine::audioEngine()->framesPerPeriod() <= 32 && - pluginBlacklist32.find(pluginUri) != pluginBlacklist32.end()) - { - issues.emplace_back(PluginIssueType::Blacklisted); // currently no special blacklist category + issues.emplace_back(PluginIssueType::Blocked); } } From 250e70136b2f47f38df7e20933c778ae8e78745b Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Wed, 3 Jul 2024 21:40:44 +0200 Subject: [PATCH 2/3] LMMS_BLOCKED_PLUGINS -> LMMS_ENABLE_BLOCKED_PLUGINS --- src/core/Engine.cpp | 2 +- src/core/lv2/Lv2Manager.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index 9c147a8ef01..0d0796662f8 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -128,7 +128,7 @@ void Engine::destroy() bool Engine::enableBlockedPlugins() { - const char* envVar = getenv("LMMS_BLOCKED_PLUGINS"); + const char* envVar = getenv("LMMS_ENABLE_BLOCKED_PLUGINS"); return (envVar && *envVar); } diff --git a/src/core/lv2/Lv2Manager.cpp b/src/core/lv2/Lv2Manager.cpp index 5aae62de40c..26bf13412cd 100644 --- a/src/core/lv2/Lv2Manager.cpp +++ b/src/core/lv2/Lv2Manager.cpp @@ -302,7 +302,7 @@ void Lv2Manager::initPlugins() { qWarning() << "WARNING! Blocked plugins enabled! If you want to disable them,\n" - " please set environment variable \"LMMS_BLOCKED_PLUGINS\" to empty or\n" + " please set environment variable \"LMMS_ENABLE_BLOCKED_PLUGINS\" to empty or\n" " do not set it."; } else if(blocked > 0) @@ -310,7 +310,7 @@ void Lv2Manager::initPlugins() qDebug() << "Blocked Lv2 Plugins:" << blocked << "of" << pluginCount << "\n" " If you want to enable them (dangerous!), please set\n" - " environment variable \"LMMS_BLOCKED_PLUGINS\" to nonempty."; + " environment variable \"LMMS_ENABLE_BLOCKED_PLUGINS\" to nonempty."; } } From f10f3a88784f9e4de5e6c685ccbbddd3054b47bf Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Mon, 8 Jul 2024 21:34:03 +0200 Subject: [PATCH 3/3] Move function enableBlockedPlugins --- include/ConfigManager.h | 1 + include/Engine.h | 2 -- src/core/ConfigManager.cpp | 6 ++++++ src/core/Engine.cpp | 9 --------- src/core/lv2/Lv2Manager.cpp | 3 ++- src/core/lv2/Lv2Proc.cpp | 3 ++- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index f6239c29783..3cba834e198 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -230,6 +230,7 @@ class LMMS_EXPORT ConfigManager : public QObject QString defaultVersion() const; + static bool enableBlockedPlugins(); static QStringList availableVstEmbedMethods(); QString vstEmbedMethod() const; diff --git a/include/Engine.h b/include/Engine.h index 36d7329aba5..7e19e2e8483 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -81,8 +81,6 @@ class LMMS_EXPORT Engine : public QObject return s_projectJournal; } - static bool enableBlockedPlugins(); - #ifdef LMMS_HAVE_LV2 static class Lv2Manager * getLv2Manager() { diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index e404f794af0..d3c973020bf 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -188,6 +188,12 @@ QString ConfigManager::defaultVersion() const return LMMS_VERSION; } +bool ConfigManager::enableBlockedPlugins() +{ + const char* envVar = getenv("LMMS_ENABLE_BLOCKED_PLUGINS"); + return (envVar && *envVar); +} + QStringList ConfigManager::availableVstEmbedMethods() { QStringList methods; diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index 0d0796662f8..9435eb69c06 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -126,15 +126,6 @@ void Engine::destroy() -bool Engine::enableBlockedPlugins() -{ - const char* envVar = getenv("LMMS_ENABLE_BLOCKED_PLUGINS"); - return (envVar && *envVar); -} - - - - float Engine::framesPerTick(sample_rate_t sampleRate) { return sampleRate * 60.0f * 4 / diff --git a/src/core/lv2/Lv2Manager.cpp b/src/core/lv2/Lv2Manager.cpp index 26bf13412cd..9807379e44c 100644 --- a/src/core/lv2/Lv2Manager.cpp +++ b/src/core/lv2/Lv2Manager.cpp @@ -36,6 +36,7 @@ #include #include "AudioEngine.h" +#include "ConfigManager.h" #include "Engine.h" #include "Plugin.h" #include "Lv2ControlBase.h" @@ -298,7 +299,7 @@ void Lv2Manager::initPlugins() } // TODO: might be better in the LMMS core - if(Engine::enableBlockedPlugins()) + if(ConfigManager::enableBlockedPlugins()) { qWarning() << "WARNING! Blocked plugins enabled! If you want to disable them,\n" diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index f62c1266e43..42ba2d31106 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -38,6 +38,7 @@ #include "AudioEngine.h" #include "AutomatableModel.h" #include "ComboBoxModel.h" +#include "ConfigManager.h" #include "Engine.h" #include "Lv2Features.h" #include "Lv2Manager.h" @@ -77,7 +78,7 @@ Plugin::Type Lv2Proc::check(const LilvPlugin *plugin, // TODO: manage a global list of blocked plugins outside of the code // for now, this will help // this is only a fix for the meantime - if (!Engine::enableBlockedPlugins()) + if (!ConfigManager::enableBlockedPlugins()) { if( // plugin unstable? Lv2Manager::pluginIsUnstable(pluginUri) ||