From d4e548013e8ddf15a1a6a08d9327a969c301de3d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 24 May 2014 01:31:50 -0700 Subject: [PATCH] Don't zero paused, but do zero end in psmfplayer. To make sure the video/audio sync up. If an audio frame was already decoded, it should technically be returned, but after that it will return an error. --- Core/HLE/scePsmf.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 520cbc090f..5a39514743 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -1561,16 +1561,17 @@ int scePsmfPlayerGetAudioData(u32 psmfPlayer, u32 audioDataAddr) if (psmfplayer->playMode == PSMF_PLAYER_MODE_PAUSE) { INFO_LOG(HLE, "scePsmfPlayerGetAudioData(%08x): paused mode", psmfPlayer); - // Clear the audio when paused. - if (Memory::IsValidAddress(audioDataAddr)) { - Memory::Memset(audioDataAddr, 0, audioSamplesBytes); - } - return 0; + return ERROR_PSMFPLAYER_NO_MORE_DATA; } int ret = 0; if (psmfplayer->mediaengine->getAudioSamples(audioDataAddr) == 0) { - ret = (int)ERROR_PSMFPLAYER_NO_MORE_DATA; + if (psmfplayer->totalAudioStreams > 0 && psmfplayer->psmfPlayerAvcAu.pts < psmfplayer->totalDurationTimestamp - VIDEO_FRAME_DURATION_TS) { + // Write zeros for any missing trailing frames so it syncs with the video. + Memory::Memset(audioDataAddr, 0, audioSamplesBytes); + } else { + ret = (int)ERROR_PSMFPLAYER_NO_MORE_DATA; + } } DEBUG_LOG(ME, "%08x=scePsmfPlayerGetAudioData(%08x, %08x)", ret, psmfPlayer, audioDataAddr);