Introduce blacklisted plugins to Lv2 interface

This commit is contained in:
Johannes Lorenz
2020-11-08 01:47:17 +01:00
committed by Johannes Lorenz
parent 7dd6a39366
commit 01f2fa5c29
3 changed files with 56 additions and 0 deletions

View File

@@ -131,6 +131,11 @@ public:
}
bool isFeatureSupported(const char* featName) const;
static const std::set<const char*, Lv2Manager::CmpStr>& 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<const char*, Lv2Manager::CmpStr> pluginBlacklist;
// functions
bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr);
};

View File

@@ -26,6 +26,7 @@
#ifdef LMMS_HAVE_LV2
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <lilv/lilv.h>
@@ -36,6 +37,7 @@
#include <QElapsedTimer>
#include "ConfigManager.h"
#include "Engine.h"
#include "Plugin.h"
#include "PluginFactory.h"
#include "Lv2ControlBase.h"
@@ -44,6 +46,13 @@
const std::set<const char*, Lv2Manager::CmpStr> 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.";
}
}

View File

@@ -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;