Browse Source

Fix calling canRequestParameterValueChanges() during constructor

Signed-off-by: falkTX <falktx@falktx.com>
pull/277/head
falkTX 4 years ago
parent
commit
f9ff394a95
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 10 additions and 2 deletions
  1. +2
    -1
      distrho/src/DistrhoPlugin.cpp
  2. +4
    -1
      distrho/src/DistrhoPluginInternal.hpp
  3. +1
    -0
      distrho/src/DistrhoPluginLV2.cpp
  4. +3
    -0
      distrho/src/DistrhoPluginVST.cpp

+ 2
- 1
distrho/src/DistrhoPlugin.cpp View File

@@ -23,6 +23,7 @@ START_NAMESPACE_DISTRHO

uint32_t d_lastBufferSize = 0;
double d_lastSampleRate = 0.0;
bool d_lastCanRequestParameterValueChanges = false;

/* ------------------------------------------------------------------------------------------------------------
* Static fallback data, see DistrhoPluginInternal.hpp */
@@ -112,7 +113,7 @@ bool Plugin::writeMidiEvent(const MidiEvent& midiEvent) noexcept
#if DISTRHO_PLUGIN_WANT_PARAMETER_VALUE_CHANGE_REQUEST
bool Plugin::canRequestParameterValueChanges() const noexcept
{
return pData->requestParameterValueChangeCallbackFunc != nullptr;
return pData->canRequestParameterValueChanges;
}

bool Plugin::requestParameterValueChange(const uint32_t index, const float value) noexcept


+ 4
- 1
distrho/src/DistrhoPluginInternal.hpp View File

@@ -31,6 +31,7 @@ static const uint32_t kMaxMidiEvents = 512;

extern uint32_t d_lastBufferSize;
extern double d_lastSampleRate;
extern bool d_lastCanRequestParameterValueChanges;

// -----------------------------------------------------------------------
// DSP callbacks
@@ -78,6 +79,7 @@ struct Plugin::PrivateData {

uint32_t bufferSize;
double sampleRate;
bool canRequestParameterValueChanges;

PrivateData() noexcept
: isProcessing(false),
@@ -103,7 +105,8 @@ struct Plugin::PrivateData {
writeMidiCallbackFunc(nullptr),
requestParameterValueChangeCallbackFunc(nullptr),
bufferSize(d_lastBufferSize),
sampleRate(d_lastSampleRate)
sampleRate(d_lastSampleRate),
canRequestParameterValueChanges(d_lastCanRequestParameterValueChanges)
{
DISTRHO_SAFE_ASSERT(bufferSize != 0);
DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate));


+ 1
- 0
distrho/src/DistrhoPluginLV2.cpp View File

@@ -1367,6 +1367,7 @@ static LV2_Handle lv2_instantiate(const LV2_Descriptor*, double sampleRate, cons
}

d_lastSampleRate = sampleRate;
d_lastCanRequestParameterValueChanges = ctrlInPortChangeReq != nullptr;

return new PluginLv2(sampleRate, uridMap, worker, ctrlInPortChangeReq, usingNominal);
}


+ 3
- 0
distrho/src/DistrhoPluginVST.cpp View File

@@ -1286,6 +1286,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
// set valid but dummy values
d_lastBufferSize = 512;
d_lastSampleRate = 44100.0;
d_lastCanRequestParameterValueChanges = true;
}

// Create dummy plugin to get data from
@@ -1296,6 +1297,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
// unset
d_lastBufferSize = 0;
d_lastSampleRate = 0.0;
d_lastCanRequestParameterValueChanges = false;

*(PluginExporter**)ptr = &plugin;
return 0;
@@ -1317,6 +1319,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t

d_lastBufferSize = audioMaster(effect, audioMasterGetBlockSize, 0, 0, nullptr, 0.0f);
d_lastSampleRate = audioMaster(effect, audioMasterGetSampleRate, 0, 0, nullptr, 0.0f);
d_lastCanRequestParameterValueChanges = true;

// some hosts are not ready at this point or return 0 buffersize/samplerate
if (d_lastBufferSize == 0)


Loading…
Cancel
Save