Module: wine Branch: master Commit: ac32d3fd727af8db2e35f96aaf5fbd921d39f49b URL: https://gitlab.winehq.org/wine/wine/-/commit/ac32d3fd727af8db2e35f96aaf5fbd9...
Author: Brendan McGrath bmcgrath@codeweavers.com Date: Fri May 17 15:27:23 2024 +1000
mplat/tests: Test Media Source is freed if immediately released.
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 21977807ac2..40853f6fc00 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -966,6 +966,7 @@ static void test_source_resolver(void) GUID guid; float rate; UINT32 rotation; + ULONG refcount;
if (!pMFCreateSourceResolver) { @@ -1045,12 +1046,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"); @@ -1077,6 +1072,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);