diff --git a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp index 2cf1cce626..ac519c494b 100644 --- a/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPESynthesiser.cpp @@ -202,8 +202,15 @@ MPESynthesiserVoice* MPESynthesiser::findVoiceToSteal (MPENote noteToStealVoiceF jassert (voice->isActive()); // We wouldn't be here otherwise usableVoices.add (voice); - std::sort (usableVoices.begin(), usableVoices.end(), - [] (const MPESynthesiserVoice* a, const MPESynthesiserVoice* b) { return a->wasStartedBefore (*b); }); + + // NB: Using a functor rather than a lambda here due to scare-stories about + // compilers generating code containing heap allocations.. + struct Sorter + { + bool operator() (const MPESynthesiserVoice* a, const MPESynthesiserVoice* b) const noexcept { return a->wasStartedBefore (*b); } + }; + + std::sort (usableVoices.begin(), usableVoices.end(), Sorter()); if (! voice->isPlayingButReleased()) // Don't protect released notes { diff --git a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp index 36c814f561..fa047d1496 100644 --- a/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp +++ b/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp @@ -514,8 +514,15 @@ SynthesiserVoice* Synthesiser::findVoiceToSteal (SynthesiserSound* soundToPlay, jassert (voice->isVoiceActive()); // We wouldn't be here otherwise usableVoices.add (voice); - std::sort (usableVoices.begin(), usableVoices.end(), - [] (const SynthesiserVoice* a, const SynthesiserVoice* b) { return a->wasStartedBefore (*b); }); + + // NB: Using a functor rather than a lambda here due to scare-stories about + // compilers generating code containing heap allocations.. + struct Sorter + { + bool operator() (const SynthesiserVoice* a, const SynthesiserVoice* b) const noexcept { return a->wasStartedBefore (*b); } + }; + + std::sort (usableVoices.begin(), usableVoices.end(), Sorter()); if (! voice->isPlayingButReleased()) // Don't protect released notes {