mmdevapi: Implement IAudioEndpointVolume::GetVolumeRange.

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:22 -06:00 committed by Alexandre Julliard
parent beb8986e48
commit 89de040e4f
5 changed files with 39 additions and 8 deletions

View File

@ -233,10 +233,15 @@ static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DW
static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc) static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
{ {
TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc); TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
if (!mindb || !maxdb || !inc) if (!mindb || !maxdb || !inc)
return E_POINTER; return E_POINTER;
FIXME("stub\n");
return E_NOTIMPL; *mindb = -100.f;
*maxdb = 0.f;
*inc = 1.f;
return S_OK;
} }
static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc) static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
@ -273,17 +278,17 @@ static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
AEV_GetVolumeRangeChannel AEV_GetVolumeRangeChannel
}; };
HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv) HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv)
{ {
AEVImpl *This; AEVImpl *This;
*ppv = NULL; *ppv = NULL;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl; This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
This->ref = 1; This->ref = 1;
*ppv = (IAudioEndpointVolume*)&This->IAudioEndpointVolumeEx_iface; *ppv = &This->IAudioEndpointVolumeEx_iface;
return S_OK; return S_OK;
} }

View File

@ -595,8 +595,9 @@ static HRESULT WINAPI MMDevice_Activate(IMMDevice *iface, REFIID riid, DWORD cls
if (IsEqualIID(riid, &IID_IAudioClient)){ if (IsEqualIID(riid, &IID_IAudioClient)){
hr = drvs.pGetAudioEndpoint(&This->devguid, iface, (IAudioClient**)ppv); hr = drvs.pGetAudioEndpoint(&This->devguid, iface, (IAudioClient**)ppv);
}else if (IsEqualIID(riid, &IID_IAudioEndpointVolume)) }else if (IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
hr = AudioEndpointVolume_Create(This, (IAudioEndpointVolume**)ppv); IsEqualIID(riid, &IID_IAudioEndpointVolumeEx))
hr = AudioEndpointVolume_Create(This, (IAudioEndpointVolumeEx**)ppv);
else if (IsEqualIID(riid, &IID_IAudioSessionManager) else if (IsEqualIID(riid, &IID_IAudioSessionManager)
|| IsEqualIID(riid, &IID_IAudioSessionManager2)) || IsEqualIID(riid, &IID_IAudioSessionManager2))
{ {

View File

@ -74,6 +74,6 @@ typedef struct MMDevice {
} MMDevice; } MMDevice;
extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv) DECLSPEC_HIDDEN; extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv) DECLSPEC_HIDDEN;
extern HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv) DECLSPEC_HIDDEN; extern HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv) DECLSPEC_HIDDEN;
extern const WCHAR drv_keyW[] DECLSPEC_HIDDEN; extern const WCHAR drv_keyW[] DECLSPEC_HIDDEN;

View File

@ -21,6 +21,7 @@
#define COBJMACROS #define COBJMACROS
#include "initguid.h" #include "initguid.h"
#include "endpointvolume.h"
#include "mmdeviceapi.h" #include "mmdeviceapi.h"
#include "audioclient.h" #include "audioclient.h"
#include "audiopolicy.h" #include "audiopolicy.h"

View File

@ -39,6 +39,7 @@
#include "mmsystem.h" #include "mmsystem.h"
#include "audioclient.h" #include "audioclient.h"
#include "audiopolicy.h" #include "audiopolicy.h"
#include "endpointvolume.h"
static const unsigned int win_formats[][4] = { static const unsigned int win_formats[][4] = {
{ 8000, 8, 1}, { 8000, 8, 2}, { 8000, 16, 1}, { 8000, 16, 2}, { 8000, 8, 1}, { 8000, 8, 2}, { 8000, 16, 1}, { 8000, 16, 2},
@ -2242,6 +2243,28 @@ static void test_marshal(void)
} }
static void test_endpointvolume(void)
{
HRESULT hr;
IAudioEndpointVolume *aev;
float mindb, maxdb, increment;
hr = IMMDevice_Activate(dev, &IID_IAudioEndpointVolume,
CLSCTX_INPROC_SERVER, NULL, (void**)&aev);
ok(hr == S_OK, "Activation failed with %08x\n", hr);
if(hr != S_OK)
return;
hr = IAudioEndpointVolume_GetVolumeRange(aev, &mindb, NULL, NULL);
ok(hr == E_POINTER, "GetVolumeRange should have failed with E_POINTER: 0x%08x\n", hr);
hr = IAudioEndpointVolume_GetVolumeRange(aev, &mindb, &maxdb, &increment);
ok(hr == S_OK, "GetVolumeRange failed: 0x%08x\n", hr);
trace("got range: [%f,%f]/%f\n", mindb, maxdb, increment);
IAudioEndpointVolume_Release(aev);
}
START_TEST(render) START_TEST(render)
{ {
HRESULT hr; HRESULT hr;
@ -2283,6 +2306,7 @@ START_TEST(render)
test_volume_dependence(); test_volume_dependence();
test_session_creation(); test_session_creation();
test_worst_case(); test_worst_case();
test_endpointvolume();
IMMDevice_Release(dev); IMMDevice_Release(dev);