Robert Reif : winmm: Always check for open and close enents in wave
test.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed May 31 05:31:31 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 2b3247a4243eaa5a75448ab446a37af4b7e952f4
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=2b3247a4243eaa5a75448ab446a37af4b7e952f4
Author: Robert Reif <reif at earthlink.net>
Date: Tue May 30 18:14:18 2006 -0400
winmm: Always check for open and close enents in wave test.
Always check for open and close events.
Send WM_APP message to thread to terminate it rather than TerminateThread.
Fix CreateThread/waveOutOpen race by waiting for background thread to
run 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.
---
dlls/winmm/tests/wave.c | 35 ++++++++++++++++++++++-------------
dlls/winmm/tests/winmm_test.h | 3 +++
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/dlls/winmm/tests/wave.c b/dlls/winmm/tests/wave.c
index f2972f0..3019472 100644
--- a/dlls/winmm/tests/wave.c
+++ b/dlls/winmm/tests/wave.c
@@ -535,14 +535,20 @@ static DWORD WINAPI callback_thread(LPVO
{
MSG msg;
+ SetEvent((HANDLE)lpParameter);
+
while (GetMessage(&msg, 0, 0, 0)) {
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 +562,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,7 +574,8 @@ static void wave_out_test_deviceOut(int
DWORD callback = 0;
DWORD callback_instance = 0;
HANDLE thread = 0;
- BYTE * buffer;
+ DWORD thread_id;
+ char * buffer;
DWORD length;
DWORD frag_length;
int i, j;
@@ -585,9 +592,10 @@ 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) {
+ /* make sure thread is running */
+ WaitForSingleObject(hevent,INFINITE);
callback = thread_id;
callback_instance = 0;
} else {
@@ -636,12 +644,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 +705,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 +784,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);
}
diff --git a/dlls/winmm/tests/winmm_test.h b/dlls/winmm/tests/winmm_test.h
index e6c0242..177dc2e 100644
--- a/dlls/winmm/tests/winmm_test.h
+++ b/dlls/winmm/tests/winmm_test.h
@@ -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-cvs
mailing list