Commit 568b4bc9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf/sar: Consistently check for shutdown flag within a lock.

parent 5981f2ed
...@@ -451,21 +451,26 @@ static HRESULT WINAPI audio_renderer_sink_GetPresentationClock(IMFMediaSink *ifa ...@@ -451,21 +451,26 @@ static HRESULT WINAPI audio_renderer_sink_GetPresentationClock(IMFMediaSink *ifa
static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface) static HRESULT WINAPI audio_renderer_sink_Shutdown(IMFMediaSink *iface)
{ {
struct audio_renderer *renderer = impl_from_IMFMediaSink(iface); struct audio_renderer *renderer = impl_from_IMFMediaSink(iface);
HRESULT hr = S_OK;
TRACE("%p.\n", iface); TRACE("%p.\n", iface);
EnterCriticalSection(&renderer->cs);
if (renderer->flags & SAR_SHUT_DOWN) if (renderer->flags & SAR_SHUT_DOWN)
return MF_E_SHUTDOWN; hr = MF_E_SHUTDOWN;
else
{
renderer->flags |= SAR_SHUT_DOWN;
IMFMediaEventQueue_Shutdown(renderer->event_queue);
IMFMediaEventQueue_Shutdown(renderer->stream_event_queue);
audio_renderer_set_presentation_clock(renderer, NULL);
audio_renderer_release_audio_client(renderer);
}
EnterCriticalSection(&renderer->cs);
renderer->flags |= SAR_SHUT_DOWN;
IMFMediaEventQueue_Shutdown(renderer->event_queue);
IMFMediaEventQueue_Shutdown(renderer->stream_event_queue);
audio_renderer_set_presentation_clock(renderer, NULL);
audio_renderer_release_audio_client(renderer);
LeaveCriticalSection(&renderer->cs); LeaveCriticalSection(&renderer->cs);
return S_OK; return hr;
} }
static const IMFMediaSinkVtbl audio_renderer_sink_vtbl = static const IMFMediaSinkVtbl audio_renderer_sink_vtbl =
...@@ -1364,19 +1369,22 @@ static HRESULT WINAPI audio_renderer_stream_ProcessSample(IMFStreamSink *iface, ...@@ -1364,19 +1369,22 @@ static HRESULT WINAPI audio_renderer_stream_ProcessSample(IMFStreamSink *iface,
if (!sample) if (!sample)
return E_POINTER; return E_POINTER;
if (renderer->flags & SAR_SHUT_DOWN)
return MF_E_STREAMSINK_REMOVED;
EnterCriticalSection(&renderer->cs); EnterCriticalSection(&renderer->cs);
if (renderer->state == STREAM_STATE_RUNNING) if (renderer->flags & SAR_SHUT_DOWN)
hr = stream_queue_sample(renderer, sample); hr = MF_E_STREAMSINK_REMOVED;
renderer->flags &= ~SAR_SAMPLE_REQUESTED; else
if (renderer->queued_frames < renderer->max_frames && renderer->state == STREAM_STATE_RUNNING)
{ {
IMFMediaEventQueue_QueueEventParamVar(renderer->stream_event_queue, MEStreamSinkRequestSample, &GUID_NULL, S_OK, NULL); if (renderer->state == STREAM_STATE_RUNNING)
renderer->flags |= SAR_SAMPLE_REQUESTED; hr = stream_queue_sample(renderer, sample);
renderer->flags &= ~SAR_SAMPLE_REQUESTED;
if (renderer->queued_frames < renderer->max_frames && renderer->state == STREAM_STATE_RUNNING)
{
IMFMediaEventQueue_QueueEventParamVar(renderer->stream_event_queue, MEStreamSinkRequestSample,
&GUID_NULL, S_OK, NULL);
renderer->flags |= SAR_SAMPLE_REQUESTED;
}
} }
LeaveCriticalSection(&renderer->cs); LeaveCriticalSection(&renderer->cs);
...@@ -1414,11 +1422,13 @@ static HRESULT WINAPI audio_renderer_stream_PlaceMarker(IMFStreamSink *iface, MF ...@@ -1414,11 +1422,13 @@ static HRESULT WINAPI audio_renderer_stream_PlaceMarker(IMFStreamSink *iface, MF
TRACE("%p, %d, %p, %p.\n", iface, marker_type, marker_value, context_value); TRACE("%p, %d, %p, %p.\n", iface, marker_type, marker_value, context_value);
EnterCriticalSection(&renderer->cs);
if (renderer->flags & SAR_SHUT_DOWN) if (renderer->flags & SAR_SHUT_DOWN)
return MF_E_STREAMSINK_REMOVED; hr = MF_E_STREAMSINK_REMOVED;
else
hr = stream_place_marker(renderer, marker_type, context_value);
EnterCriticalSection(&renderer->cs);
hr = stream_place_marker(renderer, marker_type, context_value);
LeaveCriticalSection(&renderer->cs); LeaveCriticalSection(&renderer->cs);
return hr; return hr;
......
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