forked from Mirrors/wine-wine
winecoreaudio: Enforce invariant about BlockAlign and nAvgBytesPerSec.
parent
89fe38ca9e
commit
e6770a4011
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue