mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<double>(lastPresented + frameDuration())) return false;
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user