Giovanni Mascellani : mfreadwrite/reader: Unset sample allocator callbacks while destroying the source reader.

Alexandre Julliard julliard at winehq.org
Mon Apr 11 15:54:58 CDT 2022


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

Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date:   Sat Apr  9 09:16:18 2022 +0300

mfreadwrite/reader: Unset sample allocator callbacks while destroying the source reader.

The sample allocator callbacks own a reference to the source reader,
which creates a reference loop and prevents the source reader from
being properly destroyed.

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

---

 dlls/mfreadwrite/reader.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c
index 2d3da19db10..e7b7b555e68 100644
--- a/dlls/mfreadwrite/reader.c
+++ b/dlls/mfreadwrite/reader.c
@@ -1412,6 +1412,7 @@ static ULONG WINAPI src_reader_Release(IMFSourceReader *iface)
 {
     struct source_reader *reader = impl_from_IMFSourceReader(iface);
     ULONG refcount = InterlockedDecrement(&reader->public_refcount);
+    unsigned int i;
 
     TRACE("%p, refcount %lu.\n", iface, refcount);
 
@@ -1430,6 +1431,23 @@ static ULONG WINAPI src_reader_Release(IMFSourceReader *iface)
 
             LeaveCriticalSection(&reader->cs);
         }
+
+        for (i = 0; i < reader->stream_count; ++i)
+        {
+            struct media_stream *stream = &reader->streams[i];
+            IMFVideoSampleAllocatorCallback *callback;
+
+            if (!stream->allocator)
+                continue;
+
+            if (SUCCEEDED(IMFVideoSampleAllocatorEx_QueryInterface(stream->allocator, &IID_IMFVideoSampleAllocatorCallback,
+                    (void **)&callback)))
+            {
+                IMFVideoSampleAllocatorCallback_SetCallback(callback, NULL);
+                IMFVideoSampleAllocatorCallback_Release(callback);
+            }
+        }
+
         source_reader_release(reader);
     }
 




More information about the wine-cvs mailing list