Nikolay Sivov : mfplat: Handle tracked sample release condition separately from refcount update.

Alexandre Julliard julliard at winehq.org
Mon Feb 15 16:09:50 CST 2021


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Feb 15 14:33:29 2021 +0300

mfplat: Handle tracked sample release condition separately from refcount update.

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

---

 dlls/mfplat/sample.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/dlls/mfplat/sample.c b/dlls/mfplat/sample.c
index 10d2b7bc2a8..82e7c8680dd 100644
--- a/dlls/mfplat/sample.c
+++ b/dlls/mfplat/sample.c
@@ -184,18 +184,21 @@ static ULONG WINAPI sample_tracked_Release(IMFSample *iface)
     HRESULT hr;
 
     EnterCriticalSection(&sample->attributes.cs);
-    refcount = InterlockedDecrement(&sample->attributes.ref);
-    if (sample->tracked_result && sample->tracked_refcount == refcount)
+    if (sample->tracked_result && sample->tracked_refcount == (sample->attributes.ref - 1))
     {
-        /* Call could fail if queue system is not initialized, it's not critical. */
-        if (FAILED(hr = RtwqInvokeCallback(sample->tracked_result)))
-            WARN("Failed to invoke tracking callback, hr %#x.\n", hr);
-        IRtwqAsyncResult_Release(sample->tracked_result);
+        IRtwqAsyncResult *tracked_result = sample->tracked_result;
         sample->tracked_result = NULL;
         sample->tracked_refcount = 0;
+
+        /* Call could fail if queue system is not initialized, it's not critical. */
+        if (FAILED(hr = RtwqInvokeCallback(tracked_result)))
+            WARN("Failed to invoke tracking callback, hr %#x.\n", hr);
+        IRtwqAsyncResult_Release(tracked_result);
     }
     LeaveCriticalSection(&sample->attributes.cs);
 
+    refcount = InterlockedDecrement(&sample->attributes.ref);
+
     TRACE("%p, refcount %u.\n", iface, refcount);
 
     if (!refcount)




More information about the wine-cvs mailing list