Commit 7e334a7a authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

dsound: Allocate big enough committedbuff up front.

parent 13672650
......@@ -264,7 +264,6 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetFrequency(IDirectSoundBuffer8 *i
{
IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface);
DWORD oldFreq;
void *newcommitted;
TRACE("(%p,%ld)\n",This,freq);
......@@ -290,17 +289,9 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetFrequency(IDirectSoundBuffer8 *i
oldFreq = This->freq;
This->freq = freq;
if (freq != oldFreq) {
if (freq != oldFreq)
DSOUND_RecalcFormat(This);
newcommitted = realloc(This->committedbuff, This->writelead);
if(!newcommitted) {
ReleaseSRWLockExclusive(&This->lock);
return DSERR_OUTOFMEMORY;
}
This->committedbuff = newcommitted;
}
ReleaseSRWLockExclusive(&This->lock);
return DS_OK;
......@@ -1112,7 +1103,7 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
/* calculate fragment size and write lead */
DSOUND_RecalcFormat(dsb);
dsb->committedbuff = malloc(dsb->writelead);
dsb->committedbuff = malloc(dsb->maxwritelead);
if(!dsb->committedbuff) {
IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface);
return DSERR_OUTOFMEMORY;
......@@ -1216,7 +1207,7 @@ HRESULT IDirectSoundBufferImpl_Duplicate(
return DSERR_OUTOFMEMORY;
}
committedbuff = malloc(pdsb->writelead);
committedbuff = malloc(pdsb->maxwritelead);
if (committedbuff == NULL) {
free(dsb);
*ppdsb = NULL;
......
......@@ -140,7 +140,7 @@ struct IDirectSoundBufferImpl
PWAVEFORMATEX pwfx;
BufferMemory* buffer;
DWORD playflags,state,leadin;
DWORD writelead,buflen;
DWORD writelead,maxwritelead,buflen;
DWORD freq;
DSVOLUMEPAN volpan;
DSBUFFERDESC dsbd;
......
......@@ -130,6 +130,7 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb)
/* calculate the 10ms write lead */
dsb->writelead = (dsb->freq / 100) * dsb->pwfx->nBlockAlign;
dsb->maxwritelead = (DSBFREQUENCY_MAX / 100) * dsb->pwfx->nBlockAlign;
if (oldFreqAdjustDen)
dsb->freqAccNum = (dsb->freqAccNum * dsb->freqAdjustDen + oldFreqAdjustDen / 2) / oldFreqAdjustDen;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment