winmm/tests: Don't test upper bound on sound duration, it's not guaranteed.

Also avoid infinite waits.
This commit is contained in:
Alexandre Julliard 2009-02-11 14:49:43 +01:00
parent b03175e126
commit 3c68ba1bad
1 changed files with 12 additions and 14 deletions

View File

@ -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);