Skip to content

Preserve live audio through run-ahead and long guest frames - #216

Merged
mstan merged 2 commits into
mainfrom
fix/speculative-audio-output
Oct 26, 2026
Merged

mstan merged 2 commits into
mainfrom
fix/speculative-audio-output

Conversation

@mstan

@mstan mstan commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Run-ahead rollback was resetting the live resampler and restoring the PCM ring with disjoint lock scopes. Speculative DSP work could also publish future PCM. Preserve live delivery atomically during rollback, keep speculative suppression active through undo, and synthesize speculative cycles without publishing PCM.

Long guest intervals such as Super Metroid's pause restoration could produce a FIFO-sized audio burst and then starve the callback during the host wait. Use the same bounded APU catch-up helper at CPU-port and final-frame synchronization, reusing existing producer backpressure between slices. Preserve total guest cycles, the existing1<<20-cycle cap and portable fallback; do not enlarge the FIFO or shorten the game's original restoration timing.

Validation at afe5656:

  • Matched production SM3,900-frame run-ahead1/audio improves120.998s→68.445s, versus68.364s with run-ahead off; exact guest traces. Final normal production run-ahead4 build completes68.649s with steady89.76 presentationHz and matching trace.
  • Eight actual Start-close cases (Brinstar/Norfair × stock/wide ×60/90): zero added dropped PCM, underruns or missing frames; exact native menu/guest traces. Original ROM's42–44-field restoration remains.
  • Portable DSP synthesis/output-suppression, snapshot/producer, audio-delivery and transaction fixtures pass on Windows/Linux; six snapshot/producer tests include long-frame output, bounded stalled-consumer waits and unchanged catch-up cap.
  • Frozen MMX452ac31/UI7c635c6 and SMWff08639/UI01bff94 supported builds/regens pass. Both pass unpaused same/fresh-process state continuation and movement.
  • MMX23 executed CTests pass (2 optional Saber fixtures skipped). SMW standalone adaptive-renderer suite passes; it registers no CTests.
  • Matched balanced-order built runtime: MMX CPU ratio0.9969, SMW1.0434; exact gameplay pixels and guest traces. Preserve known baseline reset failure and noisy initial timing pair separately.

Owner gameplay/audio handoff remains before merge. Actual Steam Deck ordinary-gameplay crackling is not certified by these Windows checks.

Owner accepted the combined cb85d33 visual/gameplay handoff on 2026-10-26 and explicitly requested merge. Combined regression: MMX 23 executed CTests pass (2 optional Saber fixtures skipped), MMX and SMW normal movement plus same/fresh-process current-build save/load pass; Windows Super Metroid 16/16 tests and real Options Exit 0 with config/SRAM persistence pass. Existing matched runtime evidence remains valid. Steam Deck hardware is unavailable and has no hardware-audio pass.

@mstan mstan changed the title Preserve live audio delivery across speculative rollback Preserve live audio through run-ahead and long guest frames Oct 26, 2026
@mstan
mstan marked this pull request as ready for review October 26, 2026 16:41
@mstan
mstan merged commit 13292fc into main Oct 26, 2026
8 checks passed
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.

2 participants