From 7bd3f389c71928f6099324177fd4d0c45be9d1fe Mon Sep 17 00:00:00 2001 From: oioitff Date: Fri, 17 May 2013 01:15:23 +0800 Subject: [PATCH] Improve getremainFrame. Fixed Musou Orochi 2 and so on. --- Core/HLE/sceAtrac.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 32c9f80134..6de2f2b13b 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -165,25 +165,18 @@ struct Atrac { u32 getDecodePosBySample(int sample) { return (u32)(firstSampleoffset + sample / ATRAC_MAX_SAMPLES * atracBytesPerFrame ); } + int getRemainFrames() { - // many games request to add atrac data when remainFrames = 0 - // However, some other games request to add atrac data - // when remainFrames = PSP_ATRAC_ALLDATA_IS_ON_MEMORY . - // Still need to find out how getRemainFrames() should work. + // games would like to add atrac data when it wants. + // Do not try to guess when it want to add data. + // Just return current remainFrames. int remainFrame; if (first.fileoffset >= first.filesize || currentSample >= endSample) remainFrame = PSP_ATRAC_ALLDATA_IS_ON_MEMORY; - else if (decodePos > first.size) { - // There are not enough atrac data right now to play at a certain position. - // Must load more atrac data first - remainFrame = 0; - } else if (second.writableBytes <= 0) { - remainFrame = PSP_ATRAC_NONLOOP_STREAM_DATA_IS_ON_MEMORY ; - } else { + else { // guess the remain frames. - // games would add atrac data when remainFrame = 0 or -1 - remainFrame = (first.size - decodePos) / atracBytesPerFrame - 1; + remainFrame = ((int)first.size - (int)decodePos) / atracBytesPerFrame; } return remainFrame; } @@ -897,6 +890,8 @@ int __AtracSetContext(Atrac *atrac, u32 buffer, u32 bufferSize) // alloc audio frame atrac->pFrame = avcodec_alloc_frame(); + // reinit decodePos, because ffmpeg had changed it. + atrac->decodePos = 0; #endif return 0;