quartz: Implement IMediaControl::StopWhenReady().

This allows The Bunker to exit cleanly.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-05-18 15:57:59 -05:00 committed by Alexandre Julliard
parent 925e5ddefe
commit fe5292bf50
2 changed files with 74 additions and 2 deletions

View File

@ -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;
FIXME("(%p/%p)->(): stub !!!\n", This, iface);
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;
}
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;
}

View File

@ -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);