Commit 2b3247a4 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

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.
parent 15c0db36
...@@ -535,14 +535,20 @@ static DWORD WINAPI callback_thread(LPVOID lpParameter) ...@@ -535,14 +535,20 @@ static DWORD WINAPI callback_thread(LPVOID lpParameter)
{ {
MSG msg; MSG msg;
SetEvent((HANDLE)lpParameter);
while (GetMessage(&msg, 0, 0, 0)) { while (GetMessage(&msg, 0, 0, 0)) {
UINT message = msg.message; UINT message = msg.message;
/* for some reason XP sends a WM_USER message before WOM_OPEN */ /* for some reason XP sends a WM_USER message before WOM_OPEN */
ok (message == WOM_OPEN || message == WOM_DONE || 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); "GetMessage returned unexpected message: %u\n", message);
if (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE) if (message == WOM_OPEN || message == WOM_DONE || message == WOM_CLOSE)
SetEvent((HANDLE)lpParameter); SetEvent((HANDLE)lpParameter);
else if (message == WM_APP) {
SetEvent((HANDLE)lpParameter);
return 0;
}
} }
return 0; return 0;
...@@ -556,7 +562,7 @@ static void wave_out_test_deviceOut(int device, double duration, ...@@ -556,7 +562,7 @@ static void wave_out_test_deviceOut(int device, double duration,
{ {
HWAVEOUT wout; HWAVEOUT wout;
HANDLE hevent; HANDLE hevent;
WAVEHDR *frags; WAVEHDR *frags = 0;
MMRESULT rc; MMRESULT rc;
DWORD volume; DWORD volume;
WORD nChannels = pwfx->nChannels; WORD nChannels = pwfx->nChannels;
...@@ -568,7 +574,8 @@ static void wave_out_test_deviceOut(int device, double duration, ...@@ -568,7 +574,8 @@ static void wave_out_test_deviceOut(int device, double duration,
DWORD callback = 0; DWORD callback = 0;
DWORD callback_instance = 0; DWORD callback_instance = 0;
HANDLE thread = 0; HANDLE thread = 0;
BYTE * buffer; DWORD thread_id;
char * buffer;
DWORD length; DWORD length;
DWORD frag_length; DWORD frag_length;
int i, j; int i, j;
...@@ -585,9 +592,10 @@ static void wave_out_test_deviceOut(int device, double duration, ...@@ -585,9 +592,10 @@ static void wave_out_test_deviceOut(int device, double duration,
callback = (DWORD)callback_func; callback = (DWORD)callback_func;
callback_instance = (DWORD)hevent; callback_instance = (DWORD)hevent;
} else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) { } else if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
DWORD thread_id;
thread = CreateThread(NULL, 0, callback_thread, hevent, 0, &thread_id); thread = CreateThread(NULL, 0, callback_thread, hevent, 0, &thread_id);
if (thread) { if (thread) {
/* make sure thread is running */
WaitForSingleObject(hevent,INFINITE);
callback = thread_id; callback = thread_id;
callback_instance = 0; callback_instance = 0;
} else { } else {
...@@ -636,12 +644,10 @@ static void wave_out_test_deviceOut(int device, double duration, ...@@ -636,12 +644,10 @@ static void wave_out_test_deviceOut(int device, double duration,
pwfx->wBitsPerSample,pwfx->nChannels, pwfx->wBitsPerSample,pwfx->nChannels,
flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" : flags & WAVE_FORMAT_DIRECT ? "flags=WAVE_FORMAT_DIRECT" :
flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc)); flags & WAVE_MAPPED ? "flags=WAVE_MAPPED" : "", mmsys_error(rc));
if (rc!=MMSYSERR_NOERROR) { if (rc!=MMSYSERR_NOERROR)
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) goto EXIT;
TerminateThread(thread, 0);
CloseHandle(hevent); WaitForSingleObject(hevent,INFINITE);
return;
}
ok(pwfx->nChannels==nChannels && ok(pwfx->nChannels==nChannels &&
pwfx->wBitsPerSample==wBitsPerSample && pwfx->wBitsPerSample==wBitsPerSample &&
...@@ -699,7 +705,6 @@ static void wave_out_test_deviceOut(int device, double duration, ...@@ -699,7 +705,6 @@ static void wave_out_test_deviceOut(int device, double duration,
rc=waveOutSetVolume(wout,0x20002000); rc=waveOutSetVolume(wout,0x20002000);
ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED, ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
"waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc)); "waveOutSetVolume(%s): rc=%s\n",dev_name(device),wave_out_error(rc));
WaitForSingleObject(hevent,INFINITE);
rc=waveOutSetVolume(wout,volume); rc=waveOutSetVolume(wout,volume);
ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED, ok(has_volume ? rc==MMSYSERR_NOERROR : rc==MMSYSERR_NOTSUPPORTED,
...@@ -779,8 +784,12 @@ static void wave_out_test_deviceOut(int device, double duration, ...@@ -779,8 +784,12 @@ static void wave_out_test_deviceOut(int device, double duration,
rc=waveOutClose(wout); rc=waveOutClose(wout);
ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device), ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
wave_out_error(rc)); wave_out_error(rc));
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) WaitForSingleObject(hevent,INFINITE);
TerminateThread(thread, 0); EXIT:
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
PostThreadMessage(thread_id, WM_APP, 0, 0);
WaitForSingleObject(hevent,INFINITE);
}
CloseHandle(hevent); CloseHandle(hevent);
free(frags); free(frags);
} }
......
...@@ -43,6 +43,9 @@ static const unsigned int win_formats[][4] = { ...@@ -43,6 +43,9 @@ static const unsigned int win_formats[][4] = {
{WAVE_FORMAT_1S08, 11025, 8, 2}, {WAVE_FORMAT_1S08, 11025, 8, 2},
{WAVE_FORMAT_1M16, 11025, 16, 1}, {WAVE_FORMAT_1M16, 11025, 16, 1},
{WAVE_FORMAT_1S16, 11025, 16, 2}, {WAVE_FORMAT_1S16, 11025, 16, 2},
{0, 12000, 8, 1},
{0, 12000, 8, 2},
{0, 12000, 16, 1},
{0, 12000, 16, 2}, {0, 12000, 16, 2},
{0, 16000, 8, 1}, {0, 16000, 8, 1},
{0, 16000, 8, 2}, {0, 16000, 8, 2},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment