From 5bd11f5d5c766670861d5c4feeba3e40ba498d15 Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Mon, 2 Nov 2026 17:03:55 +0300 Subject: [PATCH] Keep the 4/5-frame gap between device-paced audio frames to Linux Co-Authored-By: Claude Opus 5.5 --- runtime/audren.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/audren.c b/runtime/audren.c index 4d127161..5ede6072 100644 --- a/runtime/audren.c +++ b/runtime/audren.c @@ -356,8 +356,14 @@ static void render_thread(void *p) { // and the frames would otherwise render back to back. On hardware the DSP renders one frame every 5 ms and // the game's audio thread works in between; AUX effects need that time to fill the return ring, or mix_aux // reads stale samples and the frame clicks at its seams. Device-paced frames stay at least 4/5 of a frame - // apart, which still refills a period well before the device drains it. + // apart, which still refills a period well before the device drains it. Linux only: on Windows SDL pulls + // 480-sample periods, and a sink dump (TOTK_AUDIO_DUMP) of the bursts there showed no more seam spikes than + // chance, so a wait on this thread buys nothing. +#ifdef __linux__ const uint64_t gap_ns = frame_ns * 4 / 5; +#else + const uint64_t gap_ns = 0; +#endif uint64_t next = kern_now_ns(), last = 0; while (plat_cas32(&r->running, 0, 0)) { uint64_t now = kern_now_ns();