Jörg Höhle : wineoss: Enforce invariant about BlockAlign and nAvgBytesPerSec.
Alexandre Julliard
julliard at winehq.org
Wed Sep 16 16:01:09 CDT 2009
Module: wine
Branch: master
Commit: 8870fe38b5d9a143c78c68a43c95c1be766739b3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8870fe38b5d9a143c78c68a43c95c1be766739b3
Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date: Mon Sep 7 22:29:39 2009 +0200
wineoss: Enforce invariant about BlockAlign and nAvgBytesPerSec.
---
dlls/wineoss.drv/audio.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/dlls/wineoss.drv/audio.c b/dlls/wineoss.drv/audio.c
index ca79cd5..ddf973f 100644
--- a/dlls/wineoss.drv/audio.c
+++ b/dlls/wineoss.drv/audio.c
@@ -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));
More information about the wine-cvs
mailing list