Skip to content

Preserve audio continuity and expose a next-session buffer target - #781

Open
michaelm-afk wants to merge 2 commits into
RetroPortingToolKit:masterfrom
michaelm-afk:pr/audio-continuity-buffer-70
Open

michaelm-afk wants to merge 2 commits into
RetroPortingToolKit:masterfrom
michaelm-afk:pr/audio-continuity-buffer-70

Conversation

@michaelm-afk

@michaelm-afk michaelm-afk commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Audio Sync could resume playable PCM through a second producer fade, or stay unprimed merely because its queue was below target. After actual depletion it could resume on a tiny block instead of rebuilding the target reserve. These discontinuities caused audible clicks in the tested Tomba EU1 route.

This follows merged #769 without rewriting it:

  • Preserve playable queued PCM and its read cursor on sink resume; re-prime only after actual depletion.
  • Join newly resumed source PCM over 3 ms and avoid a second producer fade at the retained-PCM seam.
  • Count depletion episodes once and rebuild the existing target after starvation. Normal steady playback, guest clocks, SPU/HQ mixing and presentation pacing are unchanged.
  • Extend the existing Audio Sync API with a validated 20–180 ms / 5 ms next-session target. Enabled default is 70 ms; disabled keeps the configured fallback. Titles read committed mod options before device creation; no live retargeting or adaptive buffer policy is introduced.
  • Optional producer-thread diagnostics report configured/active target, fill, depletion/overflow and host device lifecycle counters at most once per second. No callback file I/O or title-specific logging paths.

The activation plugin, saved mod options and default-on choice belong to the title, not the engine. Consumer: mstan/TombaRecomp#55. Paired UI: RetroPortingToolKit/recomp-ui#122; it uses the existing ModProvider storage. This API/continuity correction can be reviewed independently of the UI.

Validation

On current master ffbd9d1, native Windows Clang Release:

  • Full psx-runtime build with the paired current-master recomp-ui succeeds (OpenGL; netplay, rewind, setup wizard and debug tools disabled; Vulkan SDK absent/stub).
  • audio_sync_target_test, audio_catchup_test, audio_sink_resume_test, mod_packages_test, builtin_mod_manifests_test and host_enhancements_test pass. The package test's sandbox file-replacement denial was rerun successfully outside the sandbox in an isolated temporary directory.
  • Title activation/catalog tests and real-package persistence check pass: fresh70, saved80 retained, upper180 accepted, reset70 retained, next-session activation and OFF fallback.
  • Earlier continuity tests found ordinary stereo playback bit-identical at 44.1/48 kHz. The owner confirmed the continuity implementation removed clicks and personally found 70 ms stable in tested EU1 sections. This is not a full-campaign or all-platform certification.

Limits

70 ms is a tested recommendation on one system, not a universal minimum. Lower targets can stutter/drop out; 20 ms was unstable in the owner's tests. Host queue fill is not measured end-to-end latency: Windows/HDMI/eARC/speaker delay remains unmeasured. Long producer/display stalls can still cause recovery silence. No further audio optimization is proposed.

Source only, developed with AI assistance. No game data, credentials, private policies, unrelated mods or binaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant