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 IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface
;
61 static inline AEVImpl
*impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx
*iface
)
63 return CONTAINING_RECORD(iface
, AEVImpl
, IAudioEndpointVolumeEx_iface
);
66 HRESULT
AudioEndpointVolume_Create(MMDevice
*parent
, IAudioEndpointVolume
**ppv
)
69 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*This
));
70 *ppv
= (IAudioEndpointVolume
*)This
;
73 This
->IAudioEndpointVolumeEx_iface
.lpVtbl
= &AEVImpl_Vtbl
;
78 static void AudioEndpointVolume_Destroy(AEVImpl
*This
)
80 HeapFree(GetProcessHeap(), 0, This
);
83 static HRESULT WINAPI
AEV_QueryInterface(IAudioEndpointVolumeEx
*iface
, REFIID riid
, void **ppv
)
85 AEVImpl
*This
= impl_from_IAudioEndpointVolumeEx(iface
);
86 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
90 if (IsEqualIID(riid
, &IID_IUnknown
) ||
91 IsEqualIID(riid
, &IID_IAudioEndpointVolume
) ||
92 IsEqualIID(riid
, &IID_IAudioEndpointVolumeEx
)) {
97 IUnknown_AddRef((IUnknown
*)*ppv
);
101 static ULONG WINAPI
AEV_AddRef(IAudioEndpointVolumeEx
*iface
)
103 AEVImpl
*This
= impl_from_IAudioEndpointVolumeEx(iface
);
104 ULONG ref
= InterlockedIncrement(&This
->ref
);
105 TRACE("(%p) new ref %u\n", This
, ref
);
109 static ULONG WINAPI
AEV_Release(IAudioEndpointVolumeEx
*iface
)
111 AEVImpl
*This
= impl_from_IAudioEndpointVolumeEx(iface
);
112 ULONG ref
= InterlockedDecrement(&This
->ref
);
113 TRACE("(%p) new ref %u\n", This
, ref
);
115 AudioEndpointVolume_Destroy(This
);
119 static HRESULT WINAPI
AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx
*iface
, IAudioEndpointVolumeCallback
*notify
)
121 TRACE("(%p)->(%p)\n", iface
, notify
);
128 static HRESULT WINAPI
AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx
*iface
, IAudioEndpointVolumeCallback
*notify
)
130 TRACE("(%p)->(%p)\n", iface
, notify
);
137 static HRESULT WINAPI
AEV_GetChannelCount(IAudioEndpointVolumeEx
*iface
, UINT
*count
)
139 TRACE("(%p)->(%p)\n", iface
, count
);
146 static HRESULT WINAPI
AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx
*iface
, float leveldb
, const GUID
*ctx
)
148 TRACE("(%p)->(%f,%s)\n", iface
, leveldb
, debugstr_guid(ctx
));
153 static HRESULT WINAPI
AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, float level
, const GUID
*ctx
)
155 TRACE("(%p)->(%f,%s)\n", iface
, level
, debugstr_guid(ctx
));
160 static HRESULT WINAPI
AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx
*iface
, float *leveldb
)
162 TRACE("(%p)->(%p)\n", iface
, leveldb
);
169 static HRESULT WINAPI
AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, float *level
)
171 TRACE("(%p)->(%p)\n", iface
, level
);
178 static HRESULT WINAPI
AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float leveldb
, const GUID
*ctx
)
180 TRACE("(%p)->(%f,%s)\n", iface
, leveldb
, debugstr_guid(ctx
));
185 static HRESULT WINAPI
AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, UINT chan
, float level
, const GUID
*ctx
)
187 TRACE("(%p)->(%u,%f,%s)\n", iface
, chan
, level
, debugstr_guid(ctx
));
192 static HRESULT WINAPI
AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *leveldb
)
194 TRACE("(%p)->(%u,%p)\n", iface
, chan
, leveldb
);
201 static HRESULT WINAPI
AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *level
)
203 TRACE("(%p)->(%u,%p)\n", iface
, chan
, level
);
210 static HRESULT WINAPI
AEV_SetMute(IAudioEndpointVolumeEx
*iface
, BOOL mute
, const GUID
*ctx
)
212 TRACE("(%p)->(%u,%s)\n", iface
, mute
, debugstr_guid(ctx
));
217 static HRESULT WINAPI
AEV_GetMute(IAudioEndpointVolumeEx
*iface
, BOOL
*mute
)
219 TRACE("(%p)->(%p)\n", iface
, mute
);
226 static HRESULT WINAPI
AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx
*iface
, UINT
*stepsize
, UINT
*stepcount
)
228 TRACE("(%p)->(%p,%p)\n", iface
, stepsize
, stepcount
);
229 if (!stepsize
&& !stepcount
)
235 static HRESULT WINAPI
AEV_VolumeStepUp(IAudioEndpointVolumeEx
*iface
, const GUID
*ctx
)
237 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(ctx
));
242 static HRESULT WINAPI
AEV_VolumeStepDown(IAudioEndpointVolumeEx
*iface
, const GUID
*ctx
)
244 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(ctx
));
249 static HRESULT WINAPI
AEV_QueryHardwareSupport(IAudioEndpointVolumeEx
*iface
, DWORD
*mask
)
251 TRACE("(%p)->(%p)\n", iface
, mask
);
258 static HRESULT WINAPI
AEV_GetVolumeRange(IAudioEndpointVolumeEx
*iface
, float *mindb
, float *maxdb
, float *inc
)
260 TRACE("(%p)->(%p,%p,%p)\n", iface
, mindb
, maxdb
, inc
);
261 if (!mindb
|| !maxdb
|| !inc
)
267 static HRESULT WINAPI
AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *mindb
, float *maxdb
, float *inc
)
269 TRACE("(%p)->(%p,%p,%p)\n", iface
, mindb
, maxdb
, inc
);
270 if (!mindb
|| !maxdb
|| !inc
)
276 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl
= {
280 AEV_RegisterControlChangeNotify
,
281 AEV_UnregisterControlChangeNotify
,
283 AEV_SetMasterVolumeLevel
,
284 AEV_SetMasterVolumeLevelScalar
,
285 AEV_GetMasterVolumeLevel
,
286 AEV_GetMasterVolumeLevelScalar
,
287 AEV_SetChannelVolumeLevel
,
288 AEV_SetChannelVolumeLevelScalar
,
289 AEV_GetChannelVolumeLevel
,
290 AEV_GetChannelVolumeLevelScalar
,
293 AEV_GetVolumeStepInfo
,
296 AEV_QueryHardwareSupport
,
298 AEV_GetVolumeRangeChannel