From df62a7c5dc4241ca63efbe4be760a87ca41da3ce Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 30 Apr 2019 14:59:14 +0100 Subject: [PATCH] Fixed a potential race condition in MPESynthesiser --- modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp index fc76d407a3..e53a4003d2 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp @@ -299,6 +299,8 @@ void MPESynthesiser::reduceNumVoices (const int newNumVoices) void MPESynthesiser::turnOffAllVoices (bool allowTailOff) { + 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) @@ -311,6 +313,8 @@ void MPESynthesiser::turnOffAllVoices (bool allowTailOff) //============================================================================== void MPESynthesiser::renderNextSubBlock (AudioBuffer& buffer, int startSample, int numSamples) { + const ScopedLock sl (voicesLock); + for (auto* voice : voices) { if (voice->isActive()) @@ -320,6 +324,8 @@ void MPESynthesiser::renderNextSubBlock (AudioBuffer& buffer, int startSa void MPESynthesiser::renderNextSubBlock (AudioBuffer& buffer, int startSample, int numSamples) { + const ScopedLock sl (voicesLock); + for (auto* voice : voices) { if (voice->isActive())