Same as b1807751219e256867eaac5cc4d8b97a5482978f.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/sample.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index 1d29b6cdc2c..738f803fe66 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -920,19 +920,21 @@ static ULONG WINAPI video_sample_AddRef(IMFSample *iface) static ULONG WINAPI video_sample_Release(IMFSample *iface) { struct video_sample *sample = impl_from_IMFSample(iface); - ULONG refcount; + ULONG refcount = InterlockedDecrement(&sample->refcount); + IMFAsyncResult *tracked_result = NULL;
IMFSample_LockStore(sample->sample); - if (sample->tracked_result && sample->tracked_refcount == (sample->refcount - 1)) + if (sample->tracked_result && sample->tracked_refcount == refcount) { - video_sample_tracking_thread_invoke(sample->tracked_result); - IMFAsyncResult_Release(sample->tracked_result); + tracked_result = sample->tracked_result; + video_sample_tracking_thread_invoke(tracked_result); sample->tracked_result = NULL; sample->tracked_refcount = 0; } IMFSample_UnlockStore(sample->sample);
- refcount = InterlockedDecrement(&sample->refcount); + if (tracked_result) + IMFAsyncResult_Release(tracked_result);
TRACE("%p, refcount %lu.\n", iface, refcount);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
Locking methods were used here before critical section was introduced, no reason to use them now.
dlls/evr/sample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/evr/sample.c b/dlls/evr/sample.c index 738f803fe66..3521e6c4d51 100644 --- a/dlls/evr/sample.c +++ b/dlls/evr/sample.c @@ -923,7 +923,7 @@ static ULONG WINAPI video_sample_Release(IMFSample *iface) ULONG refcount = InterlockedDecrement(&sample->refcount); IMFAsyncResult *tracked_result = NULL;
- IMFSample_LockStore(sample->sample); + EnterCriticalSection(&sample->cs); if (sample->tracked_result && sample->tracked_refcount == refcount) { tracked_result = sample->tracked_result; @@ -931,7 +931,7 @@ static ULONG WINAPI video_sample_Release(IMFSample *iface) sample->tracked_result = NULL; sample->tracked_refcount = 0; } - IMFSample_UnlockStore(sample->sample); + LeaveCriticalSection(&sample->cs);
if (tracked_result) IMFAsyncResult_Release(tracked_result);