Commit 715c91cf authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

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

parent 3cef5238
...@@ -184,18 +184,21 @@ static ULONG WINAPI sample_tracked_Release(IMFSample *iface) ...@@ -184,18 +184,21 @@ static ULONG WINAPI sample_tracked_Release(IMFSample *iface)
HRESULT hr; HRESULT hr;
EnterCriticalSection(&sample->attributes.cs); EnterCriticalSection(&sample->attributes.cs);
refcount = InterlockedDecrement(&sample->attributes.ref); if (sample->tracked_result && sample->tracked_refcount == (sample->attributes.ref - 1))
if (sample->tracked_result && sample->tracked_refcount == refcount)
{ {
/* Call could fail if queue system is not initialized, it's not critical. */ IRtwqAsyncResult *tracked_result = sample->tracked_result;
if (FAILED(hr = RtwqInvokeCallback(sample->tracked_result)))
WARN("Failed to invoke tracking callback, hr %#x.\n", hr);
IRtwqAsyncResult_Release(sample->tracked_result);
sample->tracked_result = NULL; sample->tracked_result = NULL;
sample->tracked_refcount = 0; 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); LeaveCriticalSection(&sample->attributes.cs);
refcount = InterlockedDecrement(&sample->attributes.ref);
TRACE("%p, refcount %u.\n", iface, refcount); TRACE("%p, refcount %u.\n", iface, refcount);
if (!refcount) if (!refcount)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment