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
21 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl
;
23 typedef struct AEVImpl
{
24 IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface
;
28 static inline AEVImpl
*impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx
*iface
)
30 return CONTAINING_RECORD(iface
, AEVImpl
, IAudioEndpointVolumeEx_iface
);
33 HRESULT
AudioEndpointVolume_Create(MMDevice
*parent
, IAudioEndpointVolume
**ppv
)
36 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*This
));
37 *ppv
= (IAudioEndpointVolume
*)This
;
40 This
->IAudioEndpointVolumeEx_iface
.lpVtbl
= &AEVImpl_Vtbl
;
45 static void AudioEndpointVolume_Destroy(AEVImpl
*This
)
47 HeapFree(GetProcessHeap(), 0, This
);
50 static HRESULT WINAPI
AEV_QueryInterface(IAudioEndpointVolumeEx
*iface
, REFIID riid
, void **ppv
)
52 AEVImpl
*This
= impl_from_IAudioEndpointVolumeEx(iface
);
53 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
57 if (IsEqualIID(riid
, &IID_IUnknown
) ||
58 IsEqualIID(riid
, &IID_IAudioEndpointVolume
) ||
59 IsEqualIID(riid
, &IID_IAudioEndpointVolumeEx
)) {
64 IUnknown_AddRef((IUnknown
*)*ppv
);
68 static ULONG WINAPI
AEV_AddRef(IAudioEndpointVolumeEx
*iface
)
70 AEVImpl
*This
= impl_from_IAudioEndpointVolumeEx(iface
);
71 ULONG ref
= InterlockedIncrement(&This
->ref
);
72 TRACE("(%p) new ref %u\n", This
, ref
);
76 static ULONG WINAPI
AEV_Release(IAudioEndpointVolumeEx
*iface
)
78 AEVImpl
*This
= impl_from_IAudioEndpointVolumeEx(iface
);
79 ULONG ref
= InterlockedDecrement(&This
->ref
);
80 TRACE("(%p) new ref %u\n", This
, ref
);
82 AudioEndpointVolume_Destroy(This
);
86 static HRESULT WINAPI
AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx
*iface
, IAudioEndpointVolumeCallback
*notify
)
88 TRACE("(%p)->(%p)\n", iface
, notify
);
95 static HRESULT WINAPI
AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx
*iface
, IAudioEndpointVolumeCallback
*notify
)
97 TRACE("(%p)->(%p)\n", iface
, notify
);
104 static HRESULT WINAPI
AEV_GetChannelCount(IAudioEndpointVolumeEx
*iface
, UINT
*count
)
106 TRACE("(%p)->(%p)\n", iface
, count
);
113 static HRESULT WINAPI
AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx
*iface
, float leveldb
, const GUID
*ctx
)
115 TRACE("(%p)->(%f,%s)\n", iface
, leveldb
, debugstr_guid(ctx
));
120 static HRESULT WINAPI
AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, float level
, const GUID
*ctx
)
122 TRACE("(%p)->(%f,%s)\n", iface
, level
, debugstr_guid(ctx
));
127 static HRESULT WINAPI
AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx
*iface
, float *leveldb
)
129 TRACE("(%p)->(%p)\n", iface
, leveldb
);
136 static HRESULT WINAPI
AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, float *level
)
138 TRACE("(%p)->(%p)\n", iface
, level
);
145 static HRESULT WINAPI
AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float leveldb
, const GUID
*ctx
)
147 TRACE("(%p)->(%f,%s)\n", iface
, leveldb
, debugstr_guid(ctx
));
152 static HRESULT WINAPI
AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, UINT chan
, float level
, const GUID
*ctx
)
154 TRACE("(%p)->(%u,%f,%s)\n", iface
, chan
, level
, debugstr_guid(ctx
));
159 static HRESULT WINAPI
AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *leveldb
)
161 TRACE("(%p)->(%u,%p)\n", iface
, chan
, leveldb
);
168 static HRESULT WINAPI
AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *level
)
170 TRACE("(%p)->(%u,%p)\n", iface
, chan
, level
);
177 static HRESULT WINAPI
AEV_SetMute(IAudioEndpointVolumeEx
*iface
, BOOL mute
, const GUID
*ctx
)
179 TRACE("(%p)->(%u,%s)\n", iface
, mute
, debugstr_guid(ctx
));
184 static HRESULT WINAPI
AEV_GetMute(IAudioEndpointVolumeEx
*iface
, BOOL
*mute
)
186 TRACE("(%p)->(%p)\n", iface
, mute
);
193 static HRESULT WINAPI
AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx
*iface
, UINT
*stepsize
, UINT
*stepcount
)
195 TRACE("(%p)->(%p,%p)\n", iface
, stepsize
, stepcount
);
196 if (!stepsize
&& !stepcount
)
202 static HRESULT WINAPI
AEV_VolumeStepUp(IAudioEndpointVolumeEx
*iface
, const GUID
*ctx
)
204 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(ctx
));
209 static HRESULT WINAPI
AEV_VolumeStepDown(IAudioEndpointVolumeEx
*iface
, const GUID
*ctx
)
211 TRACE("(%p)->(%s)\n", iface
, debugstr_guid(ctx
));
216 static HRESULT WINAPI
AEV_QueryHardwareSupport(IAudioEndpointVolumeEx
*iface
, DWORD
*mask
)
218 TRACE("(%p)->(%p)\n", iface
, mask
);
225 static HRESULT WINAPI
AEV_GetVolumeRange(IAudioEndpointVolumeEx
*iface
, float *mindb
, float *maxdb
, float *inc
)
227 TRACE("(%p)->(%p,%p,%p)\n", iface
, mindb
, maxdb
, inc
);
228 if (!mindb
|| !maxdb
|| !inc
)
234 static HRESULT WINAPI
AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx
*iface
, UINT chan
, float *mindb
, float *maxdb
, float *inc
)
236 TRACE("(%p)->(%p,%p,%p)\n", iface
, mindb
, maxdb
, inc
);
237 if (!mindb
|| !maxdb
|| !inc
)
243 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl
= {
247 AEV_RegisterControlChangeNotify
,
248 AEV_UnregisterControlChangeNotify
,
250 AEV_SetMasterVolumeLevel
,
251 AEV_SetMasterVolumeLevelScalar
,
252 AEV_GetMasterVolumeLevel
,
253 AEV_GetMasterVolumeLevelScalar
,
254 AEV_SetChannelVolumeLevel
,
255 AEV_SetChannelVolumeLevelScalar
,
256 AEV_GetChannelVolumeLevel
,
257 AEV_GetChannelVolumeLevelScalar
,
260 AEV_GetVolumeStepInfo
,
263 AEV_QueryHardwareSupport
,
265 AEV_GetVolumeRangeChannel