Catch up after a stall of the audio renderer by rendering the owed frames without queueing them.

A frame that was not rendered when it was due stayed lost: the timer set its
deadline to now once it was more than 100 ms late, and the device-paced path
only filled the ring to its target again, so after every gap the sound was
heard that much later than the picture it belongs to.

Frames that are owed are now rendered and dropped: mixed in full, so the
voices, the effects and the sinks the game reads back advance, and not queued
for the device, whose queue is filled to the same target afterwards. While the
device paces, what is owed is the silence it played for want of frames,
counted in its own samples from an underrun until the prefill is queued again;
the wait for the first prefill and anything owed across a stop do not count.
On the timer a frame is owed when its deadline passed a whole frame ago. A gap
of more than 3 seconds is not caught up: the sound goes on from now.

NX2NAVI_AUDIO_CATCHUP=0 turns it off and keeps the old timing. The audio
statistics line counts the catch-up frames and the gaps that were too long,
and tests/audio_mixer_check.py checks the device's side of the accounting.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-12 15:17:00 -05:00
parent 42d16e7f0b
commit 641c866e8a
7 changed files with 206 additions and 26 deletions

View File

@@ -717,6 +717,11 @@
# as the console does (1, the default). 0 applies the new volume at once, which clicks when a volume moves quickly (a
# fade, a sound passing by). Takes effect at the next start.
# audio_ramp = 1
# After the sound was held up (the PC was busy and a gap was heard), skip as much sound as the gap was long, so the
# sound keeps its place against the picture as on the console (1, the default). Gaps of more than 3 seconds are not
# skipped. 0 plays on from where the sound stopped, which leaves it later than the picture by every gap so far.
# Takes effect at the next start.
# audio_catchup = 1
# Volume in percent (0 to 100), on top of the game's own. Changes while the game runs take effect at once.
# volume = 100
# Speakers: stereo, 5.1 or auto (5.1 when the Windows speaker setup has six or more channels, stereo otherwise). The