Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 98 +++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 55142a79cf..790eeaf6d9 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -44,6 +44,8 @@ static HRESULT (WINAPI *pMFCreateMemoryBuffer)(DWORD max_length, IMFMediaBuffer static void* (WINAPI *pMFHeapAlloc)(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type); static void (WINAPI *pMFHeapFree)(void *p); static HRESULT (WINAPI *pMFPutWaitingWorkItem)(HANDLE event, LONG priority, IMFAsyncResult *result, MFWORKITEM_KEY *key); +static HRESULT (WINAPI *pMFAllocateSerialWorkQueue)(DWORD queue, DWORD *serial_queue); +static HRESULT (WINAPI *pMFPutWorkItemEx2)(DWORD queue, LONG priority, IMFAsyncResult *result);
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
@@ -312,7 +314,8 @@ static void init_functions(void) { HMODULE mod = GetModuleHandleA("mfplat.dll");
-#define X(f) if (!(p##f = (void*)GetProcAddress(mod, #f))) return; +#define X(f) p##f = (void*)GetProcAddress(mod, #f) + X(MFAllocateSerialWorkQueue); X(MFCopyImage); X(MFCreateSourceResolver); X(MFCreateMFByteStreamOnStream); @@ -320,6 +323,7 @@ static void init_functions(void) X(MFHeapAlloc); X(MFHeapFree); X(MFPutWaitingWorkItem); + X(MFPutWorkItemEx2); #undef X }
@@ -1104,6 +1108,7 @@ static void test_submit_work_item(void) MFASYNC_CALLBACK_QUEUE_LONG_FUNCTION, }; IMFAsyncCallback callback = { &testcallbackvtbl }; + IMFAsyncResult *norm, *low, *high; unsigned int i; HRESULT hr;
@@ -1116,6 +1121,96 @@ static void test_submit_work_item(void) ok(hr == S_OK, "Failed to submit work item, hr %#x.\n", hr); }
+ if (!pMFPutWorkItemEx2) + { + skip("MFPutWorkItem2 is not available.\n"); + hr = MFShutdown(); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); + return; + } + + hr = MFCreateAsyncResult(NULL, &callback, NULL, &norm); + ok(hr == S_OK, "Failed to create result, hr %#x.\n", hr); + + hr = MFCreateAsyncResult(NULL, &callback, NULL, &low); + ok(hr == S_OK, "Failed to create result, hr %#x.\n", hr); + + hr = MFCreateAsyncResult(NULL, &callback, NULL, &high); + ok(hr == S_OK, "Failed to create result, hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(queue_ids); ++i) + { + hr = pMFPutWorkItemEx2(queue_ids[i], 0, norm); + ok(hr == S_OK, "Failed to submit work item, hr %#x.\n", hr); + + hr = pMFPutWorkItemEx2(queue_ids[i], -1, low); + ok(hr == S_OK, "Failed to submit work item, hr %#x.\n", hr); + + hr = pMFPutWorkItemEx2(queue_ids[i], 1, high); + ok(hr == S_OK, "Failed to submit work item, hr %#x.\n", hr); + } + + IMFAsyncResult_Release(norm); + IMFAsyncResult_Release(low); + IMFAsyncResult_Release(high); + + hr = MFShutdown(); + ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); +} + +static void test_serial_queue(void) +{ + static const DWORD queue_ids[] = + { + MFASYNC_CALLBACK_QUEUE_STANDARD, + MFASYNC_CALLBACK_QUEUE_RT, + MFASYNC_CALLBACK_QUEUE_IO, + MFASYNC_CALLBACK_QUEUE_TIMER, + MFASYNC_CALLBACK_QUEUE_MULTITHREADED, + MFASYNC_CALLBACK_QUEUE_LONG_FUNCTION, + }; + DWORD queue, serial_queue; + unsigned int i; + HRESULT hr; + + if (!pMFAllocateSerialWorkQueue) + { + skip("Serial queues are not supported.\n"); + return; + } + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Failed to start up, hr %#x.\n", hr); + + for (i = 0; i < ARRAY_SIZE(queue_ids); ++i) + { + BOOL broken_types = queue_ids[i] == MFASYNC_CALLBACK_QUEUE_TIMER || + queue_ids[i] == MFASYNC_CALLBACK_QUEUE_LONG_FUNCTION; + + hr = pMFAllocateSerialWorkQueue(queue_ids[i], &serial_queue); + ok(hr == S_OK || broken(broken_types && hr == E_INVALIDARG) /* Win8 */, + "%u: failed to allocate a queue, hr %#x.\n", i, hr); + + if (SUCCEEDED(hr)) + { + hr = MFUnlockWorkQueue(serial_queue); + ok(hr == S_OK, "%u: failed to unlock the queue, hr %#x.\n", i, hr); + } + } + + /* Chain them together. */ + hr = pMFAllocateSerialWorkQueue(MFASYNC_CALLBACK_QUEUE_STANDARD, &serial_queue); + ok(hr == S_OK, "Failed to allocate a queue, hr %#x.\n", hr); + + hr = pMFAllocateSerialWorkQueue(serial_queue, &queue); + ok(hr == S_OK, "Failed to allocate a queue, hr %#x.\n", hr); + + hr = MFUnlockWorkQueue(serial_queue); + ok(hr == S_OK, "Failed to unlock the queue, hr %#x.\n", hr); + + hr = MFUnlockWorkQueue(queue); + ok(hr == S_OK, "Failed to unlock the queue, hr %#x.\n", hr); + hr = MFShutdown(); ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr); } @@ -1143,6 +1238,7 @@ START_TEST(mfplat) test_MFHeapAlloc(); test_scheduled_items(); test_submit_work_item(); + test_serial_queue();
CoUninitialize(); }