Skip to content

Fix FMV audio crackling with Audio Buffering enabled - #19173

Open
digant73 wants to merge 3 commits into
RPCS3:masterfrom
digant73:fix_fmv_audio_crackling
Open

Fix FMV audio crackling with Audio Buffering enabled#19173
digant73 wants to merge 3 commits into
RPCS3:masterfrom
digant73:fix_fmv_audio_crackling

Conversation

@digant73

@digant73 digant73 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

AI Disclosure:

  • Primary target of the PR is to identify the regressing code (reporting the PR and and possibly the regressing commit when possible) so it can help main developers to provide a correct fix in case the one provided by AI is not fully applicable.
  • Comments on the code provided by AI are not initially removed just to provide main developers a description of the changes. Comments will be removed/changed as per indication from main developers during the review
  • Analysis made by Opus 5
  • Tested on Street Fighter x Tekken Laggy/Broken sound at menu and character select #17952

#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

  • Persisting crackling at the start of a movie up to the end
  • Present only with setting Enable Buffering set to on
  • Intermittent — some movie starts are clean. Reproduced on Street Fighter X Tekken.

The 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.

@digant73
digant73 marked this pull request as draft August 9, 2026 14:37
@AniLeo

AniLeo commented Aug 9, 2026

Copy link
Copy Markdown
Member

Can you provide before/after video with sound so we can compare the sound result?

@digant73

digant73 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Can you provide before/after video with sound so we can compare the sound result?

Bug on master: audio and video not smooth (it takes more time)

https://mega.nz/file/e2RRSZpJ#ZugKOz7qHDUKaOuYm7ddWfNrzSb8i-3NLIliHIJzFz4

Fix: audio and video smooth

https://mega.nz/file/e2BRUYCD#EpPWww15urNPAdBHtNa4cTN-rrl6m3VzHdQ8Z9k-_ko

@digant73

Copy link
Copy Markdown
Contributor Author

this is ready for review

@digant73
digant73 marked this pull request as ready for review August 24, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants