From e4817b4e833ec563e7671a4c15905663d2b78edc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 28 Apr 2019 07:55:29 -0700 Subject: [PATCH] Mp3: Reset sum decoded on loop. And only on loop, not when getting add info (which clearly doesn't loop, from tests.) --- Core/HW/SimpleAudioDec.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index f5c6bf52eb..ba684785ed 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -330,10 +330,6 @@ u32 AuCtx::AuDecode(u32 pcmAddr) // no output pcm, we are at the end of the stream AuBufAvailable = 0; sourcebuff.clear(); - if (LoopNum != 0) { - // if we loop, reset readPos - readPos = startPos; - } } else { // Update our total decoded samples, but don't count stereo. SumDecodedSamples += decoder->GetOutSamples() / 2; @@ -346,6 +342,15 @@ u32 AuCtx::AuDecode(u32 pcmAddr) AuBufAvailable -= srcPos; } } + + if (sourcebuff.empty() && LoopNum != 0) { + // When looping, start the sum back off at zero and reset readPos to the start. + SumDecodedSamples = 0; + readPos = startPos; + if (LoopNum > 0) + LoopNum--; + } + Memory::Write_U32(PCMBuf, pcmAddr); return outpcmbufsize; } @@ -413,15 +418,6 @@ u32 AuCtx::AuNotifyAddStreamData(int size) { sourcebuff.append((const char *)Memory::GetPointer(AuBuf + offset), size); } - if (readPos >= (int)endPos && LoopNum != 0) { - // if we need loop, reset readPos - readPos = startPos; - // reset LoopNum - if (LoopNum > 0){ - LoopNum--; - } - } - return 0; }