From: Rémi Bernon rbernon@codeweavers.com
They may block and we need to enter the stream_cs to stop the reader.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/wm_asyncreader.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/winegstreamer/wm_asyncreader.c b/dlls/winegstreamer/wm_asyncreader.c index fbfbd38f99e..ef6e445a51b 100644 --- a/dlls/winegstreamer/wm_asyncreader.c +++ b/dlls/winegstreamer/wm_asyncreader.c @@ -99,7 +99,12 @@ static DWORD WINAPI stream_thread(void *arg) QWORD user_time = reader->user_time;
if (pts > user_time && reader->reader.callback_advanced) + { + LeaveCriticalSection(&reader->stream_cs); IWMReaderCallbackAdvanced_OnTime(reader->reader.callback_advanced, user_time, reader->context); + EnterCriticalSection(&reader->stream_cs); + } + while (pts > reader->user_time && reader->running) SleepConditionVariableCS(&reader->stream_cv, &reader->stream_cs, INFINITE); } @@ -119,18 +124,23 @@ static DWORD WINAPI stream_thread(void *arg)
if (reader->running) { + LeaveCriticalSection(&reader->stream_cs); if (stream->read_compressed) hr = IWMReaderCallbackAdvanced_OnStreamSample(reader->reader.callback_advanced, stream_number, pts, duration, flags, sample, reader->context); else hr = IWMReaderCallback_OnSample(callback, stream_number - 1, pts, duration, flags, sample, reader->context); + EnterCriticalSection(&reader->stream_cs); + TRACE("Callback returned %#lx.\n", hr); }
INSSBuffer_Release(sample); }
+ LeaveCriticalSection(&reader->stream_cs); + if (hr == NS_E_NO_MORE_SAMPLES) { IWMReaderCallback_OnStatus(callback, WMT_END_OF_STREAMING, S_OK, @@ -154,8 +164,6 @@ static DWORD WINAPI stream_thread(void *arg) ERR("Failed to get sample, hr %#lx.\n", hr); }
- LeaveCriticalSection(&reader->stream_cs); - TRACE("Reader is stopping; exiting.\n"); return 0; }