diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 4ac6afe9bba..69e47c44a24 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -329,7 +329,6 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat( ) { ICOM_THIS(PrimaryBufferImpl,iface); IDirectSoundImpl* dsound = This->dsound; - IDirectSoundBufferImpl** dsb; HRESULT err = DS_OK; int i; TRACE("(%p,%p)\n",This,wfex); @@ -361,20 +360,6 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat( /* **** */ RtlAcquireResourceExclusive(&(dsound->lock), TRUE); - if (dsound->wfx.nSamplesPerSec != wfex->nSamplesPerSec) { - dsb = dsound->buffers; - for (i = 0; i < dsound->nrofbuffers; i++, dsb++) { - /* **** */ - EnterCriticalSection(&((*dsb)->lock)); - - (*dsb)->freqAdjust = ((*dsb)->freq << DSOUND_FREQSHIFT) / - wfex->nSamplesPerSec; - - LeaveCriticalSection(&((*dsb)->lock)); - /* **** */ - } - } - dsound->wfx.nSamplesPerSec = wfex->nSamplesPerSec; dsound->wfx.nChannels = wfex->nChannels; dsound->wfx.wBitsPerSample = wfex->wBitsPerSample; @@ -431,6 +416,20 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat( } DSOUND_RecalcPrimary(dsound); + if (dsound->wfx.nSamplesPerSec != wfex->nSamplesPerSec) { + IDirectSoundBufferImpl** dsb = dsound->buffers; + for (i = 0; i < dsound->nrofbuffers; i++, dsb++) { + /* **** */ + EnterCriticalSection(&((*dsb)->lock)); + + (*dsb)->freqAdjust = ((*dsb)->freq << DSOUND_FREQSHIFT) / + wfex->nSamplesPerSec; + + LeaveCriticalSection(&((*dsb)->lock)); + /* **** */ + } + } + RtlReleaseResource(&(dsound->lock)); /* **** */