winecoreaudio: Enforce invariant about BlockAlign and nAvgBytesPerSec.

oldstable
Jörg Höhle 2009-09-11 07:46:43 +02:00 committed by Alexandre Julliard
parent 89fe38ca9e
commit e6770a4011
1 changed files with 20 additions and 0 deletions

View File

@ -825,6 +825,16 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
return MMSYSERR_NOERROR;
}
/* nBlockAlign and nAvgBytesPerSec are output variables for dsound */
if (lpDesc->lpFormat->nBlockAlign != lpDesc->lpFormat->nChannels*lpDesc->lpFormat->wBitsPerSample/8) {
lpDesc->lpFormat->nBlockAlign = lpDesc->lpFormat->nChannels*lpDesc->lpFormat->wBitsPerSample/8;
WARN("Fixing nBlockAlign\n");
}
if (lpDesc->lpFormat->nAvgBytesPerSec!= lpDesc->lpFormat->nSamplesPerSec*lpDesc->lpFormat->nBlockAlign) {
lpDesc->lpFormat->nAvgBytesPerSec = lpDesc->lpFormat->nSamplesPerSec*lpDesc->lpFormat->nBlockAlign;
WARN("Fixing nAvgBytesPerSec\n");
}
/* We proceed in three phases:
* o Reserve the device for us, marking it as unavailable (not closed)
* o Create, configure, and start the Audio Unit. To avoid deadlock,
@ -1907,6 +1917,16 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
return MMSYSERR_NOERROR;
}
/* nBlockAlign and nAvgBytesPerSec are output variables for dsound */
if (lpDesc->lpFormat->nBlockAlign != lpDesc->lpFormat->nChannels*lpDesc->lpFormat->wBitsPerSample/8) {
lpDesc->lpFormat->nBlockAlign = lpDesc->lpFormat->nChannels*lpDesc->lpFormat->wBitsPerSample/8;
WARN("Fixing nBlockAlign\n");
}
if (lpDesc->lpFormat->nAvgBytesPerSec!= lpDesc->lpFormat->nSamplesPerSec*lpDesc->lpFormat->nBlockAlign) {
lpDesc->lpFormat->nAvgBytesPerSec = lpDesc->lpFormat->nSamplesPerSec*lpDesc->lpFormat->nBlockAlign;
WARN("Fixing nAvgBytesPerSec\n");
}
wwi = &WInDev[wDevID];
if (!OSSpinLockTry(&wwi->lock))
return MMSYSERR_ALLOCATED;