From 919338130aa5baeb3b635e9709df296d061cc40e Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 4 Jun 2019 17:09:41 +0100 Subject: [PATCH] Fixed a potential deadlock in MPESynthesiser::turnOffAllVoices() --- .../juce_audio_basics/mpe/juce_MPESynthesiser.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp index e53a4003d287..8eaf95ce7d02 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp @@ -299,12 +299,14 @@ void MPESynthesiser::reduceNumVoices (const int newNumVoices) void MPESynthesiser::turnOffAllVoices (bool allowTailOff) { - const ScopedLock sl (voicesLock); + { + const ScopedLock sl (voicesLock); - // first turn off all voices (it's more efficient to do this immediately - // rather than to go through the MPEInstrument for this). - for (auto* voice : voices) - voice->noteStopped (allowTailOff); + // first turn off all voices (it's more efficient to do this immediately + // rather than to go through the MPEInstrument for this). + for (auto* voice : voices) + voice->noteStopped (allowTailOff); + } // finally make sure the MPE Instrument also doesn't have any notes anymore. instrument->releaseAllNotes();