Nikolay Sivov : mfreadwrite/reader: Keep a reference to configuration attributes.

Alexandre Julliard julliard at winehq.org
Wed Feb 10 15:34:02 CST 2021


Module: wine
Branch: master
Commit: cf4fe13a41b7cc0a624da7741ae528ef21032736
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=cf4fe13a41b7cc0a624da7741ae528ef21032736

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Feb 10 13:32:29 2021 +0300

mfreadwrite/reader: Keep a reference to configuration attributes.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mfreadwrite/reader.c       |  6 ++++++
 dlls/mfreadwrite/tests/mfplat.c | 16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c
index 0e0fe1ad9cd..86507bde5a1 100644
--- a/dlls/mfreadwrite/reader.c
+++ b/dlls/mfreadwrite/reader.c
@@ -169,6 +169,7 @@ struct source_reader
     IMFMediaSource *source;
     IMFPresentationDescriptor *descriptor;
     IMFSourceReaderCallback *async_callback;
+    IMFAttributes *attributes;
     unsigned int first_audio_stream_index;
     unsigned int first_video_stream_index;
     unsigned int last_read_index;
@@ -1268,6 +1269,8 @@ static ULONG WINAPI src_reader_Release(IMFSourceReader *iface)
             IMFMediaSource_Shutdown(reader->source);
         if (reader->descriptor)
             IMFPresentationDescriptor_Release(reader->descriptor);
+        if (reader->attributes)
+            IMFAttributes_Release(reader->attributes);
         IMFMediaSource_Release(reader->source);
 
         for (i = 0; i < reader->stream_count; ++i)
@@ -2162,6 +2165,9 @@ static HRESULT create_source_reader_from_source(IMFMediaSource *source, IMFAttri
 
     if (attributes)
     {
+        object->attributes = attributes;
+        IMFAttributes_AddRef(object->attributes);
+
         IMFAttributes_GetUnknown(attributes, &MF_SOURCE_READER_ASYNC_CALLBACK, &IID_IMFSourceReaderCallback,
                 (void **)&object->async_callback);
         if (object->async_callback)
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c
index 8455ac64688..9d84265244a 100644
--- a/dlls/mfreadwrite/tests/mfplat.c
+++ b/dlls/mfreadwrite/tests/mfplat.c
@@ -41,6 +41,13 @@ DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 #include "wine/heap.h"
 #include "wine/test.h"
 
+static ULONG get_refcount(void *iface)
+{
+    IUnknown *unknown = iface;
+    IUnknown_AddRef(unknown);
+    return IUnknown_Release(unknown);
+}
+
 static HRESULT (WINAPI *pMFCreateMFByteStreamOnStream)(IStream *stream, IMFByteStream **bytestream);
 
 static void init_functions(void)
@@ -620,6 +627,7 @@ static void test_source_reader(void)
     IMFByteStream *stream;
     LONGLONG timestamp;
     IMFSample *sample;
+    ULONG refcount;
     BOOL selected;
     HRESULT hr;
 
@@ -836,9 +844,12 @@ skip_read_sample:
     ok(hr == S_OK, "Failed to set attribute value, hr %#x.\n", hr);
     IMFSourceReaderCallback_Release(&callback->IMFSourceReaderCallback_iface);
 
+    refcount = get_refcount(attributes);
     hr = MFCreateSourceReaderFromByteStream(stream, attributes, &reader);
-todo_wine
+todo_wine {
     ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
+    ok(get_refcount(attributes) > refcount, "Unexpected refcount.\n");
+}
     IMFAttributes_Release(attributes);
     if (hr == S_OK)
         IMFSourceReader_Release(reader);
@@ -856,6 +867,7 @@ static void test_source_reader_from_media_source(void)
     IMFSample *sample;
     LONGLONG timestamp;
     IMFAttributes *attributes;
+    ULONG refcount;
     int i;
 
     source = create_test_source();
@@ -967,8 +979,10 @@ static void test_source_reader_from_media_source(void)
     ok(hr == S_OK, "Failed to set attribute value, hr %#x.\n", hr);
     IMFSourceReaderCallback_Release(&callback->IMFSourceReaderCallback_iface);
 
+    refcount = get_refcount(attributes);
     hr = MFCreateSourceReaderFromMediaSource(source, attributes, &reader);
     ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
+    ok(get_refcount(attributes) > refcount, "Unexpected refcount.\n");
 
     hr = IMFSourceReader_SetStreamSelection(reader, 0, TRUE);
     ok(hr == S_OK, "Failed to select a stream, hr %#x.\n", hr);




More information about the wine-cvs mailing list