fix(avplayer): skip late video frames in no-sync mode while audio drives the clock #2351

Merged
Faffu merged 1 commit from upstream-pr/2351 into main 2026-10-10 07:50:53 +00:00
Faffu commented 2026-10-09 16:07:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Faffu on 2026-10-09T16:07:26Z.


What

Fixes #1635.

In SCE_AVPLAYER_AV_SYNC_MODE_NONE, takeVideo hands out every decoded frame in order. A title that requests video slower than the film's frame rate (PPSA12544 requests 7-19 frames per second for a 30 fps cinematic) therefore falls further behind its audio on every call.

While the title pulls audio (audioDriving), no-sync mode now skips queued frames of the current epoch that the audio clock has already passed. This reuses the loop that sync mode already runs. Frames that are not late are handed out as before; no-sync mode still never refuses a frame for being early, and nothing changes when no audio is pulled or at a trick speed. Whether the console hands out every frame in this mode is unknown, so the behaviour is recorded under Functional in TechnicalDebt.md.

TestUnsyncedVideoKeepsUpWithAudio reproduces the issue in miniature: no-sync mode, audio pulled in real time, about 15 video requests per second for the 30 fps test movie, and it checks that video stays within 150 ms of the audio.

@awake-devel the issue's open question (whether the title requests several frames per game frame when behind) is not settled by this change. If you can, a run of PPSA12544 on this branch would confirm it on the title.

Tested

Fedora 44 host, build and run inside an Ubuntu 24.04 container (GCC 13, as CI), guest_avplayer_tests only:

worst video lag behind audio test
main 442-475 ms (3 runs) fails
this branch 30 ms (4 parallel runs) passes 5/5

python3 tools/check_conventions.py --base upstream/main passes. Not tested on a title or on Windows.

Side note, not changed here: when a Check fails in guest_avplayer_tests, the process aborts in _Unwind_Resume instead of printing the message from main's catch.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4802909695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351). Originally posted by [Faffu](https://github.com/Faffu) on 2026-10-09T16:07:26Z. --- ### What Fixes #1635. In `SCE_AVPLAYER_AV_SYNC_MODE_NONE`, `takeVideo` hands out every decoded frame in order. A title that requests video slower than the film's frame rate (PPSA12544 requests 7-19 frames per second for a 30 fps cinematic) therefore falls further behind its audio on every call. While the title pulls audio (`audioDriving`), no-sync mode now skips queued frames of the current epoch that the audio clock has already passed. This reuses the loop that sync mode already runs. Frames that are not late are handed out as before; no-sync mode still never refuses a frame for being early, and nothing changes when no audio is pulled or at a trick speed. Whether the console hands out every frame in this mode is unknown, so the behaviour is recorded under Functional in `TechnicalDebt.md`. `TestUnsyncedVideoKeepsUpWithAudio` reproduces the issue in miniature: no-sync mode, audio pulled in real time, about 15 video requests per second for the 30 fps test movie, and it checks that video stays within 150 ms of the audio. @awake-devel the issue's open question (whether the title requests several frames per game frame when behind) is not settled by this change. If you can, a run of PPSA12544 on this branch would confirm it on the title. ### Tested Fedora 44 host, build and run inside an Ubuntu 24.04 container (GCC 13, as CI), `guest_avplayer_tests` only: | | worst video lag behind audio | test | |---|---|---| | `main` | 442-475 ms (3 runs) | fails | | this branch | 30 ms (4 parallel runs) | passes 5/5 | `python3 tools/check_conventions.py --base upstream/main` passes. Not tested on a title or on Windows. Side note, not changed here: when a `Check` fails in `guest_avplayer_tests`, the process aborts in `_Unwind_Resume` instead of printing the message from `main`'s catch. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kikoarl commented 2026-10-09 17:44:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:44:21Z.


Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Release, -DBUILD_TESTING=ON, #2351 (2be693d4) tested on current main (0fdda7be).

  • tests/guest_avplayer_tests: passes cleanly (AvPlayer tests passed).
  • tools/check_conventions.py: passes cleanly.
  • Verified frame skipping logic in no-sync mode under Linux audio clock timing.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086156849 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351#issuecomment-6086156849). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-09T17:44:21Z. --- Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Release, `-DBUILD_TESTING=ON`, #2351 (`2be693d4`) tested on current `main` (`0fdda7be`). - `tests/guest_avplayer_tests`: passes cleanly (`AvPlayer tests passed`). - `tools/check_conventions.py`: passes cleanly. - Verified frame skipping logic in no-sync mode under Linux audio clock timing.
popcoder565 commented 2026-10-09 19:04:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:04:15Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 2be693d4, merged onto main f8c2f072 in one build with 9 other PRs that had no Windows run.

  • This PR's tests pass: guest_avplayer.
  • Full ctest in that build: 512 of 513. The one failure is agc_driver_depth_fast_clear_submit from #2325, which fails intermittently on its own too. The test comes from #425, where I reported it.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087426431 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351#issuecomment-6087426431). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:04:15Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `2be693d4`, merged onto `main` f8c2f072 in one build with 9 other PRs that had no Windows run. - This PR's tests pass: `guest_avplayer`. - Full ctest in that build: 512 of 513. The one failure is `agc_driver_depth_fast_clear_submit` from #2325, which fails intermittently on its own too. The test comes from #425, where I reported it. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
AnzouBelilita commented 2026-10-09 19:09:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AnzouBelilita on 2026-10-09T19:09:21Z.


Independent native-Windows validation for PR #2351:

  • OS: Windows 10 Pro, build 19045
  • Toolchain: MinGW-w64 GCC 16.2.0, CMake 4.4.4, Ninja 1.13.2
  • Performed a clean rebuild of guest_avplayer_tests (98 build steps); build completed successfully.
  • CTest: guest_avplayer passed 3 consecutive runs after the clean rebuild (3.10 s, 3.95 s, 4.01 s).
  • python tools/check_conventions.py --base d70b89989473ba1f6ae13e44e079e67f1f8a44b0 passed.
  • git diff --check --ignore-submodules=all d70b89989473ba1f6ae13e44e079e67f1f8a44b0...HEAD passed.
  • Tested PR head: 2be693d426f03ac11d176d89d807a2d318bce59f.

An earlier repeat sequence on the pre-clean build had one failure in TestPlayback (enable video failed); the subsequent run passed. After the clean rebuild, all three consecutive runs passed.

This adds native-Windows coverage for the no-sync AVPlayer frame-skipping regression. No commercial title or PS5 hardware was tested.

No production source files were modified during validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087505364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351#issuecomment-6087505364). Originally posted by [AnzouBelilita](https://github.com/AnzouBelilita) on 2026-10-09T19:09:21Z. --- Independent native-Windows validation for PR #2351: * OS: Windows 10 Pro, build 19045 * Toolchain: MinGW-w64 GCC 16.2.0, CMake 4.4.4, Ninja 1.13.2 * Performed a clean rebuild of `guest_avplayer_tests` (98 build steps); build completed successfully. * CTest: `guest_avplayer` passed 3 consecutive runs after the clean rebuild (3.10 s, 3.95 s, 4.01 s). * `python tools/check_conventions.py --base d70b89989473ba1f6ae13e44e079e67f1f8a44b0` passed. * `git diff --check --ignore-submodules=all d70b89989473ba1f6ae13e44e079e67f1f8a44b0...HEAD` passed. * Tested PR head: `2be693d426f03ac11d176d89d807a2d318bce59f`. An earlier repeat sequence on the pre-clean build had one failure in `TestPlayback` (`enable video failed`); the subsequent run passed. After the clean rebuild, all three consecutive runs passed. This adds native-Windows coverage for the no-sync AVPlayer frame-skipping regression. No commercial title or PS5 hardware was tested. No production source files were modified during validation.
oneandonlydean commented 2026-10-09 22:43:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T22:43:18Z.


This conflicts with main after today's merges; could you rebase? It's otherwise ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090510164 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351#issuecomment-6090510164). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T22:43:18Z. --- This conflicts with main after today's merges; could you rebase? It's otherwise ready.
adriadam10 commented 2026-10-10 07:43:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:43:57Z.


Rebased onto current main as @oneandonlydean asked. The conflicts were mechanical (the new test and the TechnicalDebt line next to the ones added today); both sides kept, no logic changed. Scoped build + ctest on the rebased tree is green, including guest_avplayer. Merging on green CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095241178 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351#issuecomment-6095241178). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:43:57Z. --- Rebased onto current `main` as @oneandonlydean asked. The conflicts were mechanical (the new test and the TechnicalDebt line next to the ones added today); both sides kept, no logic changed. Scoped build + ctest on the rebased tree is green, including `guest_avplayer`. Merging on green CI.
Faffu commented 2026-10-10 07:44:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Faffu on 2026-10-10T07:44:48Z.


Rebased onto current main as @oneandonlydean asked. The conflicts were mechanical (the new test and the TechnicalDebt line next to the ones added today); both sides kept, no logic changed. Scoped build + ctest on the rebased tree is green, including guest_avplayer. Merging on green CI.

Thank you for rebasing it!

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095248533 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2351#issuecomment-6095248533). Originally posted by [Faffu](https://github.com/Faffu) on 2026-10-10T07:44:48Z. --- > Rebased onto current `main` as @oneandonlydean asked. The conflicts were mechanical (the new test and the TechnicalDebt line next to the ones added today); both sides kept, no logic changed. Scoped build + ctest on the rebased tree is green, including `guest_avplayer`. Merging on green CI. > Thank you for rebasing it!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2351
No description provided.