Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/libs/prx/libSceAvPlayer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if(BUILD_TESTING)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/guest_avplayer)
add_test(NAME guest_avplayer COMMAND guest_avplayer_tests)
add_test(NAME guest_avplayer_callback_close COMMAND guest_avplayer_tests --callback-close)
add_test(NAME guest_avplayer_paused_first_video COMMAND guest_avplayer_tests --paused-first-video)
set_tests_properties(guest_avplayer_paused_first_video PROPERTIES
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/guest_avplayer_paused_first_video
TIMEOUT 20)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/guest_avplayer_paused_first_video)
set_tests_properties(guest_avplayer PROPERTIES
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/guest_avplayer
TIMEOUT 60)
Expand All @@ -21,6 +26,8 @@ if(BUILD_TESTING)
if(WIN32)
set_tests_properties(guest_avplayer PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAvPlayer>")
set_tests_properties(guest_avplayer_paused_first_video PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAvPlayer>")
set_tests_properties(guest_avplayer_callback_close PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAvPlayer>")
endif()
Expand Down
2 changes: 1 addition & 1 deletion core/libs/prx/libSceAvPlayer/src/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ class FfmpegSource final : public ISource {
while (!frames.empty() && frames.front().epoch < stale) recycleFront(video);
if (frames.empty()) return false;
const auto& front = frames.front();
if (paused && front.epoch <= clockEpoch) return false;
if (paused && presented && front.epoch <= clockEpoch) return false;
if (front.epoch > clockEpoch) {
if (synced && audioDriving && speed == NormalSpeed) return false;
if (synced && front.seamless && presented && presentationClock.Now() < static_cast<double>(lastPresented + frameDuration())) return false;
Expand Down
27 changes: 27 additions & 0 deletions core/libs/tests/GuestAvPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,26 @@ void TestRestartAfterPausedJumpKeepsClockRunning() {
Check(sceAvPlayerClose(player) == 0, "close failed");
}

void TestPausedPreparationAfterAudioStarts(std::uint32_t syncMode) {
Events events;
auto init = InitData(&events);
auto* player = sceAvPlayerInit(&init);
Check(player != nullptr, "init failed");
Check(sceAvPlayerAddSource(player, "/app0/avplayer.mp4") == 0, "add source failed");
Check(sceAvPlayerEnableStream(player, VideoStream) == 0, "enable video failed");
Check(sceAvPlayerEnableStream(player, EnglishAudioStream) == 0, "enable audio failed");
Check(sceAvPlayerSetAvSyncMode(player, syncMode) == 0, "sync mode failed");
Check(sceAvPlayerStart(player) == 0, "start failed");
AvPlayerFrameInfo audio{};
Check(WaitFor([&] { return sceAvPlayerGetAudioData(player, &audio) != 0; }), "no initial audio frame");
Check(sceAvPlayerPause(player) == 0, "pause failed");
AvPlayerFrameInfoEx frame{};
Check(WaitFor([&] { return sceAvPlayerGetVideoDataEx(player, &frame) != 0; }), "first video frame blocked during paused preparation after audio started");
CheckVideoFrame(frame);
Check(!sceAvPlayerGetVideoDataEx(player, &frame), "paused preparation delivered more than the initial video frame");
Check(sceAvPlayerClose(player) == 0, "close failed");
}

void TestUnsyncedVideoKeepsUpWithAudio() {
Events events;
AvPlayerInitData init = InitData(&events);
Expand Down Expand Up @@ -1561,6 +1581,13 @@ int main(int argc, char** argv) {
std::puts("AvPlayer callback close tests passed");
return 0;
}
if (argc == 2 && std::strcmp(argv[1], "--paused-first-video") == 0) {
WriteMovie();
TestPausedPreparationAfterAudioStarts(0);
TestPausedPreparationAfterAudioStarts(1);
std::puts("AvPlayer paused first video tests passed");
return 0;
}
Check(argc == 1, "unknown AvPlayer test arguments");
WriteMovie();
TestLoopWarningAtPlayback();
Expand Down
2 changes: 2 additions & 0 deletions docs/dev/debt/libSceAvPlayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- [sceAvPlayerInitEx](../../../core/libs/prx/libSceAvPlayer/Export.cpp) (libSceAvPlayer) - the PS5 init data layout (`this_size` 0x230: auto start at 0x74, nine 0x30-byte thread parameter blocks from 0x78, output video frame buffer count at 0x228) follows [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/main/src/libs/avPlayer.cpp), [prosper](https://github.com/mattias800/prosper/blob/main/prosper/src/hle/video/avplayer.cpp), [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/main/src/SharpProspero/Interop/Media/AvPlayer.cs) and [sharpemu](https://github.com/sharpemu/sharpemu/blob/main/src/SharpEmu.Libs/AvPlayer/AvPlayerExports.cs), which agree on it. PPSA25063 fills the same fields, writes auto start 0 and starts playback with `sceAvPlayerStart`; a title that sets auto start has not been seen. A smaller `this_size` is read with the PS4 offsets. The thread parameters are ignored
- [AvPlayer auto start](../../../core/libs/prx/libSceAvPlayer/src/Player.cpp) (libSceAvPlayer) - the auto start that `sceAvPlayerAddSource` queues for a player with auto start or without an event callback starts the player only while it is still ready: a title that starts the player itself before the auto start runs keeps its playback and the frames it holds. Not confirmed on a title.

- [Paused initial video](../../../core/libs/prx/libSceAvPlayer/src/Source.cpp) (libSceAvPlayer) keeps the first picture available when audio has already established the playback epoch before the caller pauses. Further pictures of that epoch stay blocked, as after a paused jump. The console's exact initial preparation ordering has not been measured.

### Functional

- [sceAvPlayerGetVideoData](../../../core/libs/prx/libSceAvPlayer/src/Source.cpp) (libSceAvPlayer) in sync mode `SCE_AVPLAYER_AV_SYNC_MODE_NONE` skips queued frames that the audio clock has already passed while the title pulls audio, so a title that requests video slower than the film's frame rate keeps the picture with the sound. Whether the console hands out every frame in this mode is unknown. PPSA12544 requests 7-19 frames per second for a 30 fps cinematic
Loading