From fdebace998ce93e8395c4be052a5dce8e296b35f Mon Sep 17 00:00:00 2001 From: Ove Kaaven Date: Mon, 10 Sep 2001 23:08:11 +0000 Subject: [PATCH] Fix buffering problems in HEL mode. --- dlls/dsound/dsound_main.c | 9 +++++++++ include/dsound.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index 4b24e917564..675dfb091b3 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -2047,6 +2047,11 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer( primarybuf->dsbd.dwFlags = dsbd->dwFlags; return DS_OK; } /* Else create primary buffer */ + } else { + if (dsbd->dwBufferBytes < DSBSIZE_MIN || dsbd->dwBufferBytes > DSBSIZE_MAX) { + ERR("invalid sound buffer size %ld\n", dsbd->dwBufferBytes); + return DSERR_INVALIDPARAM; /* FIXME: which error? */ + } } *ippdsb = (IDirectSoundBufferImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundBufferImpl)); @@ -3215,6 +3220,10 @@ static void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw } else mixq = 0; if (forced) mixq = DS_SND_QUEUE; + /* Make sure that we don't rewrite any fragments that have already been + written and are waiting to be played */ + mixq = (dsound->pwqueue > mixq) ? 0 : (mixq - dsound->pwqueue); + /* output it */ for (; mixq; mixq--) { waveOutWrite(dsound->hwo, dsound->pwave[dsound->pwwrite], sizeof(WAVEHDR)); diff --git a/include/dsound.h b/include/dsound.h index 1af21d7702d..d3da415a5a9 100644 --- a/include/dsound.h +++ b/include/dsound.h @@ -130,6 +130,8 @@ typedef struct _DSCAPS #define DSBCAPS_GETCURRENTPOSITION2 0x00010000 /* More accurate play cursor under emulation*/ #define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 +#define DSBSIZE_MIN 4 +#define DSBSIZE_MAX 0xFFFFFFF #define DSBPAN_LEFT -10000 #define DSBPAN_RIGHT 10000 #define DSBVOLUME_MAX 0