mfmediaengine: Handle shutdown state in Play().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-01-28 10:17:10 +03:00 committed by Alexandre Julliard
parent 86c0afc797
commit 0f4f7ca937
2 changed files with 19 additions and 14 deletions

View File

@ -1784,31 +1784,37 @@ static HRESULT WINAPI media_engine_SetLoop(IMFMediaEngineEx *iface, BOOL loop)
static HRESULT WINAPI media_engine_Play(IMFMediaEngineEx *iface) static HRESULT WINAPI media_engine_Play(IMFMediaEngineEx *iface)
{ {
struct media_engine *engine = impl_from_IMFMediaEngineEx(iface); struct media_engine *engine = impl_from_IMFMediaEngineEx(iface);
HRESULT hr = S_OK;
TRACE("%p.\n", iface); TRACE("%p.\n", iface);
EnterCriticalSection(&engine->cs); EnterCriticalSection(&engine->cs);
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS, 0, 0); if (engine->flags & FLAGS_ENGINE_SHUT_DOWN)
hr = MF_E_SHUTDOWN;
if (!(engine->flags & FLAGS_ENGINE_WAITING)) else
{ {
media_engine_set_flag(engine, FLAGS_ENGINE_PAUSED | FLAGS_ENGINE_IS_ENDED, FALSE); IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS, 0, 0);
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PLAY, 0, 0);
if (!(engine->flags & FLAGS_ENGINE_SOURCE_PENDING)) if (!(engine->flags & FLAGS_ENGINE_WAITING))
media_engine_start_playback(engine); {
else media_engine_set_flag(engine, FLAGS_ENGINE_PAUSED | FLAGS_ENGINE_IS_ENDED, FALSE);
media_engine_set_flag(engine, FLAGS_ENGINE_PLAY_PENDING, TRUE); 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); LeaveCriticalSection(&engine->cs);
return S_OK; return hr;
} }
static HRESULT WINAPI media_engine_Pause(IMFMediaEngineEx *iface) static HRESULT WINAPI media_engine_Pause(IMFMediaEngineEx *iface)

View File

@ -414,7 +414,6 @@ todo_wine
ok(!!state, "Unexpected state.\n"); ok(!!state, "Unexpected state.\n");
hr = IMFMediaEngine_Play(media_engine); hr = IMFMediaEngine_Play(media_engine);
todo_wine
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFMediaEngine_Pause(media_engine); hr = IMFMediaEngine_Pause(media_engine);