Commit 342d59f2 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Fix a race condition where result could be read before set.

Fix test to use correct event in interactive mode.
parent 03bb9b11
...@@ -371,6 +371,7 @@ static void wave_in_test_deviceIn(int device, int format, DWORD flags) ...@@ -371,6 +371,7 @@ static void wave_in_test_deviceIn(int device, int format, DWORD flags)
HANDLE hevent; HANDLE hevent;
WAVEHDR frag; WAVEHDR frag;
MMRESULT rc; MMRESULT rc;
DWORD res;
hevent=CreateEvent(NULL,FALSE,FALSE,NULL); hevent=CreateEvent(NULL,FALSE,FALSE,NULL);
ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError()); ok(hevent!=NULL,"CreateEvent: error=%ld\n",GetLastError());
...@@ -397,6 +398,8 @@ static void wave_in_test_deviceIn(int device, int format, DWORD flags) ...@@ -397,6 +398,8 @@ static void wave_in_test_deviceIn(int device, int format, DWORD flags)
CloseHandle(hevent); CloseHandle(hevent);
return; return;
} }
res=WaitForSingleObject(hevent,1000);
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for open\n");
ok(wfx.nChannels==win_formats[format][3] && ok(wfx.nChannels==win_formats[format][3] &&
wfx.wBitsPerSample==win_formats[format][2] && wfx.wBitsPerSample==win_formats[format][2] &&
...@@ -423,16 +426,23 @@ static void wave_in_test_deviceIn(int device, int format, DWORD flags) ...@@ -423,16 +426,23 @@ static void wave_in_test_deviceIn(int device, int format, DWORD flags)
rc=waveInStart(win); rc=waveInStart(win);
ok(rc==MMSYSERR_NOERROR,"waveInStart: device=%d rc=%d\n",device,rc); ok(rc==MMSYSERR_NOERROR,"waveInStart: device=%d rc=%d\n",device,rc);
WaitForSingleObject(hevent,INFINITE); res = WaitForSingleObject(hevent,1200);
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for header\n");
ok(frag.dwFlags&WHDR_DONE,"WHDR_DONE no set in frag.dwFlags\n");
ok(frag.dwBytesRecorded==wfx.nAvgBytesPerSec,"frag.dwBytesRecorded=%ld, should=%ld\n",
frag.dwBytesRecorded,wfx.nAvgBytesPerSec);
} }
rc=waveInUnprepareHeader(win, &frag, sizeof(frag)); rc=waveInUnprepareHeader(win, &frag, sizeof(frag));
ok(rc==MMSYSERR_NOERROR, ok(rc==MMSYSERR_NOERROR,
"waveInUnprepareHeader: device=%d rc=%d\n",device,rc); "waveInUnprepareHeader: device=%d rc=%d\n",device,rc);
waveInClose(win);
res=WaitForSingleObject(hevent,1000);
ok(res==WAIT_OBJECT_0,"WaitForSingleObject failed for close\n");
free(frag.lpData); free(frag.lpData);
CloseHandle(hevent); CloseHandle(hevent);
waveInClose(win);
} }
static void wave_in_tests() static void wave_in_tests()
......
...@@ -2717,9 +2717,10 @@ static DWORD CALLBACK widRecorder(LPVOID pmt) ...@@ -2717,9 +2717,10 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
lpWaveHdr->dwFlags &= ~WHDR_INQUEUE; lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
lpWaveHdr->dwFlags |= WHDR_DONE; lpWaveHdr->dwFlags |= WHDR_DONE;
wwi->lpQueuePtr = lpNext;
widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0); widNotifyClient(wwi, WIM_DATA, (DWORD)lpWaveHdr, 0);
wwi->lpQueuePtr = lpWaveHdr = lpNext; lpWaveHdr = lpNext;
if (!lpNext && bytesRead) { if (!lpNext && bytesRead) {
/* before we give up, check for more header messages */ /* before we give up, check for more header messages */
while (OSS_PeekRingMessage(&wwi->msgRing, &msg, &param, &ev)) while (OSS_PeekRingMessage(&wwi->msgRing, &msg, &param, &ev))
......
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