Actual buffer format may be different from requested format so use
returned one for calculation.
This commit is contained in:
parent
bcb1387929
commit
2ea305b02c
|
@ -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));
|
||||
/* **** */
|
||||
|
||||
|
|
Loading…
Reference in New Issue