fix(avplayer): use precise Windows notified waits for EOF polling #1780
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1780"
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 Roojool on 2026-10-08T19:04:10Z.
What
Windows guest-visible AvPlayer EOF
EventStopwas delivered up to ~15.6 mslate (related #1471, partial: this PR covers only the
Player::controllerLoop5 ms poll; other waits named in that issue are out of scope). The loop's
wait_forgoes through winpthreadsGetTickCount64steps, so EOF pollingfired late. The event wait now uses libkernel's
TimedWait::Condition(precise timed waits on Windows;TimedWait.cppis built into libSceAvPlayer); queued events andClosestill wake immediately. Linux behaviour is unchanged. Adds isolatedTestEofStopLatency(9-sample median under 10 ms, exact-once
EventStop, no positive floor).Overlap: #1601 touches the same test file (
GuestAvPlayer.cpp) withdifferent functions plus
Source.cpp, which this PR does not modify; nofunction is duplicated, rebase coordination is limited to test-file context.
Tested
Measured by the author on the previous revision (own HostCondition with a waitable timer; the final revision using
TimedWait::Conditionwas not re-measured on Windows). Windows (WinLibs GCC 15.2.0,build-cycle2,cmake --build build-cycle2 --target guest_avplayer_tests --parallel 2,ctest --test-dir build-cycle2 -R '^guest_avplayer$'): identical final probeFAILS on original code (median 13.083 ms, exit 8) and PASSES with the fix
(median 1.396 ms post-rebase; 3x
--repeat until-fail:3medians1.381/0.959/1.454 ms pre-diagnostic-fix, all PASS). Precision holds with
APS5_NO_TIMER_RESOLUTION=1(0.541 ms) andAPS5_COARSE_TIMED_WAITS=1(1.199 ms).
nid_patcher libSceAvPlayer --preserve-exportson a copy of therebuilt unpatched PRX exits 0; all 28 guest exports hashed (spot-checked
sceAvPlayerInit/sceAvPlayerIsActiveNIDs independently), 0 plain namesremain. Guest test loads the built unpatched PRX (PE imports
libSceAvPlayer.prx/libc.prx); patched-title execution not run, nohardware run.
Linux (WSL2 Ubuntu GCC 15.2,
/home/roojool/anyps5-avplayer-eof-linux):same commands, 3x repeats PASS (medians 1.416/0.802/0.908 ms); NID patch of a
PRX copy exits 0 with matching per-symbol addresses.
check_conventions.py --base upstream/main --title ... --body ...,check_test_registration.py(Windows 409, Linux 412 executables, 3 recordednot-run),
git diff --check: pass. High-resolution timer creation failuresthrow; older Windows and Wine were not validated. The 9-sample median reduces
scheduling noise but cannot guarantee timing on an overloaded host.
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-08T19:04:16Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:34Z.
Please use libkernel's
TimedWait::Condition(prx/libkernel/Time/include/TimedWait.hpp) foreventConditioninstead of the newHostMutex/HostConditioninAvPlayer.hpp. It already gives precise timed waits on Windows; #1655 does the same for VideoOut.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T05:57:54Z.
Review: CHANGES_REQUESTED
Thanks for the measurements. Two things before this can land:
TimedWait::Condition(core/libs/prx/libkernel/Time/include/TimedWait.hpp) foreventConditioninstead of the newHostMutex/HostConditioninAvPlayer.hpp:30-113. It already gives precise timed waits on Windows, and the same approach was taken for VideoOut in #1655. That would also drop the Windows-only code and the second implementation to maintain. Please keepTestEofStopLatencyas the regression test for it.mainincore/libs/tests/GuestAvPlayer.cpp; please rebase (no merge commits) and rerunguest_avplayer.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:30:25Z.
Review: APPROVED
Rebased onto
mainand applied the open review points on your branch:eventConditionis now aTimedWait::ConditionwithWaitUntil(DeadlineNanos(5000), ...);HostMutex/HostConditionand the Windows-only code are gone.TimedWait.cppis compiled into libSceAvPlayer, since libkernel is not linkable from other libraries.core/libs/tests/GuestAvPlayer.cpp(kept both sides;TestEofStopLatencyis kept as the regression test).Checked: scoped build + ctest green,
guest_avplayer5/5 on Linux (Linux uses thecondition_variablepath, so it does not exercise the Windows timing). The Windows latency of this final revision was not re-measured; merging.Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-11T09:30:30Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.