Bump audio command FIFO size for SDL 3 callback cadence

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 <noreply@anthropic.com>
This commit is contained in:
Ville Lindholm 2026-05-28 22:38:42 +03:00
parent 76c0776aec
commit aa8387e9ec
No known key found for this signature in database
GPG Key ID: 89AE9EAA3B6FDE7C

View File

@ -28,7 +28,15 @@
extern "C" { extern "C" {
#endif #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 Asynchronous command interface stuff