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

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-02-15 14:33:29 +03:00 committed by Alexandre Julliard
parent 3cef5238bd
commit 715c91cf78
1 changed files with 9 additions and 6 deletions

View File

@ -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)