Fix FMV audio crackling with Audio Buffering enabled - #19173
Open
digant73 wants to merge 3 commits into
Open
Conversation
digant73
marked this pull request as draft
August 9, 2026 14:37
Member
|
Can you provide before/after video with sound so we can compare the sound result? |
Contributor
Author
Bug on master: audio and video not smooth (it takes more time)https://mega.nz/file/e2RRSZpJ#ZugKOz7qHDUKaOuYm7ddWfNrzSb8i-3NLIliHIJzFz4 Fix: audio and video smoothhttps://mega.nz/file/e2BRUYCD#EpPWww15urNPAdBHtNa4cTN-rrl6m3VzHdQ8Z9k-_ko |
Contributor
Author
|
this is ready for review |
digant73
marked this pull request as ready for review
August 24, 2026 12:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI Disclosure:
#17952 not declared as fixed due to OP also reported crackling on menu that was still present even disabling
Audio Buffering(I didn't have any crackling on menu)AI Summary
Symptom
Enable Bufferingset toonThe video is just the most reliable trigger, because the decoder spin-up produces a prolonged and repeatable irregularity. So, the issue is general, e.g. it can happen in-game (see Root Cause section).
Root cause
untouched_expected in cell_audio_thread::operator() has no hysteresis.
These games open a second audio port when a movie starts (SFxT: port 1 exists only for the duration of the FMV). While its decoder spins up, the game feeds that port irregularly, so the number of untouched ports oscillates between 1 and 2.
Every time untouched rises above untouched_expected, the thread enters the wait branch and stalls 1 ms at a time up to partially_untouched_timeout — 21.3 ms, four audio periods. Then the game feeds the port for one period, untouched drops, and the normal path lowers untouched_expected again straight away, so the next period re-arms the wait.
The stall is self-reinforcing: it drains the ring buffer, the control loop reacts by shortening the audio period, the thread then polls the port faster than the game fills it, which produces more untouched verdicts and more stalls.
Measured over the 11 seconds following the movie port opening: 1898 waits across ~2000 periods, i.e. 1.9 s of stalled audio thread, buffer drained from 102 ms to 56 ms, dynamic period pushed from 5230 µs down to 3617 µs, and 133 periods mixed with the movie port contributing silence. Those silent blocks are the audible crackle.
Fix
Give the expectation hysteresis — it rises immediately, falls only after a hold.