Sync with trunk r63343.
[reactos.git] / dll / win32 / mmdevapi / audiovolume.c
1 /*
2 * Copyright 2010 Maarten Lankhorst for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include "mmdevapi.h"
20
21 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl;
22
23 typedef struct AEVImpl {
24 IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
25 LONG ref;
26 } AEVImpl;
27
28 static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface)
29 {
30 return CONTAINING_RECORD(iface, AEVImpl, IAudioEndpointVolumeEx_iface);
31 }
32
33 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
34 {
35 AEVImpl *This;
36 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
37 *ppv = (IAudioEndpointVolume*)This;
38 if (!This)
39 return E_OUTOFMEMORY;
40 This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
41 This->ref = 1;
42 return S_OK;
43 }
44
45 static void AudioEndpointVolume_Destroy(AEVImpl *This)
46 {
47 HeapFree(GetProcessHeap(), 0, This);
48 }
49
50 static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
51 {
52 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
53 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
54 if (!ppv)
55 return E_POINTER;
56 *ppv = NULL;
57 if (IsEqualIID(riid, &IID_IUnknown) ||
58 IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
59 IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) {
60 *ppv = This;
61 }
62 else
63 return E_NOINTERFACE;
64 IUnknown_AddRef((IUnknown *)*ppv);
65 return S_OK;
66 }
67
68 static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
69 {
70 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
71 ULONG ref = InterlockedIncrement(&This->ref);
72 TRACE("(%p) new ref %u\n", This, ref);
73 return ref;
74 }
75
76 static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
77 {
78 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
79 ULONG ref = InterlockedDecrement(&This->ref);
80 TRACE("(%p) new ref %u\n", This, ref);
81 if (!ref)
82 AudioEndpointVolume_Destroy(This);
83 return ref;
84 }
85
86 static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
87 {
88 TRACE("(%p)->(%p)\n", iface, notify);
89 if (!notify)
90 return E_POINTER;
91 FIXME("stub\n");
92 return S_OK;
93 }
94
95 static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
96 {
97 TRACE("(%p)->(%p)\n", iface, notify);
98 if (!notify)
99 return E_POINTER;
100 FIXME("stub\n");
101 return S_OK;
102 }
103
104 static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
105 {
106 TRACE("(%p)->(%p)\n", iface, count);
107 if (!count)
108 return E_POINTER;
109 FIXME("stub\n");
110 return E_NOTIMPL;
111 }
112
113 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
114 {
115 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
116 FIXME("stub\n");
117 return E_NOTIMPL;
118 }
119
120 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
121 {
122 TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
123 FIXME("stub\n");
124 return E_NOTIMPL;
125 }
126
127 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
128 {
129 TRACE("(%p)->(%p)\n", iface, leveldb);
130 if (!leveldb)
131 return E_POINTER;
132 FIXME("stub\n");
133 return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
137 {
138 TRACE("(%p)->(%p)\n", iface, level);
139 if (!level)
140 return E_POINTER;
141 FIXME("stub\n");
142 return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
146 {
147 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
148 FIXME("stub\n");
149 return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
153 {
154 TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
155 FIXME("stub\n");
156 return E_NOTIMPL;
157 }
158
159 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
160 {
161 TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
162 if (!leveldb)
163 return E_POINTER;
164 FIXME("stub\n");
165 return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
169 {
170 TRACE("(%p)->(%u,%p)\n", iface, chan, level);
171 if (!level)
172 return E_POINTER;
173 FIXME("stub\n");
174 return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
178 {
179 TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
180 FIXME("stub\n");
181 return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
185 {
186 TRACE("(%p)->(%p)\n", iface, mute);
187 if (!mute)
188 return E_POINTER;
189 FIXME("stub\n");
190 return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
194 {
195 TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
196 if (!stepsize && !stepcount)
197 return E_POINTER;
198 FIXME("stub\n");
199 return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
203 {
204 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
205 FIXME("stub\n");
206 return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
210 {
211 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
212 FIXME("stub\n");
213 return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
217 {
218 TRACE("(%p)->(%p)\n", iface, mask);
219 if (!mask)
220 return E_POINTER;
221 FIXME("stub\n");
222 return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
226 {
227 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
228 if (!mindb || !maxdb || !inc)
229 return E_POINTER;
230 FIXME("stub\n");
231 return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
235 {
236 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
237 if (!mindb || !maxdb || !inc)
238 return E_POINTER;
239 FIXME("stub\n");
240 return E_NOTIMPL;
241 }
242
243 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
244 AEV_QueryInterface,
245 AEV_AddRef,
246 AEV_Release,
247 AEV_RegisterControlChangeNotify,
248 AEV_UnregisterControlChangeNotify,
249 AEV_GetChannelCount,
250 AEV_SetMasterVolumeLevel,
251 AEV_SetMasterVolumeLevelScalar,
252 AEV_GetMasterVolumeLevel,
253 AEV_GetMasterVolumeLevelScalar,
254 AEV_SetChannelVolumeLevel,
255 AEV_SetChannelVolumeLevelScalar,
256 AEV_GetChannelVolumeLevel,
257 AEV_GetChannelVolumeLevelScalar,
258 AEV_SetMute,
259 AEV_GetMute,
260 AEV_GetVolumeStepInfo,
261 AEV_VolumeStepUp,
262 AEV_VolumeStepDown,
263 AEV_QueryHardwareSupport,
264 AEV_GetVolumeRange,
265 AEV_GetVolumeRangeChannel
266 };