Browse Source

Fix for VST plugins that update parameters without telling the host

tags/v2.1-alpha1-winvst
falkTX 7 years ago
parent
commit
15acfd6db3
3 changed files with 42 additions and 12 deletions
  1. +27
    -0
      source/backend/engine/CarlaEngineBridge.cpp
  2. +5
    -2
      source/backend/plugin/CarlaPluginBridge.cpp
  3. +10
    -10
      source/backend/plugin/CarlaPluginVST2.cpp

+ 27
- 0
source/backend/engine/CarlaEngineBridge.cpp View File

@@ -636,6 +636,33 @@ public:
}
break;

case ENGINE_CALLBACK_RELOAD_PARAMETERS:
if (CarlaPlugin* const plugin = pData->plugins[0].plugin)
{
if (const uint32_t count = std::min(pData->options.maxParameters, plugin->getParameterCount()))
{
const CarlaMutexLocker _cml(fShmNonRtServerControl.mutex);

for (uint32_t i=0; i<count; ++i)
{
const ParameterData& paramData(plugin->getParameterData(i));

if (paramData.type != PARAMETER_INPUT && paramData.type != PARAMETER_OUTPUT)
continue;
if ((paramData.hints & PARAMETER_IS_ENABLED) == 0)
continue;

fShmNonRtServerControl.writeOpcode(kPluginBridgeNonRtServerParameterValue);
fShmNonRtServerControl.writeUInt(i);
fShmNonRtServerControl.writeFloat(plugin->getParameterValue(i));
fShmNonRtServerControl.commitWrite();

fShmNonRtServerControl.waitIfDataIsReachingLimit();
}
}
}
break;

default:
break;
}


+ 5
- 2
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -2045,9 +2045,12 @@ public:
if (index < pData->param.count)
{
const float fixedValue(pData->param.getFixedValue(index, value));
fParams[index].value = fixedValue;

CarlaPlugin::setParameterValue(index, fixedValue, false, true, true);
if (carla_isNotEqual(fParams[index].value, fixedValue))
{
fParams[index].value = fixedValue;
CarlaPlugin::setParameterValue(index, fixedValue, false, true, true);
}
}
} break;



+ 10
- 10
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -584,7 +584,7 @@ public:

// Safely disable plugin for reload
const ScopedDisabler sd(this);
const ScopedValueSetter<bool> svs(fIsInitializing, fIsInitializing, true);
const ScopedValueSetter<bool> svs(fIsInitializing, fIsInitializing, false);

if (pData->active)
deactivate();
@@ -1820,26 +1820,26 @@ protected:

const pthread_t thisThread = pthread_self();

// Called from plugin process thread, nasty! (likely MIDI learn)
/**/ if (pthread_equal(thisThread, fProcThread))
/**/ if (fProcThread != kNullThread && pthread_equal(thisThread, fProcThread))
{
// Called from plugin process thread, nasty! (likely MIDI learn)
CARLA_SAFE_ASSERT(fIsProcessing);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, fixedValue);
}
// Called from effSetChunk or effSetProgram
else if (pthread_equal(thisThread, fChangingValuesThread))
else if (fChangingValuesThread != kNullThread && pthread_equal(thisThread, fChangingValuesThread))
{
// Called from effSetChunk or effSetProgram
pData->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, fixedValue);
}
// Called from UI
else if (fUI.isVisible)
{
// Called from UI?
CarlaPlugin::setParameterValue(uindex, fixedValue, false, true, true);
}
// Unknown
// TODO - check if plugin or UI is initializing
else
{
// Unknown
// TODO - check if plugin or UI is initializing
carla_stdout("audioMasterAutomate called from unknown source");

setParameterValue(uindex, fixedValue, true, true, true);
@@ -2092,7 +2092,7 @@ protected:
dispatcher(effEditIdle);

// Update current program
if (pData->prog.count > 0)
if (pData->prog.count > 1)
{
const int32_t current = static_cast<int32_t>(dispatcher(effGetProgram));

@@ -2115,7 +2115,7 @@ protected:
}

if (! fIsInitializing)
pData->engine->callback(ENGINE_CALLBACK_UPDATE, pData->id, 0, 0, 0.0f, nullptr);
pData->engine->callback(ENGINE_CALLBACK_RELOAD_PARAMETERS, pData->id, 0, 0, 0.0f, nullptr);

ret = 1;
break;


Loading…
Cancel
Save