Jörg Höhle : winecoreaudio: Enforce invariant about BlockAlign and nAvgBytesPerSec.

Alexandre Julliard julliard at winehq.org
Wed Sep 16 16:01:15 CDT 2009


Module: wine
Branch: master
Commit: e6770a40118349e8d33e52a54af3602e9af76ac3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e6770a40118349e8d33e52a54af3602e9af76ac3

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Fri Sep 11 07:46:43 2009 +0200

winecoreaudio: Enforce invariant about BlockAlign and nAvgBytesPerSec.

---

 dlls/winecoreaudio.drv/audio.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/dlls/winecoreaudio.drv/audio.c b/dlls/winecoreaudio.drv/audio.c
index 8c42815..2873b38 100644
--- a/dlls/winecoreaudio.drv/audio.c
+++ b/dlls/winecoreaudio.drv/audio.c
@@ -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;




More information about the wine-cvs mailing list