Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / dlls / mmdevapi / audiovolume.c
blob84377a5ad513849f2fe011d9815a79da994cc087
1 /*
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
21 #define COBJMACROS
22 #include "config.h"
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnls.h"
29 #include "winreg.h"
30 #include "wine/debug.h"
31 #include "wine/unicode.h"
33 #include "ole2.h"
34 #include "mmdeviceapi.h"
35 #include "dshow.h"
36 #include "dsound.h"
37 #include "audioclient.h"
38 #include "endpointvolume.h"
39 #include "audiopolicy.h"
41 #include "mmdevapi.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
45 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl;
47 typedef struct AEVImpl {
48 IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
49 LONG ref;
50 } AEVImpl;
52 static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface)
54 return CONTAINING_RECORD(iface, AEVImpl, IAudioEndpointVolumeEx_iface);
57 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
59 AEVImpl *This;
60 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
61 *ppv = (IAudioEndpointVolume*)This;
62 if (!This)
63 return E_OUTOFMEMORY;
64 This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
65 This->ref = 1;
66 return S_OK;
69 static void AudioEndpointVolume_Destroy(AEVImpl *This)
71 HeapFree(GetProcessHeap(), 0, This);
74 static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
76 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
77 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
78 if (!ppv)
79 return E_POINTER;
80 *ppv = NULL;
81 if (IsEqualIID(riid, &IID_IUnknown) ||
82 IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
83 IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) {
84 *ppv = This;
86 else
87 return E_NOINTERFACE;
88 IUnknown_AddRef((IUnknown *)*ppv);
89 return S_OK;
92 static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
94 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
95 ULONG ref = InterlockedIncrement(&This->ref);
96 TRACE("(%p) new ref %u\n", This, ref);
97 return ref;
100 static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
102 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
103 ULONG ref = InterlockedDecrement(&This->ref);
104 TRACE("(%p) new ref %u\n", This, ref);
105 if (!ref)
106 AudioEndpointVolume_Destroy(This);
107 return ref;
110 static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
112 TRACE("(%p)->(%p)\n", iface, notify);
113 if (!notify)
114 return E_POINTER;
115 FIXME("stub\n");
116 return S_OK;
119 static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
121 TRACE("(%p)->(%p)\n", iface, notify);
122 if (!notify)
123 return E_POINTER;
124 FIXME("stub\n");
125 return S_OK;
128 static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
130 TRACE("(%p)->(%p)\n", iface, count);
131 if (!count)
132 return E_POINTER;
133 FIXME("stub\n");
134 return E_NOTIMPL;
137 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
139 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
140 FIXME("stub\n");
141 return E_NOTIMPL;
144 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
146 TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
147 FIXME("stub\n");
148 return E_NOTIMPL;
151 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
153 TRACE("(%p)->(%p)\n", iface, leveldb);
154 if (!leveldb)
155 return E_POINTER;
156 FIXME("stub\n");
157 return E_NOTIMPL;
160 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
162 TRACE("(%p)->(%p)\n", iface, level);
163 if (!level)
164 return E_POINTER;
165 FIXME("stub\n");
166 return E_NOTIMPL;
169 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
171 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
172 FIXME("stub\n");
173 return E_NOTIMPL;
176 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
178 TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
179 FIXME("stub\n");
180 return E_NOTIMPL;
183 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
185 TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
186 if (!leveldb)
187 return E_POINTER;
188 FIXME("stub\n");
189 return E_NOTIMPL;
192 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
194 TRACE("(%p)->(%u,%p)\n", iface, chan, level);
195 if (!level)
196 return E_POINTER;
197 FIXME("stub\n");
198 return E_NOTIMPL;
201 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
203 TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
204 FIXME("stub\n");
205 return E_NOTIMPL;
208 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
210 TRACE("(%p)->(%p)\n", iface, mute);
211 if (!mute)
212 return E_POINTER;
213 FIXME("stub\n");
214 return E_NOTIMPL;
217 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
219 TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
220 if (!stepsize && !stepcount)
221 return E_POINTER;
222 FIXME("stub\n");
223 return E_NOTIMPL;
226 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
228 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
229 FIXME("stub\n");
230 return E_NOTIMPL;
233 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
235 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
236 FIXME("stub\n");
237 return E_NOTIMPL;
240 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
242 TRACE("(%p)->(%p)\n", iface, mask);
243 if (!mask)
244 return E_POINTER;
245 FIXME("stub\n");
246 return E_NOTIMPL;
249 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
251 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
252 if (!mindb || !maxdb || !inc)
253 return E_POINTER;
254 FIXME("stub\n");
255 return E_NOTIMPL;
258 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
260 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
261 if (!mindb || !maxdb || !inc)
262 return E_POINTER;
263 FIXME("stub\n");
264 return E_NOTIMPL;
267 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
268 AEV_QueryInterface,
269 AEV_AddRef,
270 AEV_Release,
271 AEV_RegisterControlChangeNotify,
272 AEV_UnregisterControlChangeNotify,
273 AEV_GetChannelCount,
274 AEV_SetMasterVolumeLevel,
275 AEV_SetMasterVolumeLevelScalar,
276 AEV_GetMasterVolumeLevel,
277 AEV_GetMasterVolumeLevelScalar,
278 AEV_SetChannelVolumeLevel,
279 AEV_SetChannelVolumeLevelScalar,
280 AEV_GetChannelVolumeLevel,
281 AEV_GetChannelVolumeLevelScalar,
282 AEV_SetMute,
283 AEV_GetMute,
284 AEV_GetVolumeStepInfo,
285 AEV_VolumeStepUp,
286 AEV_VolumeStepDown,
287 AEV_QueryHardwareSupport,
288 AEV_GetVolumeRange,
289 AEV_GetVolumeRangeChannel