From ad6237f6f756a56bed11554e07db9f176c6b72ef Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 26 Jan 2008 21:10:55 -0800 Subject: [PATCH] Fix availibility amount calculation --- Alc/dsound.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Alc/dsound.c b/Alc/dsound.c index e7bfb139..41248961 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -58,14 +58,17 @@ static ALuint DSoundProc(ALvoid *ptr) DWORD PlayCursor; VOID *WritePtr1, *WritePtr2; DWORD WriteCnt1, WriteCnt2; + DWORD BufferSize; DWORD avail; HRESULT err; + BufferSize = pDevice->UpdateFreq*pDevice->FrameSize; + while(!pData->killNow) { // Get current play and write cursors IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &PlayCursor, NULL); - avail = (PlayCursor-LastCursor) % (pDevice->UpdateFreq*pDevice->FrameSize); + avail = (PlayCursor-LastCursor+BufferSize) % BufferSize; if(avail == 0) { @@ -105,7 +108,7 @@ static ALuint DSoundProc(ALvoid *ptr) // Update old write cursor location LastCursor += WriteCnt1+WriteCnt2; - LastCursor %= pDevice->UpdateFreq*pDevice->FrameSize; + LastCursor %= BufferSize; } return 0; -- 2.11.4.GIT