Module: wine Branch: master Commit: fd79a28593244b860739af8a49fab5030f8f10b9 URL: https://source.winehq.org/git/wine.git/?a=commit;h=fd79a28593244b860739af8a4...
Author: Zebediah Figura z.figura12@gmail.com Date: Wed Jun 19 20:16:14 2019 -0500
quartz/filesource: Add a test for cross-thread asynchronous read requests.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/quartz/tests/filesource.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index b1a8399..c38811a 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -808,12 +808,28 @@ static void test_sync_read_aligned(IAsyncReader *reader, IMemAllocator *allocato IMediaSample_Release(sample); }
+struct request_thread_params +{ + IAsyncReader *reader; + IMediaSample *sample; +}; + +static DWORD CALLBACK request_thread(void *arg) +{ + struct request_thread_params *params = arg; + HRESULT hr = IAsyncReader_Request(params->reader, params->sample, 123); + ok(hr == S_OK, "Got hr %#x.\n", hr); + return 0; +} + static void test_request(IAsyncReader *reader, IMemAllocator *allocator) { IMediaSample *sample, *sample2, *ret_sample; + struct request_thread_params params; REFERENCE_TIME start_time, end_time; BYTE *data, *data2; DWORD_PTR cookie; + HANDLE thread; HRESULT hr; LONG len; int i; @@ -897,6 +913,17 @@ static void test_request(IAsyncReader *reader, IMemAllocator *allocator) for (i = 0; i < 88; i++) ok(data2[i] == (512 + i) % 111, "Got wrong byte %02x at %u.\n", data2[i], i);
+ params.reader = reader; + params.sample = sample; + thread = CreateThread(NULL, 0, request_thread, ¶ms, 0, NULL); + ok(!WaitForSingleObject(thread, 1000), "Wait timed out.\n"); + CloseHandle(thread); + + hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_sample == sample, "Samples didn't match.\n"); + ok(cookie == 123, "Got cookie %lu.\n", cookie); + IMediaSample_Release(sample); IMediaSample_Release(sample2); }