fix(avplayer): correct audio-video playback timing and sync #5995
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5995"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by squirlyfoxy on 2026-10-14T18:37:45Z.
What
Fix audio-video playback timing and synchronization:
Tested
Windows, Evil Inside (PPSA02508): both cutscenes play with synchronized audio and video, without the premature pause before scene transitions, afterward due to an unrelated or currently unidentified issue.
Tested also My Friend Peppa Pig (PPSA03706) with initial cutscene now playing well.
Full build and complete test suite have not been run. The AudioOut Ex test terminated while handling an expected exception; that verification remains incomplete.
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:12:57Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAudioOut/src/AudioOut.cppL113, L354, L367, L390-391, L554Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAvPlayer/src/Source.cppcore/libs/tests/GuestAvPlayer.cppcore/libs/prx/libSceAudioOut/CMakeLists.txtcore/libs/prx/libSceAudioOut/CMakeLists.txtcore/libs/tests/GuestAvPlayer.cppcore/libs/SceTypes.hppcore/libs/prx/libSceAudioOut/CMakeLists.txtcore/libs/prx/libSceAudioOut/src/AudioOut.cppcore/libs/prx/libSceAudioOut/src/AudioOut.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T19:12:37Z.
Review: COMMENTED
Linux run: head
83e7d26e0merged ontomain44df21632(clean merge). The description says the full build and suite were not run, so here they are.Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, non-GPU tests (Release,
BUILD_TESTING=ON).audio_out*tests andguest_avplayerpass,audio_out_exincluded (the description mentions it terminating on your side).main'sSceTypes.hpp,AudioOut.cppand AvPlayer sources):audio_out_last_output_timeaborts: "Independent port output waited 910 ms", "pacing one audio port must not block output on another port".guest_avplayerfails: "PS5 audio stream must use type 2 so Unity enables it". It stops at the first check, so the frame-rate checks at 0x40/0x48 were not reached without the fix.audio_out_expasses either way.ctest -E "^agc"): no regressions; the only failures arefile_writer_binaryandfile_writer_text, which fail onmainon this machine too.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-15T19:51:04Z.
Independent Linux check of
83e7d26e0c06on main44df21632125: fulllibsbuild and all AudioOut/AvPlayer targets pass. With three added controlled port tests, 21/21 CTests pass, zero skips (Arch Linux, Ryzen 9 7950X; no title/speaker-quality or FPS claim).The test-only commit exercises real public AudioOut calls with an interposed SDL queue and fixed guest clock, holding port A in backpressure until explicitly released. On main, output and close on independent port B fail to complete before A is released; the same-port close control passes. With this PR, all three pass. This supplements the virtual-port tests with controlled device-queue coverage. Removing only the same-port close lock makes the control fail on access to the reset device; restoring it passes. The fixture executable is byte-identical across these latter runs (SHA-256
39381fbb9f6e0218d4d86655e0a45e035437433b56f6ac4310fd869bb2b20917). This is a synchronization check, not a latency benchmark.Separate no-sync contract concern:
takeVideonow gates future frames wheneveraudioDrivingis true, including sync mode 1. The public PS5 SharpProspero reference describes None as caller-paced delivery as frames decode. The addedTestUnsyncedVideoDoesNotRunAheadOfAudioinstead requires audio-clock gating in this mode.I made a separate diagnostic probe: read one audio frame to activate the audio-backed clock, then request decoded video without consuming further audio and measure video lead over
sceAvPlayerCurrentTime. With this PR, lead remains 0 ms and the caller-paced probe fails. Restoring only main'sif (synced && timestamp > now)condition gives 129 ms lead and passes, with the same executable (SHA-2568160cd759cfa6f1b24315a8fcb3b5442d50b7ef45cdfacf9bc26e1590180c362). This identifies the behavior change; the reference is public interop documentation, not a PS5 hardware measurement. The mode-1 contract needs clarification before treating the new gate as generally correct.Full review source including the probe retains your original commit and intentionally exposes that probe failure. For comparison, the isolated AudioOut portion preserves your authorship, adds both test fixtures, and leaves main's AvPlayer behavior intact: full
libsbuild and 22/22 checks pass, zero skips. The temporary close-lock fault and condition-revert probe patch are removed. Conventions, registration and whitespace pass. No downloaded game assets, captures, raw title logs or binaries are published.Imported from boykopovar/AnyPS5. Originally posted by squirlyfoxy on 2026-10-15T21:14:27Z.
The no-sync concern is valid. I’ve restored
if (synced && timestamp > now), replaced TestUnsyncedVideoDoesNotRunAheadOfAudio with your caller-paced probe, and retained the per-port AudioOut locks, including same-port close serialization.The PS5 stream metadata and deferred loop notification fixes remain necessary independently of that gate. Testing My Friend Peppa Pig on Windows showed that reverting them caused skipped or prematurely terminated intros. With those fixes retained, the 73.567-second intro reaches its final frame at 73.533 seconds before closing.
The current local changes pass the full libs build and 18/18 Windows checks, including the no-sync probe. I also added your SDL-interposition fixture, but its three Linux-only cases were not run locally. These results support the synchronization fix and the observed title behavior; they do not establish PS5 hardware semantics or a latency improvement.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T23:01:28Z.
Review: COMMENTED
Linux run of the new head:
c6b9c0498merged ontomain5d9dcc42d(clean merge), in one tree with seven other library PRs that share no files with this one. The description says the three Linux-only SDL-interposition cases inAudioOutPortLocks.cppwere not run locally, so here they are.Machine: Ubuntu 26.04, Intel i7-8700, GCC 15.2, full build, Release,
BUILD_TESTING=ON.audio_out_independent_output,audio_out_independent_closeandaudio_out_same_port_closepass, as doguest_avplayerand the newguest_avplayer_no_sync_lead. All 20audio_out*tests plus both AvPlayer tests pass 5/5 with--repeat until-fail:5.SceTypes.hpp,AudioOut.cppand the AvPlayer sources frommain):audio_out_independent_outputandaudio_out_independent_closeabort with "AudioOut port locks: port output/close lock scope is wrong".audio_out_same_port_closepasses, as expected for the control case.audio_out_last_output_timeaborts: "Independent port output waited 909 ms".guest_avplayerandguest_avplayer_no_sync_leadboth fail at the first check, "PS5 audio stream must use type 2 so Unity enables it". So without the fix,--no-sync-lead-onlydoes not get as far as the lead measurement.ctest -E "^agc|gpu|vulkan|video_out"): no regressions. The only failures arefile_writer_binaryandfile_writer_text, which also fail onmainon this machine.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:44:45Z.
Checked on Linux (merged onto current
main): AudioOut/AvPlayer tests pass, and the new tests fail without the change (audio_out_independent_output,audio_out_independent_close,audio_out_last_output_time,guest_avplayer);audio_out_same_port_closeis the control that passes either way. PS5 audio stream type 2 and the extended frame rate (details offset 48) match KytyPS5 and SharpProspero.Added on rebase:
guest_avplayer_no_sync_leadctest entry:--no-sync-lead-onlyis not read bymain(), so it just re-ran the whole suite. The no-sync lead case already runs insideguest_avplayer.guest_avplayer_callback_close.Note: the PR description no longer matches the diff (it covers sync/loop changes already merged via #5846). #6922 overlaps the per-port locking and will need a rebase after this lands.
Merging once CI is green.