From b6d0bc043149f61059285a9069a62a4b78123ba8 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 20 Jan 2025 18:30:02 -0500
Subject: [PATCH] coreaudio: Use three buffers for the audioqueue, not two.
This doesn't affect latency much, but it makes the system usable if the system
drops you down from the bluetooth a2dp profile (headphones) to the handsfree
(I think...?) profile because the bluetooth audio device is also recording,
which would be extremely common in a VoIP app, but also if you're talking
in a different app while also playing audio.
Fixes #8192.
---
src/audio/coreaudio/SDL_coreaudio.m | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index 3652709e06da1..af54bebcce91d 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -817,7 +817,7 @@ static bool PrepareAudioQueue(SDL_AudioDevice *device)
}
#endif
- int numAudioBuffers = 2;
+ int numAudioBuffers = 3;
const double msecs = (device->sample_frames / ((double)device->spec.freq)) * 1000.0;
if (msecs < MINIMUM_AUDIO_BUFFER_TIME_MS) { // use more buffers if we have a VERY small sample set.
numAudioBuffers = ((int)SDL_ceil(MINIMUM_AUDIO_BUFFER_TIME_MS / msecs) * 2);