Commit 8870fe38 authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

wineoss: Enforce invariant about BlockAlign and nAvgBytesPerSec.

parent bdb73f5c
......@@ -1990,6 +1990,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");
}
TRACE("OSS_OpenDevice requested this format: %dx%dx%d %s\n",
lpDesc->lpFormat->nSamplesPerSec,
lpDesc->lpFormat->wBitsPerSample,
......@@ -2064,13 +2074,6 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwo->waveDesc = *lpDesc;
copy_format(lpDesc->lpFormat, &wwo->waveFormat);
if (wwo->waveFormat.Format.wBitsPerSample == 0) {
WARN("Resetting zeroed wBitsPerSample\n");
wwo->waveFormat.Format.wBitsPerSample = 8 *
(wwo->waveFormat.Format.nAvgBytesPerSec /
wwo->waveFormat.Format.nSamplesPerSec) /
wwo->waveFormat.Format.nChannels;
}
/* Read output space info for future reference */
if (ioctl(wwo->ossdev.fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
ERR("ioctl(%s, SNDCTL_DSP_GETOSPACE) failed (%s)\n", wwo->ossdev.dev_name, strerror(errno));
......@@ -2880,6 +2883,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");
}
TRACE("OSS_OpenDevice requested this format: %dx%dx%d %s\n",
lpDesc->lpFormat->nSamplesPerSec,
lpDesc->lpFormat->wBitsPerSample,
......@@ -2951,14 +2964,6 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwi->waveDesc = *lpDesc;
copy_format(lpDesc->lpFormat, &wwi->waveFormat);
if (wwi->waveFormat.Format.wBitsPerSample == 0) {
WARN("Resetting zeroed wBitsPerSample\n");
wwi->waveFormat.Format.wBitsPerSample = 8 *
(wwi->waveFormat.Format.nAvgBytesPerSec /
wwi->waveFormat.Format.nSamplesPerSec) /
wwi->waveFormat.Format.nChannels;
}
if (ioctl(wwi->ossdev.fd, SNDCTL_DSP_GETISPACE, &info) < 0) {
ERR("ioctl(%s, SNDCTL_DSP_GETISPACE) failed (%s)\n",
wwi->ossdev.dev_name, strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment