This MR adds a test that shows Wine does not currently free the Media Source and its associated resources when Release is called immediately after creation. That is, it is released without a call to either Start or Shutdown.
The bug is captured as Wine bug 56686.
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);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=145643
Your paranoid android.
=== w8 (32 bit report) ===
mfplat: mfplat.c:1075: Test failed: Unexpected refcount 3
=== w864 (32 bit report) ===
mfplat: mfplat.c:1075: Test failed: Unexpected refcount 3
=== w1064_adm (64 bit report) ===
mfplat: mfplat.c:1075: Test failed: Unexpected refcount 3
This merge request was approved by Nikolay Sivov.
That makes sense. First time client gets to access streams is at MENewStream event, which can only be delivered when it's listening for it, and after Start() was called for the first time. We probably have to defer that internal cross-referencing until then.