Skip to content

Commit

Permalink
Fixed a potential race condition in MPESynthesiser
Browse files Browse the repository at this point in the history
  • Loading branch information
ed95 committed Apr 30, 2019
1 parent 3d7b002 commit df62a7c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -311,6 +313,8 @@ void MPESynthesiser::turnOffAllVoices (bool allowTailOff)
//==============================================================================
void MPESynthesiser::renderNextSubBlock (AudioBuffer<float>& buffer, int startSample, int numSamples)
{
const ScopedLock sl (voicesLock);

for (auto* voice : voices)
{
if (voice->isActive())
Expand All @@ -320,6 +324,8 @@ void MPESynthesiser::renderNextSubBlock (AudioBuffer<float>& buffer, int startSa

void MPESynthesiser::renderNextSubBlock (AudioBuffer<double>& buffer, int startSample, int numSamples)
{
const ScopedLock sl (voicesLock);

for (auto* voice : voices)
{
if (voice->isActive())
Expand Down

0 comments on commit df62a7c

Please sign in to comment.