From 721f63cebb6050ff81a62720fe41b33057810e18 Mon Sep 17 00:00:00 2001 From: Evan Mezeske Date: Mon, 10 Aug 2026 11:20:46 -0700 Subject: [PATCH] AudioDeviceManager: Fix a hang when a device reports a zero buffer size --- .../audio_io/juce_AudioDeviceManager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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)