From e9cc1d58b4e5aa6c19a5d15f2da1675b635f95a4 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 2 Jun 2020 11:41:06 +0300 Subject: [PATCH] mfmediaengine: Send "volumechange" event on volume change. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfmediaengine/main.c | 30 ++++++++++++++++++++---- dlls/mfmediaengine/tests/mfmediaengine.c | 2 -- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 731bccb581d..59006e64ca7 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -79,6 +79,7 @@ struct media_engine unsigned int flags; double playback_rate; double default_playback_rate; + double volume; IMFMediaSession *session; CRITICAL_SECTION cs; }; @@ -577,16 +578,36 @@ static HRESULT WINAPI media_engine_SetMuted(IMFMediaEngine *iface, BOOL muted) static double WINAPI media_engine_GetVolume(IMFMediaEngine *iface) { - FIXME("(%p): stub.\n", iface); + struct media_engine *engine = impl_from_IMFMediaEngine(iface); + double volume; - return 0.0; + TRACE("%p.\n", iface); + + EnterCriticalSection(&engine->cs); + volume = engine->volume; + LeaveCriticalSection(&engine->cs); + + return volume; } static HRESULT WINAPI media_engine_SetVolume(IMFMediaEngine *iface, double volume) { - FIXME("(%p, %f): stub.\n", iface, volume); + struct media_engine *engine = impl_from_IMFMediaEngine(iface); + HRESULT hr = S_OK; - return E_NOTIMPL; + TRACE("%p, %f.\n", iface, volume); + + EnterCriticalSection(&engine->cs); + if (engine->flags & FLAGS_ENGINE_SHUT_DOWN) + hr = MF_E_SHUTDOWN; + else if (volume != engine->volume) + { + engine->volume = volume; + IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_VOLUMECHANGE, 0, 0); + } + LeaveCriticalSection(&engine->cs); + + return hr; } static BOOL WINAPI media_engine_HasVideo(IMFMediaEngine *iface) @@ -737,6 +758,7 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct engine->flags = (flags & MF_MEDIA_ENGINE_CREATEFLAGS_MASK) | FLAGS_ENGINE_PAUSED; engine->default_playback_rate = 1.0; engine->playback_rate = 1.0; + engine->volume = 1.0; InitializeCriticalSection(&engine->cs); hr = IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_CALLBACK, &IID_IMFMediaEngineNotify, diff --git a/dlls/mfmediaengine/tests/mfmediaengine.c b/dlls/mfmediaengine/tests/mfmediaengine.c index 0839d1d4451..a5b80ef25f4 100644 --- a/dlls/mfmediaengine/tests/mfmediaengine.c +++ b/dlls/mfmediaengine/tests/mfmediaengine.c @@ -364,11 +364,9 @@ todo_wine ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); val = IMFMediaEngine_GetVolume(media_engine); -todo_wine ok(val == 1.0, "Unexpected value %f.\n", val); hr = IMFMediaEngine_SetVolume(media_engine, 2.0); -todo_wine ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr); state = IMFMediaEngine_HasVideo(media_engine);