Commit 81d04f93 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Leave the wm_reader stream_cs when calling the callbacks.

They may block and we need to enter the stream_cs to stop the reader. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com>
parent fdb0f101
...@@ -99,7 +99,12 @@ static DWORD WINAPI stream_thread(void *arg) ...@@ -99,7 +99,12 @@ static DWORD WINAPI stream_thread(void *arg)
QWORD user_time = reader->user_time; QWORD user_time = reader->user_time;
if (pts > user_time && reader->reader.callback_advanced) if (pts > user_time && reader->reader.callback_advanced)
{
LeaveCriticalSection(&reader->stream_cs);
IWMReaderCallbackAdvanced_OnTime(reader->reader.callback_advanced, user_time, reader->context); IWMReaderCallbackAdvanced_OnTime(reader->reader.callback_advanced, user_time, reader->context);
EnterCriticalSection(&reader->stream_cs);
}
while (pts > reader->user_time && reader->running) while (pts > reader->user_time && reader->running)
SleepConditionVariableCS(&reader->stream_cv, &reader->stream_cs, INFINITE); SleepConditionVariableCS(&reader->stream_cv, &reader->stream_cs, INFINITE);
} }
...@@ -119,18 +124,23 @@ static DWORD WINAPI stream_thread(void *arg) ...@@ -119,18 +124,23 @@ static DWORD WINAPI stream_thread(void *arg)
if (reader->running) if (reader->running)
{ {
LeaveCriticalSection(&reader->stream_cs);
if (stream->read_compressed) if (stream->read_compressed)
hr = IWMReaderCallbackAdvanced_OnStreamSample(reader->reader.callback_advanced, hr = IWMReaderCallbackAdvanced_OnStreamSample(reader->reader.callback_advanced,
stream_number, pts, duration, flags, sample, reader->context); stream_number, pts, duration, flags, sample, reader->context);
else else
hr = IWMReaderCallback_OnSample(callback, stream_number - 1, pts, duration, hr = IWMReaderCallback_OnSample(callback, stream_number - 1, pts, duration,
flags, sample, reader->context); flags, sample, reader->context);
EnterCriticalSection(&reader->stream_cs);
TRACE("Callback returned %#lx.\n", hr); TRACE("Callback returned %#lx.\n", hr);
} }
INSSBuffer_Release(sample); INSSBuffer_Release(sample);
} }
LeaveCriticalSection(&reader->stream_cs);
if (hr == NS_E_NO_MORE_SAMPLES) if (hr == NS_E_NO_MORE_SAMPLES)
{ {
IWMReaderCallback_OnStatus(callback, WMT_END_OF_STREAMING, S_OK, IWMReaderCallback_OnStatus(callback, WMT_END_OF_STREAMING, S_OK,
...@@ -154,8 +164,6 @@ static DWORD WINAPI stream_thread(void *arg) ...@@ -154,8 +164,6 @@ static DWORD WINAPI stream_thread(void *arg)
ERR("Failed to get sample, hr %#lx.\n", hr); ERR("Failed to get sample, hr %#lx.\n", hr);
} }
LeaveCriticalSection(&reader->stream_cs);
TRACE("Reader is stopping; exiting.\n"); TRACE("Reader is stopping; exiting.\n");
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment