Anton Baskanov : amstream: Release filter critical section before calling upstream seeking methods.

Alexandre Julliard julliard at winehq.org
Wed Nov 4 15:20:32 CST 2020


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

Author: Anton Baskanov <baskanov at gmail.com>
Date:   Thu Oct 29 11:40:58 2020 +0700

amstream: Release filter critical section before calling upstream seeking methods.

Otherwise a seek might deadlock when the stream calls the filter methods (e.g. WaitUntil) from streaming thread.

Signed-off-by: Anton Baskanov <baskanov at gmail.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/amstream/filter.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/dlls/amstream/filter.c b/dlls/amstream/filter.c
index b63a0301d64..daeb1fafe71 100644
--- a/dlls/amstream/filter.c
+++ b/dlls/amstream/filter.c
@@ -795,15 +795,16 @@ static HRESULT WINAPI filter_seeking_GetDuration(IMediaSeeking *iface, LONGLONG
 
     EnterCriticalSection(&filter->cs);
 
-    if (!(seeking = get_seeking(filter->seekable_stream)))
-    {
-        LeaveCriticalSection(&filter->cs);
+    seeking = get_seeking(filter->seekable_stream);
+
+    LeaveCriticalSection(&filter->cs);
+
+    if (!seeking)
         return E_NOTIMPL;
-    }
+
     hr = IMediaSeeking_GetDuration(seeking, duration);
     IMediaSeeking_Release(seeking);
 
-    LeaveCriticalSection(&filter->cs);
     return hr;
 }
 
@@ -817,15 +818,16 @@ static HRESULT WINAPI filter_seeking_GetStopPosition(IMediaSeeking *iface, LONGL
 
     EnterCriticalSection(&filter->cs);
 
-    if (!(seeking = get_seeking(filter->seekable_stream)))
-    {
-        LeaveCriticalSection(&filter->cs);
+    seeking = get_seeking(filter->seekable_stream);
+
+    LeaveCriticalSection(&filter->cs);
+
+    if (!seeking)
         return E_NOTIMPL;
-    }
+
     hr = IMediaSeeking_GetStopPosition(seeking, stop);
     IMediaSeeking_Release(seeking);
 
-    LeaveCriticalSection(&filter->cs);
     return hr;
 }
 
@@ -860,18 +862,15 @@ static HRESULT WINAPI filter_seeking_SetPositions(IMediaSeeking *iface, LONGLONG
 
     seeking = get_seeking(filter->seekable_stream);
 
+    LeaveCriticalSection(&filter->cs);
+
     if (!seeking)
-    {
-        LeaveCriticalSection(&filter->cs);
         return E_NOTIMPL;
-    }
 
     hr = IMediaSeeking_SetPositions(seeking, current_ptr, current_flags, stop_ptr, stop_flags);
 
     IMediaSeeking_Release(seeking);
 
-    LeaveCriticalSection(&filter->cs);
-
     return hr;
 }
 




More information about the wine-cvs mailing list