=?UTF-8?Q?J=C3=B6rg=20H=C3=B6hle=20?=: winmm: Ignore broken nBlockAlign and AvgBytes within PCMWAVEFORMAT.

Alexandre Julliard julliard at winehq.org
Fri Jan 6 15:31:36 CST 2012


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

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Wed Jan  4 09:29:55 2012 +0100

winmm: Ignore broken nBlockAlign and AvgBytes within PCMWAVEFORMAT.

---

 dlls/winmm/waveform.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/dlls/winmm/waveform.c b/dlls/winmm/waveform.c
index b940b4f..fe07e9e 100644
--- a/dlls/winmm/waveform.c
+++ b/dlls/winmm/waveform.c
@@ -843,6 +843,19 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
         passed_fmt = &fmt;
         memcpy(passed_fmt, info->format, sizeof(PCMWAVEFORMAT));
         passed_fmt->cbSize = 0;
+        if(fmt.wBitsPerSample % 8 != 0){
+            WARN("Fixing bad wBitsPerSample (%u)\n", fmt.wBitsPerSample);
+            fmt.wBitsPerSample = (fmt.wBitsPerSample + 7) & ~7;
+        }
+        /* winmm ignores broken blockalign and avgbytes */
+        if(fmt.nBlockAlign != fmt.nChannels * fmt.wBitsPerSample/8){
+            WARN("Fixing bad nBlockAlign (%u)\n", fmt.nBlockAlign);
+            fmt.nBlockAlign  = fmt.nChannels * fmt.wBitsPerSample/8;
+        }
+        if (fmt.nAvgBytesPerSec != fmt.nSamplesPerSec * fmt.nBlockAlign) {
+            WARN("Fixing bad nAvgBytesPerSec (%u)\n", fmt.nAvgBytesPerSec);
+            fmt.nAvgBytesPerSec  = fmt.nSamplesPerSec * fmt.nBlockAlign;
+        }
     }else
         passed_fmt = info->format;
 
@@ -909,8 +922,8 @@ static LRESULT WINMM_OpenDevice(WINMM_Device *device, WINMM_MMDevice *mmdevice,
         goto error;
     }
 
-    device->bytes_per_frame = info->format->nBlockAlign;
-    device->samples_per_sec = info->format->nSamplesPerSec;
+    device->bytes_per_frame = passed_fmt->nBlockAlign;
+    device->samples_per_sec = passed_fmt->nSamplesPerSec;
 
     device->played_frames = 0;
     device->last_clock_pos = 0;




More information about the wine-cvs mailing list