From 11bd36b3ce9716b6b6f9234e81e42efeceda1637 Mon Sep 17 00:00:00 2001 From: hogliux Date: Mon, 24 Oct 2022 14:07:39 +0200 Subject: [PATCH] AudioProcessorGraph: Ensured that nodes are deleted soon after being removed from the graph --- .../processors/juce_AudioProcessorGraph.cpp | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 49b1640f57..218b4ac98a 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -1326,9 +1326,19 @@ private: At the top of the audio callback, RenderSequenceExchange::updateAudioThreadState will attempt to install the most-recently-baked graph, if there's one waiting. */ -class RenderSequenceExchange +class RenderSequenceExchange : private Timer { public: + RenderSequenceExchange() + { + startTimer (500); + } + + ~RenderSequenceExchange() override + { + stopTimer(); + } + void set (std::unique_ptr&& next) { const SpinLock::ScopedLockType lock (mutex); @@ -1353,6 +1363,14 @@ public: RenderSequence* getAudioThreadState() const { return audioThreadState.get(); } private: + void timerCallback() override + { + const SpinLock::ScopedLockType lock (mutex); + + if (! isNew) + mainThreadState.reset(); + } + SpinLock mutex; std::unique_ptr mainThreadState, audioThreadState; bool isNew = false;