From cb799fb37cbf35fbab31d2ef89382f4d8cded9aa Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 16 Aug 2019 15:44:53 +0100 Subject: [PATCH] VST3: Don't call restartComponent() when in setupProcessing() --- .../VST3/juce_VST3_Wrapper.cpp | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index cd06128abd..78fdf9035a 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -319,7 +319,7 @@ private: } //============================================================================== - Atomic refCount; + std::atomic refCount { 0 }; std::unique_ptr audioProcessor; //============================================================================== @@ -469,7 +469,7 @@ public: // Only update the AudioProcessor here if we're not playing, // otherwise we get parallel streams of parameter value updates // during playback - if (owner.vst3IsPlaying.get() == 0) + if (! owner.vst3IsPlaying) { auto value = static_cast (v); @@ -888,7 +888,7 @@ public: / static_cast (pluginInstance->getNumPrograms() - 1)); } - if (componentHandler != nullptr) + if (componentHandler != nullptr && ! inSetupProcessing) componentHandler->restartComponent (Vst::kLatencyChanged | Vst::kParamValuesChanged); } @@ -932,7 +932,9 @@ private: Vst::ParamID midiControllerToParameter[numMIDIChannels][Vst::kCountCtrlNumber]; //============================================================================== - Atomic vst3IsPlaying { 0 }; + std::atomic vst3IsPlaying { false }, + inSetupProcessing { false }; + float lastScaleFactorReceived = 1.0f; void setupParameters() @@ -1578,7 +1580,7 @@ public: ~JuceVST3Component() override { if (juceVST3EditController != nullptr) - juceVST3EditController->vst3IsPlaying = 0; + juceVST3EditController->vst3IsPlaying = false; if (pluginInstance != nullptr) if (pluginInstance->getPlayHead() == this) @@ -1644,7 +1646,7 @@ public: tresult PLUGIN_API disconnect (IConnectionPoint*) override { if (juceVST3EditController != nullptr) - juceVST3EditController->vst3IsPlaying = 0; + juceVST3EditController->vst3IsPlaying = false; juceVST3EditController = nullptr; return kResultTrue; @@ -2350,6 +2352,9 @@ public: tresult PLUGIN_API setupProcessing (Vst::ProcessSetup& newSetup) override { + if (juceVST3EditController != nullptr) + juceVST3EditController->inSetupProcessing = true; + if (canProcessSampleSize (newSetup.symbolicSampleSize) != kResultTrue) return kResultFalse; @@ -2363,6 +2368,9 @@ public: preparePlugin (processSetup.sampleRate, processSetup.maxSamplesPerBlock); + if (juceVST3EditController != nullptr) + juceVST3EditController->inSetupProcessing = false; + return kResultTrue; } @@ -2470,14 +2478,14 @@ public: processContext = *data.processContext; if (juceVST3EditController != nullptr) - juceVST3EditController->vst3IsPlaying = processContext.state & Vst::ProcessContext::kPlaying; + juceVST3EditController->vst3IsPlaying = (processContext.state & Vst::ProcessContext::kPlaying); } else { zerostruct (processContext); if (juceVST3EditController != nullptr) - juceVST3EditController->vst3IsPlaying = 0; + juceVST3EditController->vst3IsPlaying = false; } midiBuffer.clear(); @@ -2732,7 +2740,7 @@ private: //============================================================================== ScopedJuceInitialiser_GUI libraryInitialiser; - Atomic refCount { 1 }; + std::atomic refCount { 1 }; AudioProcessor* pluginInstance; ComSmartPtr host; @@ -3049,7 +3057,7 @@ struct JucePluginFactory : public IPluginFactory3 private: //============================================================================== - Atomic refCount { 1 }; + std::atomic refCount { 1 }; const PFactoryInfo factoryInfo; ComSmartPtr host;