mf: Move locking from individual command helpers to command callback.

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:13 +03:00 committed by Alexandre Julliard
parent a9e2044a11
commit 59ae49446e
1 changed files with 4 additions and 23 deletions

View File

@ -769,8 +769,6 @@ static void session_start(struct media_session *session, const GUID *time_format
struct media_source *source; struct media_source *source;
HRESULT hr; HRESULT hr;
EnterCriticalSection(&session->cs);
switch (session->state) switch (session->state)
{ {
case SESSION_STATE_STOPPED: case SESSION_STATE_STOPPED:
@ -808,8 +806,6 @@ static void session_start(struct media_session *session, const GUID *time_format
default: default:
; ;
} }
LeaveCriticalSection(&session->cs);
} }
static void session_set_paused(struct media_session *session, HRESULT status) static void session_set_paused(struct media_session *session, HRESULT status)
@ -832,8 +828,6 @@ static void session_pause(struct media_session *session)
{ {
HRESULT hr; HRESULT hr;
EnterCriticalSection(&session->cs);
switch (session->state) switch (session->state)
{ {
case SESSION_STATE_STARTED: case SESSION_STATE_STARTED:
@ -849,8 +843,6 @@ static void session_pause(struct media_session *session)
if (FAILED(hr)) if (FAILED(hr))
session_set_paused(session, hr); session_set_paused(session, hr);
LeaveCriticalSection(&session->cs);
} }
static void session_set_stopped(struct media_session *session, HRESULT status) static void session_set_stopped(struct media_session *session, HRESULT status)
@ -873,8 +865,6 @@ static void session_stop(struct media_session *session)
{ {
HRESULT hr; HRESULT hr;
EnterCriticalSection(&session->cs);
switch (session->state) switch (session->state)
{ {
case SESSION_STATE_STARTED: case SESSION_STATE_STARTED:
@ -894,8 +884,6 @@ static void session_stop(struct media_session *session)
default: default:
; ;
} }
LeaveCriticalSection(&session->cs);
} }
static HRESULT session_finalize_sinks(struct media_session *session) static HRESULT session_finalize_sinks(struct media_session *session)
@ -933,8 +921,6 @@ static void session_close(struct media_session *session)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
EnterCriticalSection(&session->cs);
switch (session->state) switch (session->state)
{ {
case SESSION_STATE_STOPPED: case SESSION_STATE_STOPPED:
@ -955,8 +941,6 @@ static void session_close(struct media_session *session)
if (FAILED(hr)) if (FAILED(hr))
session_set_closed(session, hr); session_set_closed(session, hr);
LeaveCriticalSection(&session->cs);
} }
static struct media_source *session_get_media_source(struct media_session *session, IMFMediaSource *source) static struct media_source *session_get_media_source(struct media_session *session, IMFMediaSource *source)
@ -1333,8 +1317,6 @@ static void session_set_topology(struct media_session *session, DWORD flags, IMF
} }
} }
EnterCriticalSection(&session->cs);
if (flags & MFSESSION_SETTOPOLOGY_CLEAR_CURRENT) if (flags & MFSESSION_SETTOPOLOGY_CLEAR_CURRENT)
{ {
if ((topology && topology == session->presentation.current_topology) || !topology) if ((topology && topology == session->presentation.current_topology) || !topology)
@ -1375,8 +1357,6 @@ static void session_set_topology(struct media_session *session, DWORD flags, IMF
} }
} }
LeaveCriticalSection(&session->cs);
if (resolved_topology) if (resolved_topology)
IMFTopology_Release(resolved_topology); IMFTopology_Release(resolved_topology);
} }
@ -1791,13 +1771,12 @@ static HRESULT WINAPI session_commands_callback_Invoke(IMFAsyncCallback *iface,
struct session_op *op = impl_op_from_IUnknown(IMFAsyncResult_GetStateNoAddRef(result)); struct session_op *op = impl_op_from_IUnknown(IMFAsyncResult_GetStateNoAddRef(result));
struct media_session *session = impl_from_commands_callback_IMFAsyncCallback(iface); struct media_session *session = impl_from_commands_callback_IMFAsyncCallback(iface);
EnterCriticalSection(&session->cs);
switch (op->command) switch (op->command)
{ {
case SESSION_CMD_CLEAR_TOPOLOGIES: case SESSION_CMD_CLEAR_TOPOLOGIES:
EnterCriticalSection(&session->cs);
session_clear_topologies(session); session_clear_topologies(session);
LeaveCriticalSection(&session->cs);
IMFMediaEventQueue_QueueEventParamVar(session->event_queue, MESessionTopologiesCleared, &GUID_NULL, IMFMediaEventQueue_QueueEventParamVar(session->event_queue, MESessionTopologiesCleared, &GUID_NULL,
S_OK, NULL); S_OK, NULL);
break; break;
@ -1820,6 +1799,8 @@ static HRESULT WINAPI session_commands_callback_Invoke(IMFAsyncCallback *iface,
; ;
} }
LeaveCriticalSection(&session->cs);
return S_OK; return S_OK;
} }