fix(libSceAvPlayer): report PS4 stream types in a PS4 process #22033
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22033"
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 B-Howell on 2026-11-17T02:30:32Z.
What
sceAvPlayerGetStreamInfoandsceAvPlayerGetStreamInfoExreported the PS5 stream types (video 1, audio 2) in every process. A PS4 title's libSceAvPlayer numbers video 0 and audio 1 (the enum shadPS4 uses at143b58aa48avplayer.h:Video, Audio, TimedText, Unknown).A player now picks its numbering once from
sceKernelIsPs4Process(CUSA title ID): a PS4 process gets video 0 / audio 1, a PS5 process keeps video 1 / audio 2. Auto start compares against the same numbering, so it still enables both streams. The query keeps the guesterrnounchanged, whichguest_avplayerchecks.libSceAvPlayer(and.native) now linklibkernel_sys, aslibSceAudio3dalready does, andavplayer_http_patched_modulesstages and patches it with the other modules. The debt entry for the two exports is changed by a fragment.Bloodborne CUSA00900 1.09 needs this. When New Game reaches the intro movie, the title calls
sceAvPlayerInit,PostInit,AddSourceandSetLooping, then createsMv_AudioPlayThread. On READY its handler (eboot0x2cff6a0) callssceAvPlayerStreamCountandsceAvPlayerGetStreamInfofor each stream, treating type 0 as video and type 1 as audio. The trace of the failing run onmain(--trace-imports,APS5_TRACE_CALLS=libSceAvPlayer, all on the main thread):The handler found no type 0 video and no type 1 audio, so it never called
EnableStreamorStartand the title closed the movie at once. The close deletes the movie's thread object. Its destructor destroys the object's gate mutex, which the new thread's entry (0x2a3b1e0) has not locked yet. The thread then fails the title's own check and the game crashes every time:With this change the intro movie plays to its end, with its subtitles, and the title moves on to character creation.
Tested
Windows 11, WinLibs GCC 15.2.0, Release.
guest_avplayer_ps4_process(guest_avplayer_tests --ps4-process, run in its own working directory with a CUSAparam.sfo): video type 0 and audio type 1 from both exports, and auto start still produces video and English audio. It fails onmainwitha PS4 process reports video as type 0 and audio as type 1, and passes with this change.ctest -R avplayer:guest_avplayer,guest_avplayer_callback_close,guest_avplayer_paused_first_video,guest_avplayer_ps4_process,guest_avplayer_http,avplayer_http_patched_modules,guest_avplayer_nativeandguest_avplayer_native_printfall pass (8/8). The PS5 numbering checks inguest_avplayerare unchanged.avplayer_http_patched_modulesfailed withloading patched AvPlayer faileduntil the second commit stagedlibkernel_sysbeside the patched modules; it passes now. (avplayer_http_transportwas not built; it does not link the library.)mainit crashed inMv_AudioPlayThreadin 3 of 3 runs. With this change, in 2 of 2 runs, the intro movie played for about 40 s with its subtitles and the title then loaded character creation. The next stop is the unrelatedAGC graphics: PS4 color target fast clear (CMASK) is not implemented. The movie's video frames show as horizontal stripes, a separate issue not touched here.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T02:35:27Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
289416ef56:tools/check_conventions.pypassed.guest_avplayer_testsbuilt cleanly.guest_avplayer,guest_avplayer_callback_close,guest_avplayer_paused_first_video,guest_avplayer_ps4_process):core/libs/prx/libSceAvPlayer/include/AvPlayer.hpp,core/libs/prx/libSceAvPlayer/src/Player.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-17T02:39:30Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
326789bd61:tools/check_conventions.pypassed.guest_avplayer_testsbuilt cleanly.guest_avplayer,guest_avplayer_callback_close,guest_avplayer_paused_first_video,guest_avplayer_ps4_process):core/libs/prx/libSceAvPlayer/include/AvPlayer.hpp,core/libs/prx/libSceAvPlayer/src/Player.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T05:11:29Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
326789bd610b76024824cd79d90d59aaf40405f6, basemain. Merged-preview check not run.repo_read.py).Results
ctest -R avplayerguest_avplayer_ps4_processmain, passes hereFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAvPlayer/src/Player.cpp:274:guestStreamTypemaps every type other than video to the audio number.StreamTypeTimedText(2) is therefore reported as audio (1) in a PS4 process, where the old code left it at 2. The source only emits video and audio (core/libs/prx/libSceAvPlayer/src/Source.cpp:619), so no current stream is affected. Smallest fix: map audio explicitly and return other types unchanged.Sources
github.com/boykopovar/AnyPS5@326789bd61/core/libs/prx/libSceAvPlayer/src/Source.cpp (L619)Not verified
ctestand the Bloodborne run are not checked here. The author reports Windows 11, WinLibs GCC 15.2.0, Release, and a PS4 process run of CUSA00900 1.09. The negative control (new test fails onmain) is also author-reported.GuestAvPlayer.cpp(2771 lines) andPlayer.cpp(454 lines) were not read end to end. Only the changed hunks and the autoStart and stream-info regions were read. Reading the rest of the test file is what keeps this from being a full review.sceKernelIsPs4Processgets the process type (theparam.sfolookup) was not located at the head, so the test fixture's layout was not checked against it.Events,InitData,WaitFor,CheckEnglishAudio,WriteMovie) were not checked beyondVideoStream.To get this to a good state
Nothing is required.
The non-blocking item above is optional.