From 0f4f7ca9379aae020a2afcd6605a8d7595274af9 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 28 Jan 2022 10:17:10 +0300 Subject: [PATCH] mfmediaengine: Handle shutdown state in Play(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfmediaengine/main.c | 32 ++++++++++++++---------- dlls/mfmediaengine/tests/mfmediaengine.c | 1 - 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 99beb17e429..87851cee9c4 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -1784,31 +1784,37 @@ static HRESULT WINAPI media_engine_SetLoop(IMFMediaEngineEx *iface, BOOL loop) static HRESULT WINAPI media_engine_Play(IMFMediaEngineEx *iface) { struct media_engine *engine = impl_from_IMFMediaEngineEx(iface); + HRESULT hr = S_OK; TRACE("%p.\n", iface); EnterCriticalSection(&engine->cs); - IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS, 0, 0); - - if (!(engine->flags & FLAGS_ENGINE_WAITING)) + if (engine->flags & FLAGS_ENGINE_SHUT_DOWN) + hr = MF_E_SHUTDOWN; + else { - media_engine_set_flag(engine, FLAGS_ENGINE_PAUSED | FLAGS_ENGINE_IS_ENDED, FALSE); - IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PLAY, 0, 0); + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS, 0, 0); - if (!(engine->flags & FLAGS_ENGINE_SOURCE_PENDING)) - media_engine_start_playback(engine); - else - media_engine_set_flag(engine, FLAGS_ENGINE_PLAY_PENDING, TRUE); + if (!(engine->flags & FLAGS_ENGINE_WAITING)) + { + media_engine_set_flag(engine, FLAGS_ENGINE_PAUSED | FLAGS_ENGINE_IS_ENDED, FALSE); + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PLAY, 0, 0); - media_engine_set_flag(engine, FLAGS_ENGINE_WAITING, TRUE); + if (!(engine->flags & FLAGS_ENGINE_SOURCE_PENDING)) + media_engine_start_playback(engine); + else + media_engine_set_flag(engine, FLAGS_ENGINE_PLAY_PENDING, TRUE); + + media_engine_set_flag(engine, FLAGS_ENGINE_WAITING, TRUE); + } + + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_WAITING, 0, 0); } - IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_WAITING, 0, 0); - LeaveCriticalSection(&engine->cs); - return S_OK; + return hr; } static HRESULT WINAPI media_engine_Pause(IMFMediaEngineEx *iface) diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c index 6448e7f2169..ac34bd7c4cd 100644 --- a/dlls/mfmediaengine/tests/mfmediaengine.c +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -414,7 +414,6 @@ todo_wine ok(!!state, "Unexpected state.\n"); hr = IMFMediaEngine_Play(media_engine); -todo_wine ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); hr = IMFMediaEngine_Pause(media_engine);