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);
|
ICOM_THIS(PrimaryBufferImpl,iface);
|
||||||
IDirectSoundImpl* dsound = This->dsound;
|
IDirectSoundImpl* dsound = This->dsound;
|
||||||
IDirectSoundBufferImpl** dsb;
|
|
||||||
HRESULT err = DS_OK;
|
HRESULT err = DS_OK;
|
||||||
int i;
|
int i;
|
||||||
TRACE("(%p,%p)\n",This,wfex);
|
TRACE("(%p,%p)\n",This,wfex);
|
||||||
|
@ -361,20 +360,6 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat(
|
||||||
/* **** */
|
/* **** */
|
||||||
RtlAcquireResourceExclusive(&(dsound->lock), TRUE);
|
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.nSamplesPerSec = wfex->nSamplesPerSec;
|
||||||
dsound->wfx.nChannels = wfex->nChannels;
|
dsound->wfx.nChannels = wfex->nChannels;
|
||||||
dsound->wfx.wBitsPerSample = wfex->wBitsPerSample;
|
dsound->wfx.wBitsPerSample = wfex->wBitsPerSample;
|
||||||
|
@ -431,6 +416,20 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat(
|
||||||
}
|
}
|
||||||
DSOUND_RecalcPrimary(dsound);
|
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));
|
RtlReleaseResource(&(dsound->lock));
|
||||||
/* **** */
|
/* **** */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue