2 * Copyright 2010 Maarten Lankhorst for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define NONAMELESSUNION
29 #elif defined(HAVE_OPENAL_AL_H)
30 #include <OpenAL/al.h>
31 #include <OpenAL/alc.h>
38 #include "wine/debug.h"
39 #include "wine/unicode.h"
42 #include "mmdeviceapi.h"
45 #include "audioclient.h"
46 #include "endpointvolume.h"
47 #include "audiopolicy.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
55 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl;
57 typedef struct AEVImpl {
58 const IAudioEndpointVolumeExVtbl *lpVtbl;
62 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
65 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
66 *ppv = (IAudioEndpointVolume*)This;
69 This->lpVtbl = &AEVImpl_Vtbl;
74 static void AudioEndpointVolume_Destroy(AEVImpl *This)
76 HeapFree(GetProcessHeap(), 0, This);
79 static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
81 AEVImpl *This = (AEVImpl*)iface;
82 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
86 if (IsEqualIID(riid, &IID_IUnknown) ||
87 IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
88 IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) {
93 IUnknown_AddRef((IUnknown *)*ppv);
97 static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
99 AEVImpl *This = (AEVImpl*)iface;
100 ULONG ref = InterlockedIncrement(&This->ref);
101 TRACE("(%p) new ref %u\n", This, ref);
105 static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
107 AEVImpl *This = (AEVImpl*)iface;
108 ULONG ref = InterlockedDecrement(&This->ref);
109 TRACE("(%p) new ref %u\n", This, ref);
111 AudioEndpointVolume_Destroy(This);
115 static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
117 TRACE("(%p)->(%p)\n", iface, notify);
124 static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
126 TRACE("(%p)->(%p)\n", iface, notify);
133 static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
135 TRACE("(%p)->(%p)\n", iface, count);
142 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
144 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
149 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
151 TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
156 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
158 TRACE("(%p)->(%p)\n", iface, leveldb);
165 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
167 TRACE("(%p)->(%p)\n", iface, level);
174 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
176 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
181 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
183 TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
188 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
190 TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
197 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
199 TRACE("(%p)->(%u,%p)\n", iface, chan, level);
206 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
208 TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
213 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
215 TRACE("(%p)->(%p)\n", iface, mute);
222 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
224 TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
225 if (!stepsize && !stepcount)
231 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
233 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
238 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
240 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
245 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
247 TRACE("(%p)->(%p)\n", iface, mask);
254 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
256 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
257 if (!mindb || !maxdb || !inc)
263 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
265 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
266 if (!mindb || !maxdb || !inc)
272 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
276 AEV_RegisterControlChangeNotify,
277 AEV_UnregisterControlChangeNotify,
279 AEV_SetMasterVolumeLevel,
280 AEV_SetMasterVolumeLevelScalar,
281 AEV_GetMasterVolumeLevel,
282 AEV_GetMasterVolumeLevelScalar,
283 AEV_SetChannelVolumeLevel,
284 AEV_SetChannelVolumeLevelScalar,
285 AEV_GetChannelVolumeLevel,
286 AEV_GetChannelVolumeLevelScalar,
289 AEV_GetVolumeStepInfo,
292 AEV_QueryHardwareSupport,
294 AEV_GetVolumeRangeChannel