mmdevapi: Implement Set/GetMasterVolumeLevel.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2016-03-09 12:41:25 -06:00 committed by Alexandre Julliard
parent 89de040e4f
commit 982d005da5
2 changed files with 27 additions and 5 deletions

View File

@ -43,6 +43,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
typedef struct AEVImpl { typedef struct AEVImpl {
IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface; IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
LONG ref; LONG ref;
float master_vol;
} AEVImpl; } AEVImpl;
static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface) 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) 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)); 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) 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) static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
{ {
AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
TRACE("(%p)->(%p)\n", iface, leveldb); TRACE("(%p)->(%p)\n", iface, leveldb);
if (!leveldb) if (!leveldb)
return E_POINTER; 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) static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)

View File

@ -2247,7 +2247,7 @@ static void test_endpointvolume(void)
{ {
HRESULT hr; HRESULT hr;
IAudioEndpointVolume *aev; IAudioEndpointVolume *aev;
float mindb, maxdb, increment; float mindb, maxdb, increment, volume;
hr = IMMDevice_Activate(dev, &IID_IAudioEndpointVolume, hr = IMMDevice_Activate(dev, &IID_IAudioEndpointVolume,
CLSCTX_INPROC_SERVER, NULL, (void**)&aev); 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); ok(hr == S_OK, "GetVolumeRange failed: 0x%08x\n", hr);
trace("got range: [%f,%f]/%f\n", mindb, maxdb, increment); 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); IAudioEndpointVolume_Release(aev);
} }