fix(libSceAvPlayer): keep the no-sync clock from following audio pulled early #11772

Merged
nekomancer01 merged 2 commits from upstream-pr/11772 into main 2026-11-04 19:18:13 +00:00
nekomancer01 commented 2026-10-27 07:34:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nekomancer01 on 2026-10-27T07:34:52Z.


What

In SCE_AVPLAYER_AV_SYNC_MODE_NONE, takeAudio rebased the presentation clock to every audio chunk the title pulled more than 50 ms ahead of it, so the clock followed audio pulled, not audio played. The late-frame skip from #2351 then skips every queued frame older than that clock.

Castlevania: Belmont's Curse (PPSA35399) plays a 3-minute 1920x1080 30 fps film after New Game in this mode, and pulls its audio two to four times faster than it plays it. The clock ran seconds ahead and the skip handed out frames past the one the title wanted. The title's video code (Unity) asks for frames until it gets the one whose index equals its own playback index: an earlier frame is dropped, a later one is kept until the playback index reaches it, and only an exact match is uploaded. A frame skipped to from a clock that is too far ahead is passed by the playback index before it can match, so on main every frame is dropped and the film stays black, with sound.

  • In no-sync mode, audio pulled ahead of the clock no longer moves it forward. Audio that falls more than 50 ms behind still pulls the clock back, so a title that pulls audio slower than real time (the #2351 case) keeps the picture with the sound as before. Default sync mode is unchanged.
  • In no-sync mode the player requests 12 decode-ahead video frames instead of 4, and falls back to 4 when 12 do not fit the memory replacement. The title drains every ready frame once per rendered frame; at about 4.5 fps here, 6 ready frames per poll is under the 30 fps film, so the picture still fell behind and every frame was dropped. With 12 it keeps up. Default sync mode requests 4 as before. Each request is still all or none and optional; TestOptionalVideoBuffersRespectMemoryLimit covers both modes, including the fallback.
  • TestNoSyncClockIgnoresEarlyAudio in guest_avplayer: no-sync mode, pulls the first 600 ms of audio as fast as it comes, then checks that sceAvPlayerCurrentTime has not run ahead of wall time. On main the clock is 578 ms ahead after 29 ms and the test fails; with the change it passes.
  • Both debt entries are updated. How the console's clock treats audio pulled early in this mode, and how many frames it decodes ahead, are not measured.

Each part alone is not enough on PPSA35399: the clock change with 4 decode-ahead frames stayed black in 5 of 5 runs, and 24 decode-ahead frames without the clock change stayed black.

Not fixed by this PR: when the title stalls for more than about 2 s right after the film starts (asset loading, here), its video player falls behind by more than 5 frames and resyncs with seeks that each take about three rendered frames (0.65 s at 4.5 fps), which never land inside its 5-frame tolerance. The picture then stays on the last uploaded frame. That depends on the title's frame rate, not on AvPlayer. It is the likely cause of the 2 black runs below; I saw the loop with logging in earlier runs but did not confirm it in those two.

Tested

Linux (Ubuntu 26.04 distrobox on CachyOS), GCC 15.2.0, Release, RTX 3070 (NVIDIA 615.78.08):

  • guest_avplayer, guest_avplayer_callback_close, guest_avplayer_paused_first_video and public_headers pass. guest_avplayer fails on main with the new test (3 of 3 runs) and passes with the change (5 of 5 repeats).
  • PPSA35399 01.000.000, New Game film, window captured 20, 45 and 60 s into it: on main the film is black with its Skip prompt in 3 of 3 runs; with the change it shows and advances in 12 of 14 runs and stays black in 2. The title continues into gameplay after the film as before.
  • PPSA12544 (Hollow Knight: Silksong), intro cinematic: it now renders at about 120 fps here, and video, audio and clock stay within 50 ms of wall time on both main and this change (at 72.95 s: video 72.93 s, audio 72.90 s, 30 frames handed out per second on both).

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 under Silent stubs in their library's technical debt file
  • 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 (overlaps #1601, which adds held buffers after the decode-ahead ones and edits the same buffer-count test, and a neighbouring debt line with #11716)
  • Fixes: none
  • Unblocks: PPSA35399 #5832
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5030280501 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11772). Originally posted by [nekomancer01](https://github.com/nekomancer01) on 2026-10-27T07:34:52Z. --- ### What In `SCE_AVPLAYER_AV_SYNC_MODE_NONE`, `takeAudio` rebased the presentation clock to every audio chunk the title pulled more than 50 ms ahead of it, so the clock followed audio *pulled*, not audio *played*. The late-frame skip from #2351 then skips every queued frame older than that clock. Castlevania: Belmont's Curse (PPSA35399) plays a 3-minute 1920x1080 30 fps film after New Game in this mode, and pulls its audio two to four times faster than it plays it. The clock ran seconds ahead and the skip handed out frames past the one the title wanted. The title's video code (Unity) asks for frames until it gets the one whose index equals its own playback index: an earlier frame is dropped, a later one is kept until the playback index reaches it, and only an exact match is uploaded. A frame skipped to from a clock that is too far ahead is passed by the playback index before it can match, so on `main` every frame is dropped and the film stays black, with sound. - In no-sync mode, audio pulled ahead of the clock no longer moves it forward. Audio that falls more than 50 ms behind still pulls the clock back, so a title that pulls audio slower than real time (the #2351 case) keeps the picture with the sound as before. Default sync mode is unchanged. - In no-sync mode the player requests 12 decode-ahead video frames instead of 4, and falls back to 4 when 12 do not fit the memory replacement. The title drains every ready frame once per rendered frame; at about 4.5 fps here, 6 ready frames per poll is under the 30 fps film, so the picture still fell behind and every frame was dropped. With 12 it keeps up. Default sync mode requests 4 as before. Each request is still all or none and optional; `TestOptionalVideoBuffersRespectMemoryLimit` covers both modes, including the fallback. - `TestNoSyncClockIgnoresEarlyAudio` in `guest_avplayer`: no-sync mode, pulls the first 600 ms of audio as fast as it comes, then checks that `sceAvPlayerCurrentTime` has not run ahead of wall time. On `main` the clock is 578 ms ahead after 29 ms and the test fails; with the change it passes. - Both debt entries are updated. How the console's clock treats audio pulled early in this mode, and how many frames it decodes ahead, are not measured. Each part alone is not enough on PPSA35399: the clock change with 4 decode-ahead frames stayed black in 5 of 5 runs, and 24 decode-ahead frames without the clock change stayed black. Not fixed by this PR: when the title stalls for more than about 2 s right after the film starts (asset loading, here), its video player falls behind by more than 5 frames and resyncs with seeks that each take about three rendered frames (0.65 s at 4.5 fps), which never land inside its 5-frame tolerance. The picture then stays on the last uploaded frame. That depends on the title's frame rate, not on AvPlayer. It is the likely cause of the 2 black runs below; I saw the loop with logging in earlier runs but did not confirm it in those two. ### Tested Linux (Ubuntu 26.04 distrobox on CachyOS), GCC 15.2.0, Release, RTX 3070 (NVIDIA 615.78.08): - `guest_avplayer`, `guest_avplayer_callback_close`, `guest_avplayer_paused_first_video` and `public_headers` pass. `guest_avplayer` fails on `main` with the new test (3 of 3 runs) and passes with the change (5 of 5 repeats). - PPSA35399 01.000.000, New Game film, window captured 20, 45 and 60 s into it: on `main` the film is black with its Skip prompt in 3 of 3 runs; with the change it shows and advances in 12 of 14 runs and stays black in 2. The title continues into gameplay after the film as before. - PPSA12544 (Hollow Knight: Silksong), intro cinematic: it now renders at about 120 fps here, and video, audio and clock stay within 50 ms of wall time on both `main` and this change (at 72.95 s: video 72.93 s, audio 72.90 s, 30 frames handed out per second on both). ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 (overlaps #1601, which adds held buffers after the decode-ahead ones and edits the same buffer-count test, and a neighbouring debt line with #11716) - [x] Fixes: none - [x] Unblocks: PPSA35399 #5832 - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ahmadmuj commented 2026-11-01 17:23:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-01T17:23:58Z.

Review: COMMENTED


Reviewed head 6b01c577dd06 merged locally onto main f2d874c1fdcc (PR base 20cfe359a8b6). Linux, WSL2 Ubuntu 24.04, GCC 13.3, Release, lavapipe.

What I ran:

  • ctest -R '^guest_avplayer' on the merge: 3/3 pass, three times. guest_avplayer alone: 5/5.
  • Red check: main's Source.cpp with only TestNoSyncClockIgnoresEarlyAudio added fails 3/3: no-sync clock followed audio pulled early: 578 ms after 30 ms (also 580/34 and 578/31). With the PR, clock minus first equals wall time (31-33 ms), so the 100 ms margin isn't even used.
  • Buffer test on main: only run(14, 14, true) fails (6 textures, not 14). The other six cases already pass on main, so that one case is the real negative control.
  • tools/check_conventions.py --base origin/main: pass.

Read on the merged tree: takeAudio, takeVideo, addVideoBuffers. Default mode is unchanged (drifted reduces to the old expression, still 4 buffers). SetAvSyncMode only accepts 0 and 1, so syncMode != SyncModeDefault is exactly NONE. The fallback frees a partial 12 before it tries 4, and buffers are only added in Start.

One gap, not a regression: at the end of audio, audio pulled early still moves the clock forward in no-sync mode. The exhausted term in takeAudio and reconcileExhaustedAudioClock rebase to the last pulled timestamp with no direction check.

Example, a probe on the test movie with this PR: no-sync, pull audio as fast as it comes. All 47 chunks are out after ~7 ms, and sceAvPlayerCurrentTime reads 1000 at 208 ms wall time (first chunk at 0). The next sceAvPlayerGetVideoData returns the frame at 500 ms. Main gives the same clock, so this PR doesn't cause it. But if PPSA35399 keeps pulling audio 2-4x fast through the whole film, audio runs out well before video, and the picture would jump to the end there. If you want to cover it: in no-sync mode, take the exhausted rebase only when the last timestamp is behind the clock, the same rule as drifted.

Small things:

  • The new debt line says audio pulled ahead "does not move it forward in this mode". The end-of-audio rebase above still does, and so does the epoch > clockEpoch rebase on a loop or seek.
  • TestNoSyncClockIgnoresEarlyAudio doesn't check allocations.blocks.empty() after close, like TestNoSyncVideoCanLeadAudioClock does.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729333079 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11772#pullrequestreview-5729333079). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-11-01T17:23:58Z. **Review:** COMMENTED --- Reviewed head `6b01c577dd06` merged locally onto `main` `f2d874c1fdcc` (PR base `20cfe359a8b6`). Linux, WSL2 Ubuntu 24.04, GCC 13.3, Release, lavapipe. What I ran: - `ctest -R '^guest_avplayer'` on the merge: 3/3 pass, three times. `guest_avplayer` alone: 5/5. - Red check: `main`'s `Source.cpp` with only `TestNoSyncClockIgnoresEarlyAudio` added fails 3/3: `no-sync clock followed audio pulled early: 578 ms after 30 ms` (also 580/34 and 578/31). With the PR, clock minus first equals wall time (31-33 ms), so the 100 ms margin isn't even used. - Buffer test on `main`: only `run(14, 14, true)` fails (6 textures, not 14). The other six cases already pass on main, so that one case is the real negative control. - `tools/check_conventions.py --base origin/main`: pass. Read on the merged tree: `takeAudio`, `takeVideo`, `addVideoBuffers`. Default mode is unchanged (`drifted` reduces to the old expression, still 4 buffers). `SetAvSyncMode` only accepts 0 and 1, so `syncMode != SyncModeDefault` is exactly NONE. The fallback frees a partial 12 before it tries 4, and buffers are only added in `Start`. One gap, not a regression: at the end of audio, audio pulled early still moves the clock forward in no-sync mode. The `exhausted` term in `takeAudio` and `reconcileExhaustedAudioClock` rebase to the last pulled timestamp with no direction check. Example, a probe on the test movie with this PR: no-sync, pull audio as fast as it comes. All 47 chunks are out after ~7 ms, and `sceAvPlayerCurrentTime` reads 1000 at 208 ms wall time (first chunk at 0). The next `sceAvPlayerGetVideoData` returns the frame at 500 ms. Main gives the same clock, so this PR doesn't cause it. But if PPSA35399 keeps pulling audio 2-4x fast through the whole film, audio runs out well before video, and the picture would jump to the end there. If you want to cover it: in no-sync mode, take the exhausted rebase only when the last timestamp is behind the clock, the same rule as `drifted`. Small things: - The new debt line says audio pulled ahead "does not move it forward in this mode". The end-of-audio rebase above still does, and so does the `epoch > clockEpoch` rebase on a loop or seek. - `TestNoSyncClockIgnoresEarlyAudio` doesn't check `allocations.blocks.empty()` after close, like `TestNoSyncVideoCanLeadAudioClock` does.
BunnyFl commented 2026-11-02 22:21:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T22:21:55Z.

Review: APPROVED


Reads right. ahmadmuj reviewed this exact head (6b01c577dd), and that red check stands. In core/libs/prx/libSceAvPlayer/src/Source.cpp, the no-sync clock now rebases only when audio falls behind it, not when the title pulls audio ahead, and the larger no-sync decode-ahead is all-or-nothing: addVideoBuffers frees every buffer it took before returning false, so the fallback to VideoDecodeAheadFrames starts clean. That matches the new run(13, 6, true) and run(14, 14, true) rows.

Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto current main: guest_avplayer, guest_avplayer_callback_close, guest_avplayer_paused_first_video and guest_avplayer_http pass, nothing skipped. With main's Source.cpp, guest_avplayer fails at unexpected optional video buffer count (the new buffer rows), which stops the test before TestNoSyncClockIgnoresEarlyAudio; ahmadmuj's run covers that one failing on main.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5744244459 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11772#pullrequestreview-5744244459). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T22:21:55Z. **Review:** APPROVED --- Reads right. ahmadmuj reviewed this exact head (`6b01c577dd`), and that red check stands. In `core/libs/prx/libSceAvPlayer/src/Source.cpp`, the no-sync clock now rebases only when audio falls behind it, not when the title pulls audio ahead, and the larger no-sync decode-ahead is all-or-nothing: `addVideoBuffers` frees every buffer it took before returning `false`, so the fallback to `VideoDecodeAheadFrames` starts clean. That matches the new `run(13, 6, true)` and `run(14, 14, true)` rows. Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto current `main`: `guest_avplayer`, `guest_avplayer_callback_close`, `guest_avplayer_paused_first_video` and `guest_avplayer_http` pass, nothing skipped. With `main`'s `Source.cpp`, `guest_avplayer` fails at `unexpected optional video buffer count` (the new buffer rows), which stops the test before `TestNoSyncClockIgnoresEarlyAudio`; ahmadmuj's run covers that one failing on `main`.
XairRrR commented 2026-11-02 22:57:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T22:57:58Z.

Review: APPROVED


Reviewed — approved

The no-sync clock now only rebases backward, and the 12-then-4 decode-ahead request applies only in SCE_AVPLAYER_AV_SYNC_MODE_NONE. The AvPlayer tests pass, and each new test part fails when I revert its production change.

What I ran

Head 6b01c577dd06399fcdc34291363a1d56b108ee9c merged into main 5cb015caaaaf83f8ee431414ee6a457b5b307d49 (merged tree 1c2f0a4b41b10ab6fa71e470631785b58acb90f0). The machine was Debian 13 (VM, Xeon Gold 6136), GCC 14.2.0, Release, Ninja, with lavapipe and no GPU.

git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...6b01c577dd06399fcdc34291363a1d56b108ee9c
python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(guest_avplayer|avplayer_http)"
# negative control 1: main's Source.cpp
git show 5cb015caaaaf83f8ee431414ee6a457b5b307d49:core/libs/prx/libSceAvPlayer/src/Source.cpp > core/libs/prx/libSceAvPlayer/src/Source.cpp
ninja -C build -j32 -l32 libs tests/guest_avplayer_tests
ctest --test-dir build --output-on-failure -R "^guest_avplayer$"
# negative control 2: merged Source.cpp with only the `drifted` line reverted to main's expression
ninja -C build -j32 -l32 libs tests/guest_avplayer_tests
ctest --test-dir build --output-on-failure -R "^guest_avplayer$"   # 3 times
# restore
git show 1c2f0a4b41b10ab6fa71e470631785b58acb90f0:core/libs/prx/libSceAvPlayer/src/Source.cpp > core/libs/prx/libSceAvPlayer/src/Source.cpp
ninja -C build -j32 -l32 libs tests/guest_avplayer_tests
ctest --test-dir build --output-on-failure -R "^guest_avplayer$"   # 3 times
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build (merged tree) ok
guest_avplayer, guest_avplayer_callback_close, guest_avplayer_paused_first_video, guest_avplayer_http, avplayer_http_transport, avplayer_http_patched_modules 6/6 pass; guest_avplayer 4.5–4.8 s (3 more runs after the restore, all pass)
Script test run (842 tests) 839 pass, 1 expected skip, 2 failures not caused by this PR (see below)
Worktree after negative control git status --porcelain empty

The script reported two failures that are not on its baseline list: agc_driver_image_sample_lod_clamp_shader_lane and unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group. Neither comes from this PR:

  • The AGC test executable has no AvPlayer input (ninja -t query finds no AvPlayer dependency).
  • The baseline was measured on an older main (096c45570f). Between the baseline and the main used here, main changed the AGC sampler code, the agc_driver_image_sample_lod_clamp_tests fragment, tools/unwrap_self.py and tools/tests/test_unwrap_self.py.
  • The unwrap test fails at os.chown(directory, -1, group) with EINVAL, which is a limit of this sandbox.

The script also lists unwrap_self as fixed, which has nothing to do with this PR either.

Negative control

  • main's Source.cpp: guest_avplayer fails with unexpected optional video buffer count. This is the new buffer-count rows, and it matches BunnyFl's result. The failure stops the test before the clock test runs.
  • Merged Source.cpp with only the drifted condition reverted (Source.cpp:637 back to timestamp > currentClock + 50.0 without the !unsynced guard): guest_avplayer fails 3/3 with no-sync clock followed audio pulled early: 578 ms after 29 ms, then 578/29 and 578/30. This isolates TestNoSyncClockIgnoresEarlyAudio, and it confirms ahmadmuj's red check on a different machine and compiler.
  • Restored the merged file and rebuilt: the test passes 3/3, and the worktree is back to the merged tree.

Findings

Blocking

None.

Non-blocking

  • The debt line overstates the new rule (docs/dev/debt/libSceAvPlayer.md:28). ahmadmuj already raised this; I confirm it by reading the code. The entry says audio pulled ahead "does not move it forward in this mode", but two paths still rebase forward to the last pulled timestamp in no-sync mode:

    • the exhausted term at core/libs/prx/libSceAvPlayer/src/Source.cpp:638-643;
    • reconcileExhaustedAudioClock at core/libs/prx/libSceAvPlayer/src/Source.cpp:579-583.

    The epoch > clockEpoch rebase at line 639 does the same. A title that pulls audio 2–4× fast for the whole film runs out of audio early, and at that point the clock still jumps to the end of the audio. main behaves the same way, so this is not a regression.

    Suggested fix: limit the end-of-audio rebase to a timestamp behind the clock, like the drifted rule, or name these exceptions in the debt line.

  • The new test does not check that its allocations were freed (core/libs/tests/GuestAvPlayer.cpp:1610-1628). TestNoSyncClockIgnoresEarlyAudio does not check allocations.blocks.empty() after sceAvPlayerClose, unlike TestNoSyncVideoCanLeadAudioClock. ahmadmuj noted this too. Adding the check costs one line.

Other things I checked and found correct:

  • addVideoDecodeAheadBuffers (Source.cpp:743-747) runs only from Start (Source.cpp:359). It reads the atomic syncMode there, which Player.cpp:218 forwards before playback starts, so "as playback starts" in the debt entry is accurate.
  • addVideoBuffers frees a partial request before it returns false, so the fallback to 4 starts clean.
  • SetAvSyncMode accepts only 0 and 1, so syncMode != SyncModeDefault means exactly no-sync mode.
  • In default mode the drifted expression reduces to main's expression.

Not verified

  • PPSA35399 and PPSA12544 behaviour. I launched no titles.
  • Windows and non-lavapipe hosts. Other reviewers posted Windows runs.
  • Whether the console's clock follows audio pulled early, or how many frames it decodes ahead. The debt entries already record both as unknown.
  • I did not rerun the two unrelated failing tests in isolation on main. I attribute them to main because their inputs differ from the baseline and do not include any file this PR touches.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5744625768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11772#pullrequestreview-5744625768). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-02T22:57:58Z. **Review:** APPROVED --- # Reviewed — approved The no-sync clock now only rebases backward, and the 12-then-4 decode-ahead request applies only in `SCE_AVPLAYER_AV_SYNC_MODE_NONE`. The AvPlayer tests pass, and each new test part fails when I revert its production change. ## What I ran Head `6b01c577dd06399fcdc34291363a1d56b108ee9c` merged into `main` `5cb015caaaaf83f8ee431414ee6a457b5b307d49` (merged tree `1c2f0a4b41b10ab6fa71e470631785b58acb90f0`). The machine was Debian 13 (VM, Xeon Gold 6136), GCC 14.2.0, Release, Ninja, with lavapipe and no GPU. ``` git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...6b01c577dd06399fcdc34291363a1d56b108ee9c python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "^(guest_avplayer|avplayer_http)" # negative control 1: main's Source.cpp git show 5cb015caaaaf83f8ee431414ee6a457b5b307d49:core/libs/prx/libSceAvPlayer/src/Source.cpp > core/libs/prx/libSceAvPlayer/src/Source.cpp ninja -C build -j32 -l32 libs tests/guest_avplayer_tests ctest --test-dir build --output-on-failure -R "^guest_avplayer$" # negative control 2: merged Source.cpp with only the `drifted` line reverted to main's expression ninja -C build -j32 -l32 libs tests/guest_avplayer_tests ctest --test-dir build --output-on-failure -R "^guest_avplayer$" # 3 times # restore git show 1c2f0a4b41b10ab6fa71e470631785b58acb90f0:core/libs/prx/libSceAvPlayer/src/Source.cpp > core/libs/prx/libSceAvPlayer/src/Source.cpp ninja -C build -j32 -l32 libs tests/guest_avplayer_tests ctest --test-dir build --output-on-failure -R "^guest_avplayer$" # 3 times git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build (merged tree) | ok | | `guest_avplayer`, `guest_avplayer_callback_close`, `guest_avplayer_paused_first_video`, `guest_avplayer_http`, `avplayer_http_transport`, `avplayer_http_patched_modules` | 6/6 pass; `guest_avplayer` 4.5–4.8 s (3 more runs after the restore, all pass) | | Script test run (842 tests) | 839 pass, 1 expected skip, 2 failures not caused by this PR (see below) | | Worktree after negative control | `git status --porcelain` empty | The script reported two failures that are not on its baseline list: `agc_driver_image_sample_lod_clamp_shader_lane` and `unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group`. Neither comes from this PR: - The AGC test executable has no AvPlayer input (`ninja -t query` finds no AvPlayer dependency). - The baseline was measured on an older `main` (`096c45570f`). Between the baseline and the `main` used here, `main` changed the AGC sampler code, the `agc_driver_image_sample_lod_clamp_tests` fragment, `tools/unwrap_self.py` and `tools/tests/test_unwrap_self.py`. - The unwrap test fails at `os.chown(directory, -1, group)` with EINVAL, which is a limit of this sandbox. The script also lists `unwrap_self` as fixed, which has nothing to do with this PR either. ## Negative control - **`main`'s `Source.cpp`:** `guest_avplayer` fails with `unexpected optional video buffer count`. This is the new buffer-count rows, and it matches BunnyFl's result. The failure stops the test before the clock test runs. - **Merged `Source.cpp` with only the `drifted` condition reverted** (`Source.cpp:637` back to `timestamp > currentClock + 50.0` without the `!unsynced` guard): `guest_avplayer` fails 3/3 with `no-sync clock followed audio pulled early: 578 ms after 29 ms`, then `578/29` and `578/30`. This isolates `TestNoSyncClockIgnoresEarlyAudio`, and it confirms ahmadmuj's red check on a different machine and compiler. - **Restored the merged file and rebuilt:** the test passes 3/3, and the worktree is back to the merged tree. ## Findings ### Blocking None. ### Non-blocking - **The debt line overstates the new rule** (`docs/dev/debt/libSceAvPlayer.md:28`). ahmadmuj already raised this; I confirm it by reading the code. The entry says audio pulled ahead "does not move it forward in this mode", but two paths still rebase forward to the last pulled timestamp in no-sync mode: - the `exhausted` term at `core/libs/prx/libSceAvPlayer/src/Source.cpp:638-643`; - `reconcileExhaustedAudioClock` at `core/libs/prx/libSceAvPlayer/src/Source.cpp:579-583`. The `epoch > clockEpoch` rebase at line 639 does the same. A title that pulls audio 2–4× fast for the whole film runs out of audio early, and at that point the clock still jumps to the end of the audio. `main` behaves the same way, so this is not a regression. Suggested fix: limit the end-of-audio rebase to a timestamp behind the clock, like the `drifted` rule, or name these exceptions in the debt line. - **The new test does not check that its allocations were freed** (`core/libs/tests/GuestAvPlayer.cpp:1610-1628`). `TestNoSyncClockIgnoresEarlyAudio` does not check `allocations.blocks.empty()` after `sceAvPlayerClose`, unlike `TestNoSyncVideoCanLeadAudioClock`. ahmadmuj noted this too. Adding the check costs one line. Other things I checked and found correct: - `addVideoDecodeAheadBuffers` (`Source.cpp:743-747`) runs only from `Start` (`Source.cpp:359`). It reads the atomic `syncMode` there, which `Player.cpp:218` forwards before playback starts, so "as playback starts" in the debt entry is accurate. - `addVideoBuffers` frees a partial request before it returns `false`, so the fallback to 4 starts clean. - `SetAvSyncMode` accepts only 0 and 1, so `syncMode != SyncModeDefault` means exactly no-sync mode. - In default mode the `drifted` expression reduces to `main`'s expression. ## Not verified - PPSA35399 and PPSA12544 behaviour. I launched no titles. - Windows and non-lavapipe hosts. Other reviewers posted Windows runs. - Whether the console's clock follows audio pulled early, or how many frames it decodes ahead. The debt entries already record both as unknown. - I did not rerun the two unrelated failing tests in isolation on `main`. I attribute them to `main` because their inputs differ from the baseline and do not include any file this PR touches. <!-- anyps5-bots job=2509 head=6b01c577dd06399fcdc34291363a1d56b108ee9c -->
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!11772
No description provided.