From 736ba56d850008256fc66af93b7ca2f3c51f6464 Mon Sep 17 00:00:00 2001 From: Merijn Date: Tue, 6 Oct 2026 15:20:51 +0200 Subject: [PATCH] fix(avplayer): deliver the frame at a jump while paused A paused player returned no video at all. Unity's video player prepares a clip by starting it, pausing, jumping to the start and polling sceAvPlayerGetVideoDataEx until the frame at the jump arrives, and only then resumes; PPSA12544 waited there forever on a black screen in its intro cinematic. While paused, the first frame after a jump is now delivered (the paused clock rebased to it); other frames are still held until the player resumes. The guest test pauses, jumps and expects that one frame and nothing after it. AI-assisted: yes Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceAvPlayer/src/Player.cpp | 2 +- core/libs/prx/libSceAvPlayer/src/Source.cpp | 3 ++- core/libs/tests/GuestAvPlayer.cpp | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libSceAvPlayer/src/Player.cpp b/core/libs/prx/libSceAvPlayer/src/Player.cpp index cc55f6eff..1e265d395 100644 --- a/core/libs/prx/libSceAvPlayer/src/Player.cpp +++ b/core/libs/prx/libSceAvPlayer/src/Player.cpp @@ -327,7 +327,7 @@ int Player::SetAvSyncMode(std::uint32_t mode) { bool Player::GetVideoData(AvPlayerFrameInfoEx& info) { std::lock_guard lock(mutex); - if (!source || state != State::Play) return false; + if (!source || (state != State::Play && state != State::Pause)) return false; return source->GetVideoData(info); } diff --git a/core/libs/prx/libSceAvPlayer/src/Source.cpp b/core/libs/prx/libSceAvPlayer/src/Source.cpp index a59c07a47..8990d5d57 100644 --- a/core/libs/prx/libSceAvPlayer/src/Source.cpp +++ b/core/libs/prx/libSceAvPlayer/src/Source.cpp @@ -494,7 +494,7 @@ private: } bool takeVideo(AvPlayerFrameInfoEx& info) { - if (!started || paused || video.stream < 0 || speed < 0) return false; + if (!started || video.stream < 0 || speed < 0) return false; if (speed != NormalSpeed) dropLateAudio(); auto& frames = video.frames; const bool synced = syncMode == SyncModeDefault; @@ -502,6 +502,7 @@ private: 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 (front.epoch > clockEpoch) { if (synced && audioDriving && speed == NormalSpeed) return false; if (synced && front.seamless && presented && presentationClock.Now() < static_cast(lastPresented + frameDuration())) return false; diff --git a/core/libs/tests/GuestAvPlayer.cpp b/core/libs/tests/GuestAvPlayer.cpp index e9981ef53..b38ee2895 100644 --- a/core/libs/tests/GuestAvPlayer.cpp +++ b/core/libs/tests/GuestAvPlayer.cpp @@ -756,6 +756,13 @@ void TestPlayback() { Check(!sceAvPlayerGetVideoDataEx(player, &frame) && !sceAvPlayerGetAudioData(player, &sound), "data delivered while paused"); Check(sceAvPlayerCurrentTime(player) == paused, "clock moved while paused"); Check(sceAvPlayerIsActive(player), "inactive while paused"); + Check(sceAvPlayerJumpToTime(player, 300) == 0, "jump while paused failed"); + Check(WaitFor([&] { return events.Seen(EventWarning, JumpComplete); }), "jump completion missing while paused"); + Check(WaitFor([&] { return sceAvPlayerGetVideoDataEx(player, &frame) != 0; }), "no frame at a jump while paused"); + CheckVideoFrame(frame); + Check(frame.timestamp >= 300 && frame.timestamp <= 367, "paused jump landed at " + std::to_string(frame.timestamp)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + Check(!sceAvPlayerGetVideoDataEx(player, &frame) && !sceAvPlayerGetAudioData(player, &sound), "data delivered after the frame at a paused jump"); events.Clear(); Check(sceAvPlayerResume(player) == 0, "resume failed"); Check(sceAvPlayerResume(player) == OperationFailed, "resume accepted while playing");