[WINMM] always check for open and close enents in wave test

Robert Reif reif at earthlink.net
Tue May 30 06:46:11 CDT 2006


Always check for open and close events.
Send WM_APP message to thread to terminate it rather than TerminateThread.
Fix CreateThread/waveOutOpen race by forcing parent thread to sleep 
which allows background thread to run and block before waveOutOpen is 
called.
Add more non-hardware supported formats.  There is a bug in wave mapper 
GetPosition when multiple headers are used and this helps trigger it.
-------------- next part --------------
Index: dlls/winmm/tests/wave.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/tests/wave.c,v
retrieving revision 1.60
diff -p -u -r1.60 wave.c
--- dlls/winmm/tests/wave.c	30 May 2006 10:57:40 -0000	1.60
+++ dlls/winmm/tests/wave.c	30 May 2006 11:27:41 -0000
@@ -539,10 +539,14 @@ static DWORD WINAPI callback_thread(LPVO
         UINT message = msg.message;
         /* for some reason XP sends a WM_USER message before WOM_OPEN */
         ok (message == WOM_OPEN || message == WOM_DONE ||
-            message == WOM_CLOSE || message == WM_USER,
+            message == WOM_CLOSE || message == WM_USER || message == WM_APP,
             "GetMessage returned unexpected message: %u\n", message);
         if (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE)
             SetEvent((HANDLE)lpParameter);
+        else if (message == WM_APP) {
+            SetEvent((HANDLE)lpParameter);
+            return 0;
+        }
     }
 
     return 0;
@@ -556,7 +560,7 @@ static void wave_out_test_deviceOut(int 
 {
     HWAVEOUT wout;
     HANDLE hevent;
-    WAVEHDR *frags;
+    WAVEHDR *frags = 0;
     MMRESULT rc;
     DWORD volume;
     WORD nChannels = pwfx->nChannels;
@@ -568,6 +572,7 @@ static void wave_out_test_deviceOut(int 
     DWORD callback = 0;
     DWORD callback_instance = 0;
     HANDLE thread = 0;
+    DWORD thread_id;
     BYTE * buffer;
     DWORD length;
     DWORD frag_length;
@@ -585,9 +590,9 @@ static void wave_out_test_deviceOut(int 
         callback = (DWORD)callback_func;
         callback_instance = (DWORD)hevent;
     } else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
-        DWORD thread_id;
         thread = CreateThread(NULL, 0, callback_thread, hevent, 0, &thread_id);
         if (thread) {
+            Sleep(1);   /* make sure thread is running */
             callback = thread_id;
             callback_instance = 0;
         } else {
@@ -636,12 +641,10 @@ static void wave_out_test_deviceOut(int 
               pwfx->wBitsPerSample,pwfx->nChannels,
               flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
               flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
-    if (rc!=MMSYSERR_NOERROR) {
-        if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD)
-            TerminateThread(thread, 0);
-        CloseHandle(hevent);
-        return;
-    }
+    if (rc!=MMSYSERR_NOERROR)
+        goto EXIT;
+
+    WaitForSingleObject(hevent,INFINITE);
 
     ok(pwfx->nChannels==nChannels &&
        pwfx->wBitsPerSample==wBitsPerSample &&
@@ -699,7 +702,6 @@ static void wave_out_test_deviceOut(int 
         rc=waveOutSetVolume(wout,0x20002000);
         ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
            "waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
-        WaitForSingleObject(hevent,INFINITE);
 
         rc=waveOutSetVolume(wout,volume);
         ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
@@ -779,8 +781,12 @@ static void wave_out_test_deviceOut(int 
     rc=waveOutClose(wout);
     ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
        wave_out_error(rc));
-    if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD)
-        TerminateThread(thread, 0);
+    WaitForSingleObject(hevent,INFINITE);
+EXIT:
+    if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
+        PostThreadMessage(thread_id, WM_APP, 0, 0);
+        WaitForSingleObject(hevent,INFINITE);
+    }
     CloseHandle(hevent);
     free(frags);
 }
Index: dlls/winmm/tests/winmm_test.h
===================================================================
RCS file: /home/wine/wine/dlls/winmm/tests/winmm_test.h,v
retrieving revision 1.10
diff -p -u -r1.10 winmm_test.h
--- dlls/winmm/tests/winmm_test.h	23 May 2006 12:48:57 -0000	1.10
+++ dlls/winmm/tests/winmm_test.h	30 May 2006 11:27:41 -0000
@@ -43,6 +43,9 @@ static const unsigned int win_formats[][
     {WAVE_FORMAT_1S08,  11025,  8, 2},
     {WAVE_FORMAT_1M16,  11025, 16, 1},
     {WAVE_FORMAT_1S16,  11025, 16, 2},
+    {0,                 12000,  8, 1},
+    {0,                 12000,  8, 2},
+    {0,                 12000, 16, 1},
     {0,                 12000, 16, 2},
     {0,                 16000,  8, 1},
     {0,                 16000,  8, 2},


More information about the wine-patches mailing list