From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 752be9ea260..554d457dd0d 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -585,6 +585,7 @@ struct test_callback LONG refcount; HANDLE event; DWORD param; + UINT sleep_ms; IMFMediaEvent *media_event; IMFAsyncResult *result; }; @@ -640,6 +641,10 @@ static HRESULT WINAPI test_async_callback_result_Invoke(IMFAsyncCallback *iface,
callback->result = result; IMFAsyncResult_AddRef(callback->result); + + if (callback->sleep_ms) + Sleep(callback->sleep_ms); + SetEvent(callback->event);
return S_OK; @@ -6703,6 +6708,43 @@ static void test_queue_com_state(const char *name) IMFAsyncCallback_Release(&callback->IMFAsyncCallback_iface); }
+static void test_queue_unlock_with_pending(void) +{ + struct test_callback *callback0, *callback1; + DWORD queue; + HRESULT hr; + + callback0 = create_test_callback(&test_queue_com_state_callback_vtbl); + callback1 = create_test_callback(&test_queue_com_state_callback_vtbl); + callback0->sleep_ms = 500; + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(SUCCEEDED(hr), "Failed to start up, hr %#lx.\n", hr); + + hr = MFAllocateWorkQueue(&queue); + ok(SUCCEEDED(hr), "Failed to allocate queue, hr %#lx.\n", hr); + + hr = MFPutWorkItem(queue, &callback0->IMFAsyncCallback_iface, NULL); + ok(SUCCEEDED(hr), "Failed to queue work item, hr %#lx.\n", hr); + hr = MFPutWorkItem(queue, &callback1->IMFAsyncCallback_iface, NULL); + ok(SUCCEEDED(hr), "Failed to queue work item, hr %#lx.\n", hr); + + /* Unlocking does not prevent pending items from executing. */ + MFUnlockWorkQueue(queue); + + hr = WaitForSingleObject(callback0->event, 1000); + ok(hr == WAIT_OBJECT_0 || hr == WAIT_TIMEOUT, "Failed to wait for event, hr %#lx.\n", hr); + hr = WaitForSingleObject(callback1->event, 1000); + todo_wine + ok(hr == WAIT_OBJECT_0, "Failed to wait for event, hr %#lx.\n", hr); + + hr = MFShutdown(); + ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr); + + IMFAsyncCallback_Release(&callback0->IMFAsyncCallback_iface); + IMFAsyncCallback_Release(&callback1->IMFAsyncCallback_iface); +} + static void test_MFGetStrideForBitmapInfoHeader(void) { static const struct stride_test @@ -13216,6 +13258,7 @@ START_TEST(mfplat) CoInitialize(NULL);
test_startup(); + test_queue_unlock_with_pending(); test_register(); test_media_type(); test_MFCreateMediaEvent();