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
This commit is contained in:
kaienfr 2014-04-12 14:54:25 +02:00
parent c6ed59ec0b
commit b3a7568811
2 changed files with 14 additions and 3 deletions

View File

@ -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;
}

View File

@ -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(){