mf: Add a helper for session commands without parameters.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-05-11 17:53:10 +03:00 committed by Alexandre Julliard
parent 23543f2005
commit 741016dd32
1 changed files with 17 additions and 36 deletions

View File

@ -536,6 +536,19 @@ static HRESULT session_submit_command(struct media_session *session, struct sess
return hr;
}
static HRESULT session_submit_simple_command(struct media_session *session, enum session_command command)
{
struct session_op *op;
HRESULT hr;
if (FAILED(hr = create_session_op(command, &op)))
return hr;
hr = session_submit_command(session, op);
IUnknown_Release(&op->IUnknown_iface);
return hr;
}
static void session_clear_topologies(struct media_session *session)
{
struct queued_topology *ptr, *next;
@ -1499,18 +1512,10 @@ static HRESULT WINAPI mfsession_SetTopology(IMFMediaSession *iface, DWORD flags,
static HRESULT WINAPI mfsession_ClearTopologies(IMFMediaSession *iface)
{
struct media_session *session = impl_from_IMFMediaSession(iface);
struct session_op *op;
HRESULT hr;
TRACE("%p.\n", iface);
if (FAILED(hr = create_session_op(SESSION_CMD_CLEAR_TOPOLOGIES, &op)))
return hr;
hr = session_submit_command(session, op);
IUnknown_Release(&op->IUnknown_iface);
return hr;
return session_submit_simple_command(session, SESSION_CMD_CLEAR_TOPOLOGIES);
}
static HRESULT WINAPI mfsession_Start(IMFMediaSession *iface, const GUID *format, const PROPVARIANT *start_position)
@ -1541,52 +1546,28 @@ static HRESULT WINAPI mfsession_Start(IMFMediaSession *iface, const GUID *format
static HRESULT WINAPI mfsession_Pause(IMFMediaSession *iface)
{
struct media_session *session = impl_from_IMFMediaSession(iface);
struct session_op *op;
HRESULT hr;
TRACE("%p.\n", iface);
if (FAILED(hr = create_session_op(SESSION_CMD_PAUSE, &op)))
return hr;
hr = session_submit_command(session, op);
IUnknown_Release(&op->IUnknown_iface);
return hr;
return session_submit_simple_command(session, SESSION_CMD_PAUSE);
}
static HRESULT WINAPI mfsession_Stop(IMFMediaSession *iface)
{
struct media_session *session = impl_from_IMFMediaSession(iface);
struct session_op *op;
HRESULT hr;
TRACE("%p.\n", iface);
if (FAILED(hr = create_session_op(SESSION_CMD_STOP, &op)))
return hr;
hr = session_submit_command(session, op);
IUnknown_Release(&op->IUnknown_iface);
return hr;
return session_submit_simple_command(session, SESSION_CMD_STOP);
}
static HRESULT WINAPI mfsession_Close(IMFMediaSession *iface)
{
struct media_session *session = impl_from_IMFMediaSession(iface);
struct session_op *op;
HRESULT hr;
TRACE("%p.\n", iface);
if (FAILED(hr = create_session_op(SESSION_CMD_CLOSE, &op)))
return hr;
hr = session_submit_command(session, op);
IUnknown_Release(&op->IUnknown_iface);
return hr;
return session_submit_simple_command(session, SESSION_CMD_CLOSE);
}
static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface)