Commit fe5292bf authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz: Implement IMediaControl::StopWhenReady().

This allows The Bunker to exit cleanly. Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 925e5dde
......@@ -2132,11 +2132,63 @@ static HRESULT WINAPI MediaControl_get_RegFilterCollection(IMediaControl *iface,
return S_OK;
}
static void CALLBACK wait_pause_cb(TP_CALLBACK_INSTANCE *instance, void *context)
{
IMediaControl *control = context;
OAFilterState state;
HRESULT hr;
if ((hr = IMediaControl_GetState(control, INFINITE, &state)) != S_OK)
ERR("Failed to get paused state, hr %#x.\n", hr);
if (FAILED(hr = IMediaControl_Stop(control)))
ERR("Failed to stop, hr %#x.\n", hr);
if ((hr = IMediaControl_GetState(control, INFINITE, &state)) != S_OK)
ERR("Failed to get paused state, hr %#x.\n", hr);
IMediaControl_Release(control);
}
static void CALLBACK wait_stop_cb(TP_CALLBACK_INSTANCE *instance, void *context)
{
IMediaControl *control = context;
OAFilterState state;
HRESULT hr;
if ((hr = IMediaControl_GetState(control, INFINITE, &state)) != S_OK)
ERR("Failed to get state, hr %#x.\n", hr);
IMediaControl_Release(control);
}
static HRESULT WINAPI MediaControl_StopWhenReady(IMediaControl *iface)
{
IFilterGraphImpl *This = impl_from_IMediaControl(iface);
IFilterGraphImpl *graph = impl_from_IMediaControl(iface);
HRESULT hr;
TRACE("graph %p.\n", graph);
/* Even if we are already stopped, we still pause. */
hr = IMediaControl_Pause(iface);
if (FAILED(hr))
return hr;
else if (hr == S_FALSE)
{
IMediaControl_AddRef(iface);
TrySubmitThreadpoolCallback(wait_pause_cb, iface, NULL);
return S_FALSE;
}
FIXME("(%p/%p)->(): stub !!!\n", This, iface);
hr = IMediaControl_Stop(iface);
if (FAILED(hr))
return hr;
else if (hr == S_FALSE)
{
IMediaControl_AddRef(iface);
TrySubmitThreadpoolCallback(wait_stop_cb, iface, NULL);
return S_FALSE;
}
return S_OK;
}
......
......@@ -3178,6 +3178,26 @@ static void test_filter_state(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_filter_state(graph, State_Stopped);
hr = IMediaControl_Pause(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_filter_state(graph, State_Paused);
hr = IMediaControl_StopWhenReady(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_filter_state(graph, State_Stopped);
hr = IMediaControl_Run(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_filter_state(graph, State_Running);
hr = IMediaControl_StopWhenReady(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_filter_state(graph, State_Stopped);
hr = IMediaControl_StopWhenReady(control);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_filter_state(graph, State_Stopped);
IReferenceClock_Release(clock);
IMediaFilter_Release(filter);
IMediaControl_Release(control);
......
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