From 982d005da56c5c6f771987c6f724018daa5735ba Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Wed, 9 Mar 2016 12:41:25 -0600 Subject: [PATCH] mmdevapi: Implement Set/GetMasterVolumeLevel. Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/mmdevapi/audiovolume.c | 21 +++++++++++++++++---- dlls/mmdevapi/tests/render.c | 11 ++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dlls/mmdevapi/audiovolume.c b/dlls/mmdevapi/audiovolume.c index a49d2e93db2..742823c5fd5 100644 --- a/dlls/mmdevapi/audiovolume.c +++ b/dlls/mmdevapi/audiovolume.c @@ -43,6 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi); typedef struct AEVImpl { IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface; LONG ref; + float master_vol; } AEVImpl; static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface) @@ -120,9 +121,16 @@ static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *c static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx) { + AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); + TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx)); - FIXME("stub\n"); - return E_NOTIMPL; + + if(leveldb < -100.f || leveldb > 0.f) + return E_INVALIDARG; + + This->master_vol = leveldb; + + return S_OK; } static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx) @@ -134,11 +142,16 @@ static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *ifa static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb) { + AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); + TRACE("(%p)->(%p)\n", iface, leveldb); + if (!leveldb) return E_POINTER; - FIXME("stub\n"); - return E_NOTIMPL; + + *leveldb = This->master_vol; + + return S_OK; } static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level) diff --git a/dlls/mmdevapi/tests/render.c b/dlls/mmdevapi/tests/render.c index 1476adc6878..1e8a5f191c2 100644 --- a/dlls/mmdevapi/tests/render.c +++ b/dlls/mmdevapi/tests/render.c @@ -2247,7 +2247,7 @@ static void test_endpointvolume(void) { HRESULT hr; IAudioEndpointVolume *aev; - float mindb, maxdb, increment; + float mindb, maxdb, increment, volume; hr = IMMDevice_Activate(dev, &IID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, NULL, (void**)&aev); @@ -2262,6 +2262,15 @@ static void test_endpointvolume(void) ok(hr == S_OK, "GetVolumeRange failed: 0x%08x\n", hr); trace("got range: [%f,%f]/%f\n", mindb, maxdb, increment); + hr = IAudioEndpointVolume_SetMasterVolumeLevel(aev, mindb - increment, NULL); + ok(hr == E_INVALIDARG, "SetMasterVolumeLevel failed: 0x%08x\n", hr); + + hr = IAudioEndpointVolume_GetMasterVolumeLevel(aev, &volume); + ok(hr == S_OK, "GetMasterVolumeLevel failed: 0x%08x\n", hr); + + hr = IAudioEndpointVolume_SetMasterVolumeLevel(aev, volume, NULL); + ok(hr == S_OK, "SetMasterVolumeLevel failed: 0x%08x\n", hr); + IAudioEndpointVolume_Release(aev); } -- 2.11.4.GIT