Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319/* * Copyright 2010 Maarten Lankhorst for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
#define COBJMACROS
#include <stdarg.h>
#include "windef.h"#include "winbase.h"#include "winnls.h"#include "winreg.h"#include "wine/debug.h"
#include "ole2.h"#include "mmdeviceapi.h"#include "mmsystem.h"#include "dsound.h"#include "audioclient.h"#include "endpointvolume.h"#include "audiopolicy.h"
#include "mmdevapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
typedef struct AEVImpl { IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface; LONG ref; float master_vol; BOOL mute;} AEVImpl;
static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface){ return CONTAINING_RECORD(iface, AEVImpl, IAudioEndpointVolumeEx_iface);}
static void AudioEndpointVolume_Destroy(AEVImpl *This){ HeapFree(GetProcessHeap(), 0, This);}
static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv){ AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv); if (!ppv) return E_POINTER; *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IAudioEndpointVolume) || IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) { *ppv = &This->IAudioEndpointVolumeEx_iface; } else return E_NOINTERFACE; IUnknown_AddRef((IUnknown *)*ppv); return S_OK;}
static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface){ AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); ULONG ref = InterlockedIncrement(&This->ref); TRACE("(%p) new ref %u\n", This, ref); return ref;}
static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface){ AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) new ref %u\n", This, ref); if (!ref) AudioEndpointVolume_Destroy(This); return ref;}
static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify){ TRACE("(%p)->(%p)\n", iface, notify); if (!notify) return E_POINTER; FIXME("stub\n"); return S_OK;}
static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify){ TRACE("(%p)->(%p)\n", iface, notify); if (!notify) return E_POINTER; FIXME("stub\n"); return S_OK;}
static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count){ TRACE("(%p)->(%p)\n", iface, count); if (!count) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
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));
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){ TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx)); FIXME("stub\n"); return E_NOTIMPL;}
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;
*leveldb = This->master_vol;
return S_OK;}
static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level){ TRACE("(%p)->(%p)\n", iface, level); if (!level) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx){ TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx)); FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx){ TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx)); FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb){ TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb); if (!leveldb) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level){ TRACE("(%p)->(%u,%p)\n", iface, chan, level); if (!level) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx){ AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface); HRESULT ret;
TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
ret = This->mute == mute ? S_FALSE : S_OK;
This->mute = mute;
return ret;}
static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute){ AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
TRACE("(%p)->(%p)\n", iface, mute);
if (!mute) return E_POINTER;
*mute = This->mute;
return S_OK;}
static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount){ TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount); if (!stepsize && !stepcount) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx){ TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx)); FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx){ TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx)); FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask){ TRACE("(%p)->(%p)\n", iface, mask); if (!mask) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc){ TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
if (!mindb || !maxdb || !inc) return E_POINTER;
*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){ TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc); if (!mindb || !maxdb || !inc) return E_POINTER; FIXME("stub\n"); return E_NOTIMPL;}
static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = { AEV_QueryInterface, AEV_AddRef, AEV_Release, AEV_RegisterControlChangeNotify, AEV_UnregisterControlChangeNotify, AEV_GetChannelCount, AEV_SetMasterVolumeLevel, AEV_SetMasterVolumeLevelScalar, AEV_GetMasterVolumeLevel, AEV_GetMasterVolumeLevelScalar, AEV_SetChannelVolumeLevel, AEV_SetChannelVolumeLevelScalar, AEV_GetChannelVolumeLevel, AEV_GetChannelVolumeLevelScalar, AEV_SetMute, AEV_GetMute, AEV_GetVolumeStepInfo, AEV_VolumeStepUp, AEV_VolumeStepDown, AEV_QueryHardwareSupport, AEV_GetVolumeRange, AEV_GetVolumeRangeChannel};
HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv){ AEVImpl *This;
*ppv = NULL; This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This)); if (!This) return E_OUTOFMEMORY; This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl; This->ref = 1;
*ppv = &This->IAudioEndpointVolumeEx_iface; return S_OK;}