Nikolay Sivov : mf/samplegrabber: Test shutdown state under the lock for methods that modify item queue.

Alexandre Julliard julliard at winehq.org
Fri May 15 16:55:07 CDT 2020


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri May 15 18:32:55 2020 +0300

mf/samplegrabber: Test shutdown state under the lock for methods that modify item queue.

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

---

 dlls/mf/samplegrabber.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/dlls/mf/samplegrabber.c b/dlls/mf/samplegrabber.c
index 24d9163d19..92330abc9f 100644
--- a/dlls/mf/samplegrabber.c
+++ b/dlls/mf/samplegrabber.c
@@ -407,12 +407,11 @@ static HRESULT WINAPI sample_grabber_stream_ProcessSample(IMFStreamSink *iface,
     if (!sample)
         return S_OK;
 
-    if (grabber->is_shut_down)
-        return MF_E_STREAMSINK_REMOVED;
-
     EnterCriticalSection(&grabber->cs);
 
-    if (grabber->state == SINK_STATE_RUNNING)
+    if (grabber->is_shut_down)
+        hr = MF_E_STREAMSINK_REMOVED;
+    else if (grabber->state == SINK_STATE_RUNNING)
     {
         hr = IMFSample_GetSampleTime(sample, &sampletime);
 
@@ -479,12 +478,11 @@ static HRESULT WINAPI sample_grabber_stream_PlaceMarker(IMFStreamSink *iface, MF
 
     TRACE("%p, %d, %p, %p.\n", iface, marker_type, marker_value, context_value);
 
-    if (grabber->is_shut_down)
-        return MF_E_STREAMSINK_REMOVED;
-
     EnterCriticalSection(&grabber->cs);
 
-    if (grabber->state == SINK_STATE_RUNNING)
+    if (grabber->is_shut_down)
+        hr = MF_E_STREAMSINK_REMOVED;
+    else if (grabber->state == SINK_STATE_RUNNING)
         hr = stream_place_marker(grabber, marker_type, context_value);
 
     LeaveCriticalSection(&grabber->cs);




More information about the wine-cvs mailing list