commit ad055720fc348478717037017edb003072278d6d
parent 0f31c24917043d6841fcc16efcb0e4e85bc51a89
Author: falkTX <falktx@falktx.com>
Date: Fri, 5 Nov 2021 12:41:31 +0000
Add Plugin::isDummyInstance() method, useful for some plugins
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
7 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp
@@ -845,6 +845,14 @@ public:
*/
const char* getBundlePath() const noexcept;
+ /**
+ Check if this plugin instance is a "dummy" one used for plugin meta-data/information export.@n
+ When true no processing will be done, the plugin is created only to extract information.@n
+ In DPF, LADSPA/DSSI, VST2 and VST3 formats create one global instance per plugin binary
+ while LV2 creates one when generating turtle meta-data.
+ */
+ bool isDummyInstance() const noexcept;
+
#if DISTRHO_PLUGIN_WANT_TIMEPOS
/**
Get the current host transport time position.@n
diff --git a/distrho/src/DistrhoPlugin.cpp b/distrho/src/DistrhoPlugin.cpp
@@ -24,6 +24,7 @@ START_NAMESPACE_DISTRHO
uint32_t d_nextBufferSize = 0;
double d_nextSampleRate = 0.0;
const char* d_nextBundlePath = nullptr;
+bool d_nextPluginIsDummy = false;
bool d_nextCanRequestParameterValueChanges = false;
/* ------------------------------------------------------------------------------------------------------------
@@ -106,6 +107,11 @@ const char* Plugin::getBundlePath() const noexcept
return pData->bundlePath;
}
+bool Plugin::isDummyInstance() const noexcept
+{
+ return pData->isDummy;
+}
+
#if DISTRHO_PLUGIN_WANT_TIMEPOS
const TimePosition& Plugin::getTimePosition() const noexcept
{
diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp
@@ -34,6 +34,7 @@ static const uint32_t kMaxMidiEvents = 512;
extern uint32_t d_nextBufferSize;
extern double d_nextSampleRate;
extern const char* d_nextBundlePath;
+extern bool d_nextPluginIsDummy;
extern bool d_nextCanRequestParameterValueChanges;
// -----------------------------------------------------------------------
@@ -84,6 +85,8 @@ static void fillInPredefinedPortGroupData(const uint32_t groupId, PortGroup& por
// Plugin private data
struct Plugin::PrivateData {
+ const bool canRequestParameterValueChanges;
+ const bool isDummy;
bool isProcessing;
#if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0
@@ -124,10 +127,11 @@ struct Plugin::PrivateData {
uint32_t bufferSize;
double sampleRate;
char* bundlePath;
- bool canRequestParameterValueChanges;
PrivateData() noexcept
- : isProcessing(false),
+ : canRequestParameterValueChanges(d_nextCanRequestParameterValueChanges),
+ isDummy(d_nextPluginIsDummy),
+ isProcessing(false),
#if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0
audioPorts(nullptr),
#endif
@@ -153,8 +157,7 @@ struct Plugin::PrivateData {
requestParameterValueChangeCallbackFunc(nullptr),
bufferSize(d_nextBufferSize),
sampleRate(d_nextSampleRate),
- bundlePath(d_nextBundlePath != nullptr ? strdup(d_nextBundlePath) : nullptr),
- canRequestParameterValueChanges(d_nextCanRequestParameterValueChanges)
+ bundlePath(d_nextBundlePath != nullptr ? strdup(d_nextBundlePath) : nullptr)
{
DISTRHO_SAFE_ASSERT(bufferSize != 0);
DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate));
diff --git a/distrho/src/DistrhoPluginLADSPA+DSSI.cpp b/distrho/src/DistrhoPluginLADSPA+DSSI.cpp
@@ -553,9 +553,11 @@ static const struct DescriptorInitializer
// Create dummy plugin to get data from
d_nextBufferSize = 512;
d_nextSampleRate = 44100.0;
+ d_nextPluginIsDummy = true;
const PluginExporter plugin(nullptr, nullptr, nullptr);
d_nextBufferSize = 0;
d_nextSampleRate = 0.0;
+ d_nextPluginIsDummy = false;
// Get port count, init
ulong port = 0;
diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp
@@ -231,9 +231,11 @@ void lv2_generate_ttl(const char* const basename)
// Dummy plugin to get data from
d_nextBufferSize = 512;
d_nextSampleRate = 44100.0;
+ d_nextPluginIsDummy = true;
PluginExporter plugin(nullptr, nullptr, nullptr);
d_nextBufferSize = 0;
d_nextSampleRate = 0.0;
+ d_nextPluginIsDummy = false;
const String pluginDLL(basename);
const String pluginTTL(pluginDLL + ".ttl");
diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp
@@ -1406,6 +1406,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
// set valid but dummy values
d_nextBufferSize = 512;
d_nextSampleRate = 44100.0;
+ d_nextPluginIsDummy = true;
d_nextCanRequestParameterValueChanges = true;
}
@@ -1417,6 +1418,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
// unset
d_nextBufferSize = 0;
d_nextSampleRate = 0.0;
+ d_nextPluginIsDummy = false;
d_nextCanRequestParameterValueChanges = false;
*(PluginExporter**)ptr = &plugin;
diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp
@@ -3544,10 +3544,12 @@ static const PluginExporter& _getPluginInfo()
{
d_nextBufferSize = 512;
d_nextSampleRate = 44100.0;
+ d_nextPluginIsDummy = true;
d_nextCanRequestParameterValueChanges = true;
static const PluginExporter gPluginInfo(nullptr, nullptr, nullptr);
d_nextBufferSize = 0;
d_nextSampleRate = 0.0;
+ d_nextPluginIsDummy = false;
d_nextCanRequestParameterValueChanges = false;
return gPluginInfo;