From aa8387e9ec01b097974c54e0897097e69994e46a Mon Sep 17 00:00:00 2001 From: Ville Lindholm Date: Thu, 28 May 2026 22:38:42 +0300 Subject: [PATCH] Bump audio command FIFO size for SDL 3 callback cadence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The audio engine queues sound-control commands (PATCH, PAN, PLAY, STOP, etc.) into an sfifo for the audio thread to consume from inside _run_commands(). The FIFO was sized at 128 commands, which was fine under SDL 1.2's push-callback model: the driver fired callbacks at a predictable cadence that drained the FIFO promptly. SDL 3's pull-stream model on macOS calls our audio callback ~25-30 ms apart with 4096-byte (1024-sample) chunks. Under sustained multi-channel activity (e.g. holding fire in Classic mode, where xkobo_shot generates several commands per shot at ~33 Hz), the FIFO fills faster than the audio thread drains it and overflows. Each overflowed command is a silently dropped sound event — audibly manifest as unevenly-spaced shot sounds. Bumping to 1024 gives the FIFO plenty of headroom (the drain rate at ~250 Hz handles thousands of commands/sec; the FIFO only needs to absorb burst arrivals between drain ticks). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- sound/a_commands.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/a_commands.h b/sound/a_commands.h index 5658710..c42956f 100644 --- a/sound/a_commands.h +++ b/sound/a_commands.h @@ -28,7 +28,15 @@ extern "C" { #endif -#define MAX_COMMANDS 128 +/* + * SDL 3 migration: the audio command FIFO was sized 128 for the SDL 1.2 + * push-callback model where the driver fired predictably-spaced + * callbacks that drained the FIFO promptly. SDL 3's pull-stream model + * can call the audio callback less often / with larger buffers, so + * commands accumulate between drains. 1024 gives a comfortable + * headroom even under sustained heavy fire. + */ +#define MAX_COMMANDS 1024 /*---------------------------------------------------------- Asynchronous command interface stuff