Commit ba340e74 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

mmdevapi/tests: Avoid race condition in capture test.

These tests depended on no data being put into the buffer between calls to Start() and GetBuffer(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47876Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9023c5a6
...@@ -95,45 +95,6 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) ...@@ -95,45 +95,6 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
if (hr != S_OK) if (hr != S_OK)
return; return;
frames = 0xabadcafe;
data = (void*)0xdeadf00d;
flags = 0xabadcafe;
pos = qpc = 0xdeadbeef;
hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
ok(hr == AUDCLNT_S_BUFFER_EMPTY, "Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr);
/* should be empty right after start. Otherwise consume one packet */
if(hr == S_OK){
hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
sum += frames;
frames = 0xabadcafe;
data = (void*)0xdeadf00d;
flags = 0xabadcafe;
pos = qpc = 0xdeadbeef;
hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
ok(hr == AUDCLNT_S_BUFFER_EMPTY, "Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr);
}
if(hr == AUDCLNT_S_BUFFER_EMPTY){
ok(!frames, "frames changed to %u\n", frames);
ok(data == (void*)0xdeadf00d, "data changed to %p\n", data);
ok(flags == 0xabadcafe, "flags changed to %x\n", flags);
ok(pos == 0xdeadbeef, "position changed to %u\n", (UINT)pos);
ok(qpc == 0xdeadbeef, "timer changed to %u\n", (UINT)qpc);
/* GetNextPacketSize yields 0 if no data is yet available
* it is not constantly period_size * SamplesPerSec */
hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08x\n", hr);
ok(!next, "GetNextPacketSize %u\n", next);
}
hr = IAudioCaptureClient_ReleaseBuffer(acc, frames);
ok(hr == S_OK, "Releasing buffer returns %08x\n", hr);
sum += frames;
ok(ResetEvent(handle), "ResetEvent\n"); ok(ResetEvent(handle), "ResetEvent\n");
hr = IAudioCaptureClient_GetNextPacketSize(acc, &next); hr = IAudioCaptureClient_GetNextPacketSize(acc, &next);
...@@ -169,6 +130,9 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) ...@@ -169,6 +130,9 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
ok(hr == S_OK, "GetDevicePeriod failed: %08x\n", hr); ok(hr == S_OK, "GetDevicePeriod failed: %08x\n", hr);
period = MulDiv(period, wfx->nSamplesPerSec, 10000000); /* as in render.c */ period = MulDiv(period, wfx->nSamplesPerSec, 10000000); /* as in render.c */
hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
ok(WaitForSingleObject(handle, 1000) == WAIT_OBJECT_0, "Waiting on event handle failed!\n"); ok(WaitForSingleObject(handle, 1000) == WAIT_OBJECT_0, "Waiting on event handle failed!\n");
data = (void*)0xdeadf00d; data = (void*)0xdeadf00d;
...@@ -375,37 +339,25 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) ...@@ -375,37 +339,25 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
ok(hr == S_OK, "Reset on a stopped stream returns %08x\n", hr); ok(hr == S_OK, "Reset on a stopped stream returns %08x\n", hr);
sum += pad - frames; sum += pad - frames;
hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
hr = IAudioClient_GetCurrentPadding(ac, &pad); hr = IAudioClient_GetCurrentPadding(ac, &pad);
ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr); ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
ok(!pad, "reset GCP %u\n", pad);
flags = 0xabadcafe; flags = 0xabadcafe;
hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc); hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc);
ok(hr == AUDCLNT_S_BUFFER_EMPTY || /*PulseAudio*/hr == S_OK, ok(hr == AUDCLNT_S_BUFFER_EMPTY,
"Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr); "Initial IAudioCaptureClient_GetBuffer returns %08x\n", hr);
trace("Reset position %d pad %u flags %x, amount of frames locked: %u\n", trace("Reset position %d pad %u flags %x, amount of frames locked: %u\n",
hr==S_OK ? (UINT)pos : -1, pad, flags, frames); hr==S_OK ? (UINT)pos : -1, pad, flags, frames);
if(hr == S_OK){ if(SUCCEEDED(hr))
/* Only PulseAudio goes here; despite snd_pcm_drop it manages IAudioCaptureClient_ReleaseBuffer(acc, frames);
* to fill GetBufferSize with a single snd_pcm_read */
trace("Test marked todo: only PulseAudio gets here\n");
todo_wine ok(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY, "expect DISCONTINUITY %x\n", flags);
/* Reset zeroes padding, not the position */
ok(pos >= sum, "Position %u last %u\n", (UINT)pos, sum);
/*sum = pos; check after next GetBuffer */
hr = IAudioCaptureClient_ReleaseBuffer(acc, frames); hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Releasing buffer returns %08x\n", hr); ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
sum += frames;
} Sleep(180);
else if(hr == AUDCLNT_S_BUFFER_EMPTY){
ok(!pad, "reset GCP %u\n", pad);
Sleep(180);
}
hr = IAudioClient_GetCurrentPadding(ac, &pad); hr = IAudioClient_GetCurrentPadding(ac, &pad);
ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr); ok(hr == S_OK, "GetCurrentPadding call returns %08x\n", hr);
...@@ -583,9 +535,6 @@ static void test_audioclient(void) ...@@ -583,9 +535,6 @@ static void test_audioclient(void)
hr = IAudioClient_Stop(ac); hr = IAudioClient_Stop(ac);
ok(hr == S_FALSE, "Stop on a stopped stream returns %08x\n", hr); ok(hr == S_FALSE, "Stop on a stopped stream returns %08x\n", hr);
hr = IAudioClient_Start(ac);
ok(hr == S_OK, "Start on a stopped stream returns %08x\n", hr);
test_capture(ac, handle, pwfx); test_capture(ac, handle, pwfx);
cleanup: cleanup:
......
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