From b3a7568811a9a961787eb3e51adb4cee99298930 Mon Sep 17 00:00:00 2001 From: kaienfr Date: Sat, 12 Apr 2014 14:54:25 +0200 Subject: [PATCH] change the way in AuGetInfoToAddStreamData and AuNotifyAddStreamData. readPos and available buffer is firstly updated in AuGetInfoToAddStreamData then notified in AuNotifyAddStreamData. Since, some games as Dead and alive may not call NotifyAddStreamData after GetInfoToAddStreamData --- Core/HW/SimpleAudioDec.cpp | 15 ++++++++++++--- Core/HW/SimpleAudioDec.h | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 52d00c1b09..e89af49ad3 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -374,9 +374,12 @@ int AuCtx::AuCheckStreamDataNeeded() // check how many bytes we have read from source file u32 AuCtx::AuNotifyAddStreamData(int size) { - readPos += size; - AuBufAvailable += size; - writePos = 0; + realReadSize = size; + int diffszie = realReadSize - askedReadSize; + if (diffszie != 0){ + readPos += diffszie; + AuBufAvailable += diffszie; + } if (readPos >= endPos && LoopNum != 0){ // if we need loop, reset readPos @@ -391,6 +394,7 @@ u32 AuCtx::AuNotifyAddStreamData(int size) } // read from stream position srcPos of size bytes into buff +// buff, size and srcPos are all pointers u32 AuCtx::AuGetInfoToAddStreamData(u32 buff, u32 size, u32 srcPos) { // we can recharge AuBuf from its begining @@ -401,6 +405,11 @@ u32 AuCtx::AuGetInfoToAddStreamData(u32 buff, u32 size, u32 srcPos) if (Memory::IsValidAddress(srcPos)) Memory::Write_U32(readPos, srcPos); + askedReadSize = AuBufSize; + readPos += askedReadSize; + AuBufAvailable += askedReadSize; + writePos = 0; + return 0; } diff --git a/Core/HW/SimpleAudioDec.h b/Core/HW/SimpleAudioDec.h index 0079a68a96..7f12b5ff00 100644 --- a/Core/HW/SimpleAudioDec.h +++ b/Core/HW/SimpleAudioDec.h @@ -129,6 +129,8 @@ public: int AuBufAvailable; // the available buffer of AuBuf to be able to recharge data int readPos; // read position in audio source file int writePos; // write position in AuBuf, i.e. the size of bytes decoded in AuBuf. + int askedReadSize; // the size of data requied to be read from file by the game + int realReadSize; // the really read size from file AuCtx() :decoder(NULL){}; ~AuCtx(){