Commit 848fe4a7 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

mfplat/tests: Create the test_callback event in the constructor.

parent cda2886f
...@@ -521,7 +521,10 @@ static ULONG WINAPI testcallback_Release(IMFAsyncCallback *iface) ...@@ -521,7 +521,10 @@ static ULONG WINAPI testcallback_Release(IMFAsyncCallback *iface)
ULONG refcount = InterlockedDecrement(&callback->refcount); ULONG refcount = InterlockedDecrement(&callback->refcount);
if (!refcount) if (!refcount)
{
CloseHandle(callback->event);
free(callback); free(callback);
}
return refcount; return refcount;
} }
...@@ -804,6 +807,7 @@ static struct test_callback * create_test_callback(const IMFAsyncCallbackVtbl *v ...@@ -804,6 +807,7 @@ static struct test_callback * create_test_callback(const IMFAsyncCallbackVtbl *v
callback->IMFAsyncCallback_iface.lpVtbl = vtbl ? vtbl : &testcallbackvtbl; callback->IMFAsyncCallback_iface.lpVtbl = vtbl ? vtbl : &testcallbackvtbl;
callback->refcount = 1; callback->refcount = 1;
callback->event = CreateEventA(NULL, FALSE, FALSE, NULL);
return callback; return callback;
} }
...@@ -816,7 +820,6 @@ static BOOL get_event(IMFMediaEventGenerator *generator, MediaEventType expected ...@@ -816,7 +820,6 @@ static BOOL get_event(IMFMediaEventGenerator *generator, MediaEventType expected
HRESULT hr; HRESULT hr;
callback = create_test_callback(&events_callback_vtbl); callback = create_test_callback(&events_callback_vtbl);
callback->event = CreateEventA(NULL, FALSE, FALSE, NULL);
for (;;) for (;;)
{ {
...@@ -847,7 +850,6 @@ static BOOL get_event(IMFMediaEventGenerator *generator, MediaEventType expected ...@@ -847,7 +850,6 @@ static BOOL get_event(IMFMediaEventGenerator *generator, MediaEventType expected
} }
} }
CloseHandle(callback->event);
if (callback->media_event) if (callback->media_event)
IMFMediaEvent_Release(callback->media_event); IMFMediaEvent_Release(callback->media_event);
IMFAsyncCallback_Release(&callback->IMFAsyncCallback_iface); IMFAsyncCallback_Release(&callback->IMFAsyncCallback_iface);
...@@ -937,7 +939,6 @@ static void test_source_resolver(void) ...@@ -937,7 +939,6 @@ static void test_source_resolver(void)
IMFByteStream_Release(stream); IMFByteStream_Release(stream);
/* Create from URL. */ /* Create from URL. */
callback->event = CreateEventA(NULL, FALSE, FALSE, NULL);
hr = IMFSourceResolver_CreateObjectFromURL(resolver, L"nonexisting.mp4", MF_RESOLUTION_BYTESTREAM, NULL, &obj_type, hr = IMFSourceResolver_CreateObjectFromURL(resolver, L"nonexisting.mp4", MF_RESOLUTION_BYTESTREAM, NULL, &obj_type,
(IUnknown **)&stream); (IUnknown **)&stream);
...@@ -1234,7 +1235,6 @@ static void test_source_resolver(void) ...@@ -1234,7 +1235,6 @@ static void test_source_resolver(void)
(void **)&scheme_handler); (void **)&scheme_handler);
ok(hr == S_OK, "Failed to create handler object, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to create handler object, hr %#lx.\n", hr);
callback2->event = callback->event;
cancel_cookie = NULL; cancel_cookie = NULL;
hr = IMFSchemeHandler_BeginCreateObject(scheme_handler, pathW, MF_RESOLUTION_MEDIASOURCE, NULL, &cancel_cookie, hr = IMFSchemeHandler_BeginCreateObject(scheme_handler, pathW, MF_RESOLUTION_MEDIASOURCE, NULL, &cancel_cookie,
&callback2->IMFAsyncCallback_iface, (IUnknown *)scheme_handler); &callback2->IMFAsyncCallback_iface, (IUnknown *)scheme_handler);
...@@ -1249,8 +1249,6 @@ static void test_source_resolver(void) ...@@ -1249,8 +1249,6 @@ static void test_source_resolver(void)
if (do_uninit) if (do_uninit)
CoUninitialize(); CoUninitialize();
CloseHandle(callback->event);
IMFSourceResolver_Release(resolver); IMFSourceResolver_Release(resolver);
hr = MFShutdown(); hr = MFShutdown();
...@@ -3524,16 +3522,12 @@ static void test_event_queue(void) ...@@ -3524,16 +3522,12 @@ static void test_event_queue(void)
hr = IMFMediaEventQueue_BeginGetEvent(queue, &callback2->IMFAsyncCallback_iface, (IUnknown *)&callback->IMFAsyncCallback_iface); hr = IMFMediaEventQueue_BeginGetEvent(queue, &callback2->IMFAsyncCallback_iface, (IUnknown *)&callback->IMFAsyncCallback_iface);
ok(hr == MF_E_MULTIPLE_SUBSCRIBERS, "Unexpected hr %#lx.\n", hr); ok(hr == MF_E_MULTIPLE_SUBSCRIBERS, "Unexpected hr %#lx.\n", hr);
callback->event = CreateEventA(NULL, FALSE, FALSE, NULL);
hr = IMFMediaEventQueue_QueueEvent(queue, event); hr = IMFMediaEventQueue_QueueEvent(queue, event);
ok(hr == S_OK, "Failed to queue event, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to queue event, hr %#lx.\n", hr);
ret = WaitForSingleObject(callback->event, 500); ret = WaitForSingleObject(callback->event, 500);
ok(ret == WAIT_OBJECT_0, "Unexpected return value %#lx.\n", ret); ok(ret == WAIT_OBJECT_0, "Unexpected return value %#lx.\n", ret);
CloseHandle(callback->event);
IMFMediaEvent_Release(event); IMFMediaEvent_Release(event);
hr = MFCreateAsyncResult(NULL, &callback->IMFAsyncCallback_iface, NULL, &result); hr = MFCreateAsyncResult(NULL, &callback->IMFAsyncCallback_iface, NULL, &result);
...@@ -4957,8 +4951,6 @@ static void test_async_create_file(void) ...@@ -4957,8 +4951,6 @@ static void test_async_create_file(void)
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Fail to start up, hr %#lx.\n", hr); ok(hr == S_OK, "Fail to start up, hr %#lx.\n", hr);
callback->event = CreateEventA(NULL, FALSE, FALSE, NULL);
GetTempPathW(ARRAY_SIZE(pathW), pathW); GetTempPathW(ARRAY_SIZE(pathW), pathW);
GetTempFileNameW(pathW, NULL, 0, fileW); GetTempFileNameW(pathW, NULL, 0, fileW);
...@@ -4971,8 +4963,6 @@ static void test_async_create_file(void) ...@@ -4971,8 +4963,6 @@ static void test_async_create_file(void)
IUnknown_Release(cancel_cookie); IUnknown_Release(cancel_cookie);
CloseHandle(callback->event);
hr = MFShutdown(); hr = MFShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
...@@ -5856,7 +5846,6 @@ static void test_queue_com_state(const char *name) ...@@ -5856,7 +5846,6 @@ static void test_queue_com_state(const char *name)
HRESULT hr; HRESULT hr;
callback = create_test_callback(&test_queue_com_state_callback_vtbl); callback = create_test_callback(&test_queue_com_state_callback_vtbl);
callback->event = CreateEventA(NULL, FALSE, FALSE, NULL);
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr);
...@@ -5888,8 +5877,6 @@ static void test_queue_com_state(const char *name) ...@@ -5888,8 +5877,6 @@ static void test_queue_com_state(const char *name)
} }
} }
CloseHandle(callback->event);
hr = MFShutdown(); hr = MFShutdown();
ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to shut down, hr %#lx.\n", hr);
......
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