From 68b02efea1673c082090469a1411cf05fe3dc44d Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 10 Feb 2020 14:36:28 +0000 Subject: [PATCH] AudioProcessorGraph: Immediately rebuild the graph if topology changes on the message thread --- .../processors/juce_AudioProcessorGraph.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 1a016a9c42..082a574e6d 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -27,6 +27,14 @@ namespace juce { +static void updateOnMessageThread (AsyncUpdater& updater) +{ + if (MessageManager::getInstance()->isThisTheMessageThread()) + updater.handleAsyncUpdate(); + else + updater.triggerAsyncUpdate(); +} + template struct GraphRenderSequence { @@ -901,7 +909,7 @@ void AudioProcessorGraph::topologyChanged() sendChangeMessage(); if (isPrepared) - triggerAsyncUpdate(); + updateOnMessageThread (*this); } void AudioProcessorGraph::clear() @@ -1262,10 +1270,7 @@ void AudioProcessorGraph::prepareToPlay (double sampleRate, int estimatedSamples clearRenderingSequence(); - if (MessageManager::getInstance()->isThisTheMessageThread()) - handleAsyncUpdate(); - else - triggerAsyncUpdate(); + updateOnMessageThread (*this); } bool AudioProcessorGraph::supportsDoublePrecisionProcessing() const