From: Giovanni Mascellani gmascellani@codeweavers.com
Which already does the same tests and many more. --- dlls/mmdevapi/tests/capture.c | 40 +++++------------------------------ 1 file changed, 5 insertions(+), 35 deletions(-)
diff --git a/dlls/mmdevapi/tests/capture.c b/dlls/mmdevapi/tests/capture.c index 3baa0331dc8..460d9cfd910 100644 --- a/dlls/mmdevapi/tests/capture.c +++ b/dlls/mmdevapi/tests/capture.c @@ -292,45 +292,15 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) hr = IAudioClient_Start(ac); ok(hr == S_OK, "Start on a stopped stream returns %08lx\n", hr);
- ok(WaitForSingleObject(handle, 1000) == WAIT_OBJECT_0, "Waiting on event handle failed!\n"); + packets_data.expected_dev_pos = UINT64_MAX;
- data = (void*)0xdeadf00d; - hr = IAudioCaptureClient_GetBuffer(acc, &data, &frames, &flags, &pos, &qpc); - ok(hr == S_OK || hr == AUDCLNT_S_BUFFER_EMPTY, "Valid IAudioCaptureClient_GetBuffer returns %08lx\n", hr); - if (hr == S_OK){ - ok(frames, "Amount of frames locked is 0!\n"); - /* broken: some w7 machines return pad == 0 and DATA_DISCONTINUITY here, - * AUDCLNT_S_BUFFER_EMPTY above, yet pos == 1-2 * period rather than 0 */ - ok(pos == sum || broken(flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY), - "Position %u expected %u\n", (UINT)pos, sum); - sum = pos; - }else if (hr == AUDCLNT_S_BUFFER_EMPTY){ - ok(!frames, "Amount of frames locked with empty buffer is %u!\n", frames); - ok(broken(data == (void*)0xdeadf00d) || /* <= win8 */ - data == NULL, "No data changed to %p\n", data); - } - - trace("Wait'ed position %d pad %u flags %lx, amount of frames locked: %u\n", - hr==S_OK ? (UINT)pos : -1, pad, flags, frames); + winetest_push_context("read 10 packets");
- hr = IAudioCaptureClient_GetNextPacketSize(acc, &next); - ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08lx\n", hr); - ok(next == frames, "GetNextPacketSize %u vs. GetBuffer %u\n", next, frames); - - hr = IAudioCaptureClient_ReleaseBuffer(acc, frames); - ok(hr == S_OK, "Releasing buffer returns %08lx\n", hr); - - hr = IAudioCaptureClient_ReleaseBuffer(acc, 0); - ok(hr == S_OK, "Releasing 0 returns %08lx\n", hr); + read_packets(ac, acc, handle, 10, &packets_data);
- hr = IAudioCaptureClient_GetNextPacketSize(acc, &next); - ok(hr == S_OK, "IAudioCaptureClient_GetNextPacketSize returns %08lx\n", hr); + winetest_pop_context();
- if (frames) { - hr = IAudioCaptureClient_ReleaseBuffer(acc, frames); - ok(hr == AUDCLNT_E_OUT_OF_ORDER, "Releasing buffer twice returns %08lx\n", hr); - sum += frames; - } + sum = packets_data.expected_dev_pos;
Sleep(350); /* for sure there's data now */
From: Giovanni Mascellani gmascellani@codeweavers.com
--- dlls/mmdevapi/tests/capture.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/dlls/mmdevapi/tests/capture.c b/dlls/mmdevapi/tests/capture.c index 460d9cfd910..ea72efd9105 100644 --- a/dlls/mmdevapi/tests/capture.c +++ b/dlls/mmdevapi/tests/capture.c @@ -110,6 +110,8 @@ static void test_uninitialized(IAudioClient *ac) struct read_packets_data { UINT64 expected_dev_pos; + BOOL discontinuity_at_0; + BOOL discontinuity_at_later; };
static void read_packets(IAudioClient *ac, IAudioCaptureClient *acc, HANDLE handle, @@ -118,6 +120,9 @@ static void read_packets(IAudioClient *ac, IAudioCaptureClient *acc, HANDLE hand unsigned int idx = 0; HRESULT hr;
+ data->discontinuity_at_0 = FALSE; + data->discontinuity_at_later = FALSE; + while (idx < packet_count) { UINT32 next_packet_size, frames, frames2, padding; @@ -168,6 +173,14 @@ static void read_packets(IAudioClient *ac, IAudioCaptureClient *acc, HANDLE hand ok(padding >= frames, "GetCurrentPadding returns %u, GetBuffer returns %u frames\n", padding, frames);
+ if (flags & AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) + { + if (idx == 0) + data->discontinuity_at_0 = TRUE; + else + data->discontinuity_at_later = TRUE; + } + if (data->expected_dev_pos != UINT64_MAX) { /* Win <= 8 and some older Win 10 builds sometimes handle discontinuities incorrectly. */ @@ -298,6 +311,10 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
read_packets(ac, acc, handle, 10, &packets_data);
+ todo_wine + ok(packets_data.discontinuity_at_0, "No discontinuity at first packet\n"); + ok(!packets_data.discontinuity_at_later, "Discontinuity at later packet\n"); + winetest_pop_context();
sum = packets_data.expected_dev_pos;
From: Giovanni Mascellani gmascellani@codeweavers.com
--- dlls/mmdevapi/tests/capture.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/mmdevapi/tests/capture.c b/dlls/mmdevapi/tests/capture.c index ea72efd9105..e67810cb83d 100644 --- a/dlls/mmdevapi/tests/capture.c +++ b/dlls/mmdevapi/tests/capture.c @@ -110,6 +110,7 @@ static void test_uninitialized(IAudioClient *ac) struct read_packets_data { UINT64 expected_dev_pos; + UINT32 period; BOOL discontinuity_at_0; BOOL discontinuity_at_later; }; @@ -118,6 +119,7 @@ static void read_packets(IAudioClient *ac, IAudioCaptureClient *acc, HANDLE hand unsigned int packet_count, struct read_packets_data *data) { unsigned int idx = 0; + UINT32 padding; HRESULT hr;
data->discontinuity_at_0 = FALSE; @@ -125,8 +127,8 @@ static void read_packets(IAudioClient *ac, IAudioCaptureClient *acc, HANDLE hand
while (idx < packet_count) { - UINT32 next_packet_size, frames, frames2, padding; UINT64 dev_pos, dev_pos2, qpc_pos, qpc_pos2; + UINT32 next_packet_size, frames, frames2; DWORD flags, flags2; BYTE *ptr;
@@ -248,6 +250,13 @@ static void read_packets(IAudioClient *ac, IAudioCaptureClient *acc, HANDLE hand
winetest_pop_context(); } + + /* Here we should have basically emptied the buffer, but we allow one or two + * packets to arrive concurrently. */ + hr = IAudioClient_GetCurrentPadding(ac, &padding); + ok(hr == S_OK, "GetCurrentPadding returns %08lx\n", hr); + ok(padding <= 2 * data->period, "GetCurrentPadding %u is larger then twice the period%u\n", + padding, data->period); }
static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) @@ -300,7 +309,7 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx)
hr = IAudioClient_GetDevicePeriod(ac, &period, NULL); ok(hr == S_OK, "GetDevicePeriod failed: %08lx\n", hr); - period = MulDiv(period, wfx->nSamplesPerSec, 10000000); /* as in render.c */ + packets_data.period = MulDiv(period, wfx->nSamplesPerSec, 10000000); /* as in render.c */
hr = IAudioClient_Start(ac); ok(hr == S_OK, "Start on a stopped stream returns %08lx\n", hr); @@ -402,7 +411,7 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) ok(hr == AUDCLNT_E_OUT_OF_ORDER, "Releasing buffer twice returns %08lx\n", hr); }
- frames = period; + frames = packets_data.period; flaky_wine ok(next == frames, "GetNextPacketSize %u vs. GetDevicePeriod %u\n", next, frames);
From: Giovanni Mascellani gmascellani@codeweavers.com
The buffer is around 500 ms, so 400 ms is not enough. It works now because there is an earlier 350 ms sleep and only one packet is read since then, but this will soon change. --- dlls/mmdevapi/tests/capture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/mmdevapi/tests/capture.c b/dlls/mmdevapi/tests/capture.c index e67810cb83d..6bc2ed70760 100644 --- a/dlls/mmdevapi/tests/capture.c +++ b/dlls/mmdevapi/tests/capture.c @@ -420,7 +420,7 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) ok(hr == S_OK, "GetBufferSize failed: %08lx\n", hr); trace("GetBufferSize %u period size %u\n", next, frames);
- Sleep(400); /* overrun */ + Sleep(600); /* overrun */
hr = IAudioClient_GetCurrentPadding(ac, &pad); ok(hr == S_OK, "GetCurrentPadding call returns %08lx\n", hr);
From: Giovanni Mascellani gmascellani@codeweavers.com
The packet size is usually the device period, but not necessarily. I've often seen packets large two periods. --- dlls/mmdevapi/tests/capture.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/mmdevapi/tests/capture.c b/dlls/mmdevapi/tests/capture.c index 6bc2ed70760..43555c42292 100644 --- a/dlls/mmdevapi/tests/capture.c +++ b/dlls/mmdevapi/tests/capture.c @@ -411,14 +411,10 @@ static void test_capture(IAudioClient *ac, HANDLE handle, WAVEFORMATEX *wfx) ok(hr == AUDCLNT_E_OUT_OF_ORDER, "Releasing buffer twice returns %08lx\n", hr); }
- frames = packets_data.period; - flaky_wine - ok(next == frames, "GetNextPacketSize %u vs. GetDevicePeriod %u\n", next, frames); - /* GetBufferSize is not a multiple of the period size! */ hr = IAudioClient_GetBufferSize(ac, &next); ok(hr == S_OK, "GetBufferSize failed: %08lx\n", hr); - trace("GetBufferSize %u period size %u\n", next, frames); + trace("GetBufferSize %u period size %u\n", next, packets_data.period);
Sleep(600); /* overrun */