[PATCH v3 3/6] amstream: Release filter critical section before calling upstream seeking methods.

Anton Baskanov baskanov at gmail.com
Wed Oct 28 23:40:58 CDT 2020


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>
---
 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;
 }
 
-- 
2.17.1




More information about the wine-devel mailing list