Alexandre Julliard : winmm/tests: Don't test upper bound on sound duration, it's not guaranteed.
Alexandre Julliard
julliard at winehq.org
Wed Feb 11 09:25:45 CST 2009
Module: wine
Branch: master
Commit: 3c68ba1bad8f0a3e02bb1f93267713ecfc5c4bdf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3c68ba1bad8f0a3e02bb1f93267713ecfc5c4bdf
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Feb 11 14:49:43 2009 +0100
winmm/tests: Don't test upper bound on sound duration, it's not guaranteed.
Also avoid infinite waits.
---
dlls/winmm/tests/wave.c | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/dlls/winmm/tests/wave.c b/dlls/winmm/tests/wave.c
index 22ada89..37685ed 100644
--- a/dlls/winmm/tests/wave.c
+++ b/dlls/winmm/tests/wave.c
@@ -603,7 +603,7 @@ static void wave_out_test_deviceOut(int device, double duration,
DWORD nSamplesPerSec = pwfx->nSamplesPerSec;
BOOL has_volume = pcaps->dwSupport & WAVECAPS_VOLUME ? TRUE : FALSE;
double paused = 0.0;
- double actual;
+ DWORD actual;
DWORD_PTR callback = 0;
DWORD_PTR callback_instance = 0;
HANDLE thread = 0;
@@ -628,7 +628,7 @@ static void wave_out_test_deviceOut(int device, double duration,
thread = CreateThread(NULL, 0, callback_thread, hevent, 0, &thread_id);
if (thread) {
/* make sure thread is running */
- WaitForSingleObject(hevent,INFINITE);
+ WaitForSingleObject(hevent,10000);
callback = thread_id;
callback_instance = 0;
} else {
@@ -680,7 +680,7 @@ static void wave_out_test_deviceOut(int device, double duration,
if (rc!=MMSYSERR_NOERROR)
goto EXIT;
- WaitForSingleObject(hevent,INFINITE);
+ WaitForSingleObject(hevent,10000);
ok(pwfx->nChannels==nChannels &&
pwfx->wBitsPerSample==wBitsPerSample &&
@@ -785,19 +785,17 @@ static void wave_out_test_deviceOut(int device, double duration,
ok(rc==MMSYSERR_NOERROR,"waveOutWrite(%s, header[%d]): rc=%s\n",
dev_name(device),(i+1)%headers,wave_out_error(rc));
}
- WaitForSingleObject(hevent,INFINITE);
+ WaitForSingleObject(hevent,10000);
}
}
- /* Check the sound duration was between -10% and +35% of the expected value */
+ /* Check the sound duration was at least 90% of the expected value */
end=GetTickCount();
- actual = (end - start) / 1000.0;
- if (winetest_debug > 1)
- trace("sound duration=%g ms\n",1000*actual);
- ok((actual > (0.9 * (duration+paused))) &&
- (actual < (1.35 * (duration+paused))),
- "The sound played for %g ms instead of %g ms\n",
- 1000*actual,1000*(duration+paused));
+ actual = end - start;
+ trace("sound duration=%u ms\n",actual);
+ ok(actual > 900 * (duration+paused),
+ "The sound played for %u ms instead of %g ms\n",
+ actual,1000*(duration+paused));
for (i = 0; i < headers; i++) {
ok(frags[i].dwFlags=(WHDR_DONE|WHDR_PREPARED),
"WHDR_DONE WHDR_PREPARED expected, got %s\n",
@@ -817,11 +815,11 @@ static void wave_out_test_deviceOut(int device, double duration,
rc=waveOutClose(wout);
ok(rc==MMSYSERR_NOERROR,"waveOutClose(%s): rc=%s\n",dev_name(device),
wave_out_error(rc));
- WaitForSingleObject(hevent,INFINITE);
+ WaitForSingleObject(hevent,10000);
EXIT:
if ((flags & CALLBACK_TYPEMASK) == CALLBACK_THREAD) {
PostThreadMessage(thread_id, WM_APP, 0, 0);
- WaitForSingleObject(hevent,INFINITE);
+ WaitForSingleObject(hevent,10000);
}
CloseHandle(hevent);
HeapFree(GetProcessHeap(), 0, frags);
More information about the wine-cvs
mailing list