Commit 5ec5eb07 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Add a helper to check for session shutdown state.

parent 0b4e4601
...@@ -454,14 +454,17 @@ static HRESULT create_session_op(enum session_command command, struct session_op ...@@ -454,14 +454,17 @@ static HRESULT create_session_op(enum session_command command, struct session_op
return S_OK; return S_OK;
} }
static HRESULT session_is_shut_down(struct media_session *session)
{
return session->state == SESSION_STATE_SHUT_DOWN ? MF_E_SHUTDOWN : S_OK;
}
static HRESULT session_submit_command(struct media_session *session, struct session_op *op) static HRESULT session_submit_command(struct media_session *session, struct session_op *op)
{ {
HRESULT hr; HRESULT hr;
EnterCriticalSection(&session->cs); EnterCriticalSection(&session->cs);
if (session->state == SESSION_STATE_SHUT_DOWN) if (SUCCEEDED(hr = session_is_shut_down(session)))
hr = MF_E_SHUTDOWN;
else
hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &session->commands_callback, &op->IUnknown_iface); hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &session->commands_callback, &op->IUnknown_iface);
LeaveCriticalSection(&session->cs); LeaveCriticalSection(&session->cs);
...@@ -707,7 +710,6 @@ static void session_stop(struct media_session *session) ...@@ -707,7 +710,6 @@ static void session_stop(struct media_session *session)
LeaveCriticalSection(&session->cs); 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)
{ {
struct media_source *cur; struct media_source *cur;
...@@ -1347,9 +1349,7 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface) ...@@ -1347,9 +1349,7 @@ static HRESULT WINAPI mfsession_Shutdown(IMFMediaSession *iface)
FIXME("%p.\n", iface); FIXME("%p.\n", iface);
EnterCriticalSection(&session->cs); EnterCriticalSection(&session->cs);
if (session->state == SESSION_STATE_SHUT_DOWN) if (SUCCEEDED(hr = session_is_shut_down(session)))
hr = MF_E_SHUTDOWN;
else
{ {
session->state = SESSION_STATE_SHUT_DOWN; session->state = SESSION_STATE_SHUT_DOWN;
IMFMediaEventQueue_Shutdown(session->event_queue); IMFMediaEventQueue_Shutdown(session->event_queue);
...@@ -1384,9 +1384,7 @@ static HRESULT WINAPI mfsession_GetSessionCapabilities(IMFMediaSession *iface, D ...@@ -1384,9 +1384,7 @@ static HRESULT WINAPI mfsession_GetSessionCapabilities(IMFMediaSession *iface, D
return E_POINTER; return E_POINTER;
EnterCriticalSection(&session->cs); EnterCriticalSection(&session->cs);
if (session->state == SESSION_STATE_SHUT_DOWN) if (SUCCEEDED(hr = session_is_shut_down(session)))
hr = MF_E_SHUTDOWN;
else
*caps = session->caps; *caps = session->caps;
LeaveCriticalSection(&session->cs); LeaveCriticalSection(&session->cs);
......
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