Fix the winmm/wave tests (take 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




This time with the wavemap.c that solves the waveOutOpen problem reported by Alexandre.

* dlls/winmm/wavemap/wavemap.c,
dlls/winmm/tests/wave.c

Francois Gouget <fgouget@codeweavers.com>

Fix error reporting in wavemap.c:wodOpen()
This solves the waveOutOpen problem so that we can remove the todo_wine
Win9x does not support WAVE_FORMAT_DIRECT
Don't check the format if the waveOutOpen command failed
Use trace, not winetest_trace!

--
Francois Gouget
fgouget@codeweavers.com

Index: dlls/winmm/wavemap/wavemap.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/wavemap/wavemap.c,v
retrieving revision 1.24
diff -u -r1.24 wavemap.c
--- dlls/winmm/wavemap/wavemap.c	31 Oct 2002 00:54:27 -0000	1.24
+++ dlls/winmm/wavemap/wavemap.c	12 Dec 2002 03:13:02 -0000
@@ -217,7 +229,8 @@
     }
 
     HeapFree(GetProcessHeap(), 0, wom);
-    return MMSYSERR_ALLOCATED;
+    return WAVERR_BADFORMAT;
+
 found:
     if (dwFlags & WAVE_FORMAT_QUERY) {
 	*lpdwUser = 0L;
Index: dlls/winmm/tests/wave.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/tests/wave.c,v
retrieving revision 1.2
diff -u -r1.2 wave.c
--- dlls/winmm/tests/wave.c	10 Dec 2002 19:10:46 -0000	1.2
+++ dlls/winmm/tests/wave.c	12 Dec 2002 03:05:28 -0000
@@ -51,10 +51,9 @@
     HWAVEOUT wout;
     MMRESULT rc;
     UINT ndev,d,f;
-    int success;
 
     ndev=waveOutGetNumDevs();
-    winetest_trace("found %d WaveOut devices\n",ndev);
+    trace("found %d WaveOut devices\n",ndev);
 
     todo_wine {
         rc=waveOutGetDevCapsA(ndev+1,&caps,sizeof(caps));
@@ -75,16 +74,16 @@
 
     for (d=0;d<ndev;d++) {
         rc=waveOutGetDevCapsA(d,&caps,sizeof(caps));
-        success=(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID);
-        ok(success,"failed to get capabilities of device %d: rc=%d",d,rc);
-        if (!success)
+        ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID,
+           "failed to get capabilities of device %d: rc=%d",d,rc);
+        if (rc==MMSYSERR_BADDEVICEID)
             continue;
 
-        winetest_trace("  %d: \"%s\" %d.%d (%d:%d): channels=%d formats=%04lx support=%04lx\n",
-                       d,caps.szPname,caps.vDriverVersion >> 8,
-                       caps.vDriverVersion & 0xff,
-                       caps.wMid,caps.wPid,
-                       caps.wChannels,caps.dwFormats,caps.dwSupport);
+        trace("  %d: \"%s\" %d.%d (%d:%d): channels=%d formats=%04lx support=%04lx\n",
+              d,caps.szPname,caps.vDriverVersion >> 8,
+              caps.vDriverVersion & 0xff,
+              caps.wMid,caps.wPid,
+              caps.wChannels,caps.dwFormats,caps.dwSupport);
 
         for (f=0;f<TEST_FORMATS;f++) {
             if (!(caps.dwFormats & win_formats[f][0]))
@@ -99,9 +98,9 @@
             format.cbSize=0;
 
             rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL);
-            success=(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID);
-            ok(success, "failed to open device %d: rc=%d",d,rc);
-            if (success) {
+            ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID,
+               "failed to open device %d: rc=%d",d,rc);
+            if (rc==MMSYSERR_NOERROR) {
                 ok(format.nChannels==win_formats[f][3] &&
                    format.wBitsPerSample==win_formats[f][2] &&
                    format.nSamplesPerSec==win_formats[f][1],
@@ -109,15 +108,16 @@
                    format.nSamplesPerSec, format.wBitsPerSample,
                    format.nChannels, win_formats[f][1], win_formats[f][2],
                    win_formats[f][3]);
-            }
-            if (rc==MMSYSERR_NOERROR)
                 waveOutClose(wout);
+            }
 
-            /* Try again with WAVE_FORMAT_DIRECT */
+            /* Try again with WAVE_FORMAT_DIRECT
+             * Note: Win9x doesn't know WAVE_FORMAT_DIRECT
+             */
             rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
-            success=(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID);
-            ok(success, "failed to open device %d: rc=%d",d,rc);
-            if (success) {
+            ok(rc==MMSYSERR_NOERROR || rc==MMSYSERR_BADDEVICEID || rc==MMSYSERR_INVALFLAG,
+               "failed to open device %d: rc=%d",d,rc);
+            if (rc==MMSYSERR_NOERROR) {
                 ok(format.nChannels==win_formats[f][3] &&
                    format.wBitsPerSample==win_formats[f][2] &&
                    format.nSamplesPerSec==win_formats[f][1],
@@ -125,14 +125,12 @@
                    format.nSamplesPerSec, format.wBitsPerSample,
                    format.nChannels, win_formats[f][1], win_formats[f][2],
                    win_formats[f][3]);
-            }
-            if (rc==MMSYSERR_NOERROR)
                 waveOutClose(wout);
+            }
         }
 
-        /* Check an invalid format to test error handling */
-        todo_wine {
-        winetest_trace("Testing invalid 2MHz format\n");
+        /* Try an invalid format to test error handling */
+        trace("Testing invalid 2MHz format\n");
         format.wFormatTag=WAVE_FORMAT_PCM;
         format.nChannels=2;
         format.wBitsPerSample=16;
@@ -141,17 +139,16 @@
         format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
         format.cbSize=0;
         rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL);
-        success=(rc==WAVERR_BADFORMAT);
-        ok(success, "opening the device at 2MHz should fail %d: rc=%d",d,rc);
+        ok(rc==WAVERR_BADFORMAT,
+           "opening the device at 2MHz should fail %d: rc=%d",d,rc);
         if (rc==MMSYSERR_NOERROR) {
-            winetest_trace("     got %ldx%2dx%d for %dx%2dx%d\n",
-                           format.nSamplesPerSec, format.wBitsPerSample,
-                           format.nChannels,
-                           win_formats[f][1], win_formats[f][2],
-                           win_formats[f][3]);
+            trace("     got %ldx%2dx%d for %dx%2dx%d\n",
+                  format.nSamplesPerSec, format.wBitsPerSample,
+                  format.nChannels,
+                  win_formats[f][1], win_formats[f][2],
+                  win_formats[f][3]);
             waveOutClose(wout);
         }
-        }
 
         format.wFormatTag=WAVE_FORMAT_PCM;
         format.nChannels=2;
@@ -161,14 +158,14 @@
         format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
         format.cbSize=0;
         rc=waveOutOpen(&wout,d,&format,0,0,CALLBACK_NULL|WAVE_FORMAT_DIRECT);
-        success=(rc==WAVERR_BADFORMAT);
-        ok(success, "opening the device at 2MHz should fail %d: rc=%d",d,rc);
+        ok(rc==WAVERR_BADFORMAT || rc==MMSYSERR_INVALFLAG,
+           "opening the device at 2MHz should fail %d: rc=%d",d,rc);
         if (rc==MMSYSERR_NOERROR) {
-            winetest_trace("     got %ldx%2dx%d for %dx%2dx%d\n",
-                           format.nSamplesPerSec, format.wBitsPerSample,
-                           format.nChannels,
-                           win_formats[f][1], win_formats[f][2],
-                           win_formats[f][3]);
+            trace("     got %ldx%2dx%d for %dx%2dx%d\n",
+                  format.nSamplesPerSec, format.wBitsPerSample,
+                  format.nChannels,
+                  win_formats[f][1], win_formats[f][2],
+                  win_formats[f][3]);
             waveOutClose(wout);
         }
     }

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux