From 58f468038013db22ba1905d57df0eb58caad5dbb Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 29 May 2020 21:28:40 +0300 Subject: [PATCH] mfmediaengine: Send "pause" event on Pause(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfmediaengine/main.c | 21 +++++++++++++++++++-- dlls/mfmediaengine/tests/mfmediaengine.c | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 13cbeb4b8db..fcef1be048f 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -476,9 +476,26 @@ static HRESULT WINAPI media_engine_Play(IMFMediaEngine *iface) static HRESULT WINAPI media_engine_Pause(IMFMediaEngine *iface) { - FIXME("(%p): stub.\n", iface); + struct media_engine *engine = impl_from_IMFMediaEngine(iface); - return E_NOTIMPL; + TRACE("%p.\n", iface); + + EnterCriticalSection(&engine->cs); + + if (!(engine->flags & FLAGS_ENGINE_PAUSED)) + { + engine->flags &= ~FLAGS_ENGINE_WAITING; + engine->flags |= FLAGS_ENGINE_PAUSED; + + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_TIMEUPDATE, 0, 0); + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PAUSE, 0, 0); + } + + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS, 0, 0); + + LeaveCriticalSection(&engine->cs); + + return S_OK; } static BOOL WINAPI media_engine_GetMuted(IMFMediaEngine *iface) diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c index e7cb6432b92..a3db611e9fc 100644 --- a/dlls/mfmediaengine/tests/mfmediaengine.c +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -421,6 +421,23 @@ static void test_Play(void) ok(!ret, "Unexpected state %d.\n", ret); IMFMediaEngine_Release(media_engine); + + /* Play -> Pause */ + media_engine = create_media_engine(callback); + + hr = IMFMediaEngine_Play(media_engine); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + ret = IMFMediaEngine_IsPaused(media_engine); + ok(!ret, "Unexpected state %d.\n", ret); + + hr = IMFMediaEngine_Pause(media_engine); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + ret = IMFMediaEngine_IsPaused(media_engine); + ok(!!ret, "Unexpected state %d.\n", ret); + + IMFMediaEngine_Release(media_engine); } START_TEST(mfmediaengine)