dsound tests and winealsa patch

Robert Reif reif at earthlink.net
Mon Apr 26 20:58:53 CDT 2004


I hate to see a valid test removed because it fails on
windows and wine because of buggy drivers.  We can't
fix windows but we can fix wine.

This patch restores the 2 MHz sample rate test and
fixes the winealsa driver for reasonable limits.

There are several windows audio driver models but at
least one gets it's wave device limits from the direct sound
device limits so this isn't an unreasonable limit.
-------------- next part --------------
Index: dlls/winmm/tests/wave.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/tests/wave.c,v
retrieving revision 1.17
diff -u -r1.17 wave.c
--- dlls/winmm/tests/wave.c	26 Apr 2004 23:30:26 -0000	1.17
+++ dlls/winmm/tests/wave.c	27 Apr 2004 01:40:16 -0000
@@ -324,12 +324,12 @@
             }
         }
 
-        /* Try an invalid format to test error handling */
-        trace("Testing invalid format\n");
+        /* Try invalid formats to test error handling */
+        trace("Testing invalid format: 11 bits per sample\n");
         format.wFormatTag=WAVE_FORMAT_PCM;
         format.nChannels=2;
         format.wBitsPerSample=11;
-        format.nSamplesPerSec=8000;
+        format.nSamplesPerSec=22050;
         format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
         format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
         format.cbSize=0;
@@ -345,6 +345,27 @@
                   oformat.nChannels);
             waveOutClose(wout);
         }
+
+        trace("Testing invalid format: 2 MHz sample rate\n");
+        format.wFormatTag=WAVE_FORMAT_PCM;
+        format.nChannels=2;
+        format.wBitsPerSample=16;
+        format.nSamplesPerSec=2000000;
+        format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
+        format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
+        format.cbSize=0;
+        oformat=format;
+        rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
+        ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG,
+           "waveOutOpen: opening the device at 2 MHz sample rate should fail %d: rc=%d\n",d,rc);
+        if (rc==MMSYSERR_NOERROR) {
+            trace("     got %ldx%2dx%d for %ldx%2dx%d\n",
+                  format.nSamplesPerSec, format.wBitsPerSample,
+                  format.nChannels,
+                  oformat.nSamplesPerSec, oformat.wBitsPerSample,
+                  oformat.nChannels);
+            waveOutClose(wout);
+        }
     }
 }
 
@@ -525,12 +546,12 @@
             }
         }
 
-        /* Try an invalid format to test error handling */
-        trace("Testing invalid format\n");
+        /* Try invalid formats to test error handling */
+        trace("Testing invalid format: 11 bits per sample\n");
         format.wFormatTag=WAVE_FORMAT_PCM;
         format.nChannels=2;
         format.wBitsPerSample=11;
-        format.nSamplesPerSec=8000;
+        format.nSamplesPerSec=22050;
         format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
         format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
         format.cbSize=0;
@@ -538,6 +559,27 @@
         rc=waveInOpen(&win,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
         ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG,
            "waveInOpen: opening the device in 11 bit mode should fail %d: rc=%d\n",d,rc);
+        if (rc==MMSYSERR_NOERROR) {
+            trace("     got %ldx%2dx%d for %ldx%2dx%d\n",
+                  format.nSamplesPerSec, format.wBitsPerSample,
+                  format.nChannels,
+                  oformat.nSamplesPerSec, oformat.wBitsPerSample,
+                  oformat.nChannels);
+            waveInClose(win);
+        }
+
+        trace("Testing invalid format: 2 MHz sample rate\n");
+        format.wFormatTag=WAVE_FORMAT_PCM;
+        format.nChannels=2;
+        format.wBitsPerSample=16;
+        format.nSamplesPerSec=2000000;
+        format.nBlockAlign=format.nChannels*format.wBitsPerSample/8;
+        format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
+        format.cbSize=0;
+        oformat=format;
+        rc=waveInOpen(&win,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
+        ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG,
+           "waveInOpen: opening the device with 2 MHz sample rate should fail %d: rc=%d\n",d,rc);
         if (rc==MMSYSERR_NOERROR) {
             trace("     got %ldx%2dx%d for %ldx%2dx%d\n",
                   format.nSamplesPerSec, format.wBitsPerSample,
Index: dlls/winmm/winealsa/audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/winealsa/audio.c,v
retrieving revision 1.38
diff -u -r1.38 audio.c
--- dlls/winmm/winealsa/audio.c	26 Apr 2004 23:31:11 -0000	1.38
+++ dlls/winmm/winealsa/audio.c	27 Apr 2004 01:40:19 -0000
@@ -1438,7 +1438,8 @@
     /* only PCM format is supported so far... */
     if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM ||
 	lpDesc->lpFormat->nChannels == 0 ||
-	lpDesc->lpFormat->nSamplesPerSec == 0 ||
+	lpDesc->lpFormat->nSamplesPerSec < DSBFREQUENCY_MIN ||
+	lpDesc->lpFormat->nSamplesPerSec > DSBFREQUENCY_MAX ||
         (lpDesc->lpFormat->wBitsPerSample!=8 && lpDesc->lpFormat->wBitsPerSample!=16)) {
 	WARN("Bad format: tag=%04X nChannels=%d nSamplesPerSec=%ld !\n",
 	     lpDesc->lpFormat->wFormatTag, lpDesc->lpFormat->nChannels,


More information about the wine-patches mailing list