diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index ea129a474b5..faaa56dd25c 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -111,6 +111,20 @@ class CallbackMaxSizeEnforcer : public AudioIODeviceCallback jassert ((int) storedInputChannels.size() == numInputChannels); jassert ((int) storedOutputChannels.size() == numOutputChannels); + // A device that is mid-reconfiguration can report a buffer size of 0 + // (e.g. the JACK backend does this when its client is unavailable), + // which would otherwise make the chunking loop below spin forever on + // the audio thread. Emit a silent block instead; the next call to + // audioDeviceAboutToStart() will restore the real block size. + if (maximumSize <= 0) + { + for (int i = 0; i < numOutputChannels; ++i) + if (auto* channel = outputChannelData[i]) + zeromem (channel, (size_t) numSamples * sizeof (float)); + + return; + } + int position = 0; while (position < numSamples)