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
28 #elif defined(HAVE_OPENAL_AL_H)
29 #include <OpenAL/al.h>
30 #include <OpenAL/alc.h>
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
41 #include "mmdeviceapi.h"
44 #include "audioclient.h"
45 #include "endpointvolume.h"
46 #include "audiopolicy.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi
);
54 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl
;
56 typedef struct AEVImpl
{
57 const IAudioEndpointVolumeExVtbl
*lpVtbl
;
61 HRESULT
AudioEndpointVolume_Create(MMDevice
*parent
, IAudioEndpointVolume
**ppv
)
64 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*This
));
65 *ppv
= (IAudioEndpointVolume
*)This
;
68 This
->lpVtbl
= &AEVImpl_Vtbl
;
73 static void AudioEndpointVolume_Destroy(AEVImpl
*This
)
75 HeapFree(GetProcessHeap(), 0, This
);
78 static HRESULT WINAPI
AEV_QueryInterface(IAudioEndpointVolumeEx
*iface
, REFIID riid
, void **ppv
)
80 AEVImpl
*This
= (AEVImpl
*)iface
;
81 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
85 if (IsEqualIID(riid
, &IID_IUnknown
) ||
86 IsEqualIID(riid
, &IID_IAudioEndpointVolume
) ||
87 IsEqualIID(riid
, &IID_IAudioEndpointVolumeEx
)) {
92 IUnknown_AddRef((IUnknown
*)*ppv
);
96 static ULONG WINAPI
AEV_AddRef(IAudioEndpointVolumeEx
*iface
)
98 AEVImpl
*This
= (AEVImpl
*)iface
;
99 ULONG ref
= InterlockedIncrement(&This
->ref
);
100 TRACE("(%p) new ref %u\n", This
, ref
);
104 static ULONG WINAPI
AEV_Release(IAudioEndpointVolumeEx
*iface
)
106 AEVImpl
*This
= (AEVImpl
*)iface
;
107 ULONG ref
= InterlockedDecrement(&This
->ref
);
108 TRACE("(%p) new ref %u\n", This
, ref
);
110 AudioEndpointVolume_Destroy(This
);
114 static HRESULT WINAPI
AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx
*iface
, IAudioEndpointVolumeCallback
*notify
)
116 TRACE("(%p)->(%p)\n", iface
, notify
);
123 static HRESULT WINAPI
AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx
*iface
, IAudioEndpointVolumeCallback
*notify
)
125 TRACE("(%p)->(%p)\n", iface
, notify
);
132 static HRESULT WINAPI
AEV_GetChannelCount(IAudioEndpointVolumeEx
*iface
, UINT
*count
)
134 TRACE("(%p)->(%p)\n", iface
, count
);
141 static HRESULT WINAPI
AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx
*iface
, float leveldb
, const GUID
*ctx
)
143 TRACE("(%p)->(%f,%s)\n", iface
, leveldb
, debugstr_guid(ctx
));
148 static HRESULT WINAPI
AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, float level
, const GUID
*ctx
)
150 TRACE("(%p)->(%f,%s)\n", iface
, level
, debugstr_guid(ctx
));
155 static HRESULT WINAPI
AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx
*iface
, float *leveldb
)
157 TRACE("(%p)->(%p)\n", iface
, leveldb
);
164 static HRESULT WINAPI
AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, float *level
)
166 TRACE("(%p)->(%p)\n", iface
, level
);
173 static HRESULT WINAPI
AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float leveldb
, const GUID
*ctx
)
175 TRACE("(%p)->(%f,%s)\n", iface
, leveldb
, debugstr_guid(ctx
));
180 static HRESULT WINAPI
AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, UINT chan
, float level
, const GUID
*ctx
)
182 TRACE("(%p)->(%u,%f,%s)\n", iface
, chan
, level
, debugstr_guid(ctx
));
187 static HRESULT WINAPI
AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *leveldb
)
189 TRACE("(%p)->(%u,%p)\n", iface
, chan
, leveldb
);
196 static HRESULT WINAPI
AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *level
)
198 TRACE("(%p)->(%u,%p)\n", iface
, chan
, level
);
205 static HRESULT WINAPI
AEV_SetMute(IAudioEndpointVolumeEx
*iface
, BOOL mute
, const GUID
*ctx
)
207 TRACE("(%p)->(%u,%s)\n", iface
, mute
, debugstr_guid(ctx
));
212 static HRESULT WINAPI
AEV_GetMute(IAudioEndpointVolumeEx
*iface
, BOOL
*mute
)
214 TRACE("(%p)->(%p)\n", iface
, mute
);
221 static HRESULT WINAPI
AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx
*iface
, UINT
*stepsize
, UINT
*stepcount
)
223 TRACE("(%p)->(%p,%p)\n", iface
, stepsize
, stepcount
);
224 if (!stepsize
&& !stepcount
)
230 static HRESULT WINAPI
AEV_VolumeStepUp(IAudioEndpointVolumeEx
*iface
, const GUID
*ctx
)
232 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(ctx
));
237 static HRESULT WINAPI
AEV_VolumeStepDown(IAudioEndpointVolumeEx
*iface
, const GUID
*ctx
)
239 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(ctx
));
244 static HRESULT WINAPI
AEV_QueryHardwareSupport(IAudioEndpointVolumeEx
*iface
, DWORD
*mask
)
246 TRACE("(%p)->(%p)\n", iface
, mask
);
253 static HRESULT WINAPI
AEV_GetVolumeRange(IAudioEndpointVolumeEx
*iface
, float *mindb
, float *maxdb
, float *inc
)
255 TRACE("(%p)->(%p,%p,%p)\n", iface
, mindb
, maxdb
, inc
);
256 if (!mindb
|| !maxdb
|| !inc
)
262 static HRESULT WINAPI
AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *mindb
, float *maxdb
, float *inc
)
264 TRACE("(%p)->(%p,%p,%p)\n", iface
, mindb
, maxdb
, inc
);
265 if (!mindb
|| !maxdb
|| !inc
)
271 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl
= {
275 AEV_RegisterControlChangeNotify
,
276 AEV_UnregisterControlChangeNotify
,
278 AEV_SetMasterVolumeLevel
,
279 AEV_SetMasterVolumeLevelScalar
,
280 AEV_GetMasterVolumeLevel
,
281 AEV_GetMasterVolumeLevelScalar
,
282 AEV_SetChannelVolumeLevel
,
283 AEV_SetChannelVolumeLevelScalar
,
284 AEV_GetChannelVolumeLevel
,
285 AEV_GetChannelVolumeLevelScalar
,
288 AEV_GetVolumeStepInfo
,
291 AEV_QueryHardwareSupport
,
293 AEV_GetVolumeRangeChannel