From: Brendan McGrath bmcgrath@codeweavers.com
Tests that the Media Source and its associated resources are freed if Release is called immediately after creation. That is, without a call to either Start or Shutdown.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56686 --- dlls/mfplat/tests/mfplat.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index a4ca567367c..deb457e0256 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -964,6 +964,7 @@ static void test_source_resolver(void) GUID guid; float rate; UINT32 rotation; + ULONG refcount;
if (!pMFCreateSourceResolver) { @@ -1043,12 +1044,6 @@ static void test_source_resolver(void) hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &stream); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- /* Wrap ::Close to test when the media source calls it */ - bytestream_vtbl_orig = stream->lpVtbl; - bytestream_vtbl_wrapper = *bytestream_vtbl_orig; - bytestream_vtbl_wrapper.Close = bytestream_wrapper_Close; - stream->lpVtbl = &bytestream_vtbl_wrapper; - hr = IMFByteStream_QueryInterface(stream, &IID_IMFAttributes, (void **)&attributes); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFAttributes_SetString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, L"video/mp4"); @@ -1075,6 +1070,33 @@ static void test_source_resolver(void) ok(mediasource != NULL, "got %p\n", mediasource); ok(obj_type == MF_OBJECT_MEDIASOURCE, "got %d\n", obj_type);
+ refcount = IMFMediaSource_Release(mediasource); + todo_wine + ok(!refcount, "Unexpected refcount %ld\n", refcount); + IMFByteStream_Release(stream); + + /* We have to create a new bytestream here, because all following + * calls to CreateObjectFromByteStream will fail. */ + hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &stream); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + /* Wrap ::Close to test when the media source calls it */ + bytestream_vtbl_orig = stream->lpVtbl; + bytestream_vtbl_wrapper = *bytestream_vtbl_orig; + bytestream_vtbl_wrapper.Close = bytestream_wrapper_Close; + stream->lpVtbl = &bytestream_vtbl_wrapper; + + hr = IMFByteStream_QueryInterface(stream, &IID_IMFAttributes, (void **)&attributes); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFAttributes_SetString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, L"video/mp4"); + ok(hr == S_OK, "Failed to set string value, hr %#lx.\n", hr); + IMFAttributes_Release(attributes); + + hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL, MF_RESOLUTION_MEDIASOURCE, NULL, + &obj_type, (IUnknown **)&mediasource); + ok(mediasource != NULL, "got %p\n", mediasource); + ok(obj_type == MF_OBJECT_MEDIASOURCE, "got %d\n", obj_type); + check_interface(mediasource, &IID_IMFGetService, TRUE); check_service_interface(mediasource, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateSupport, TRUE);