TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / mmdevapi / audiovolume.c
blob7dddbdf16601cb55c1878e94bd66a29bbcf18cc8
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
19 #define COBJMACROS
20 #include "config.h"
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winnls.h"
27 #include "winreg.h"
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
31 #include "ole2.h"
32 #include "mmdeviceapi.h"
33 #include "mmsystem.h"
34 #include "dsound.h"
35 #include "audioclient.h"
36 #include "endpointvolume.h"
37 #include "audiopolicy.h"
39 #include "mmdevapi.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
43 typedef struct AEVImpl {
44 IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
45 LONG ref;
46 } AEVImpl;
48 static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface)
50 return CONTAINING_RECORD(iface, AEVImpl, IAudioEndpointVolumeEx_iface);
53 static void AudioEndpointVolume_Destroy(AEVImpl *This)
55 HeapFree(GetProcessHeap(), 0, This);
58 static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
60 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
61 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
62 if (!ppv)
63 return E_POINTER;
64 *ppv = NULL;
65 if (IsEqualIID(riid, &IID_IUnknown) ||
66 IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
67 IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) {
68 *ppv = &This->IAudioEndpointVolumeEx_iface;
70 else
71 return E_NOINTERFACE;
72 IUnknown_AddRef((IUnknown *)*ppv);
73 return S_OK;
76 static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
78 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
79 ULONG ref = InterlockedIncrement(&This->ref);
80 TRACE("(%p) new ref %u\n", This, ref);
81 return ref;
84 static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
86 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
87 ULONG ref = InterlockedDecrement(&This->ref);
88 TRACE("(%p) new ref %u\n", This, ref);
89 if (!ref)
90 AudioEndpointVolume_Destroy(This);
91 return ref;
94 static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
96 TRACE("(%p)->(%p)\n", iface, notify);
97 if (!notify)
98 return E_POINTER;
99 FIXME("stub\n");
100 return S_OK;
103 static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
105 TRACE("(%p)->(%p)\n", iface, notify);
106 if (!notify)
107 return E_POINTER;
108 FIXME("stub\n");
109 return S_OK;
112 static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
114 TRACE("(%p)->(%p)\n", iface, count);
115 if (!count)
116 return E_POINTER;
117 FIXME("stub\n");
118 return E_NOTIMPL;
121 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
123 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
124 FIXME("stub\n");
125 return E_NOTIMPL;
128 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
130 TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
131 FIXME("stub\n");
132 return E_NOTIMPL;
135 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
137 TRACE("(%p)->(%p)\n", iface, leveldb);
138 if (!leveldb)
139 return E_POINTER;
140 FIXME("stub\n");
141 return E_NOTIMPL;
144 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
146 TRACE("(%p)->(%p)\n", iface, level);
147 if (!level)
148 return E_POINTER;
149 FIXME("stub\n");
150 return E_NOTIMPL;
153 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
155 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
156 FIXME("stub\n");
157 return E_NOTIMPL;
160 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
162 TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
163 FIXME("stub\n");
164 return E_NOTIMPL;
167 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
169 TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
170 if (!leveldb)
171 return E_POINTER;
172 FIXME("stub\n");
173 return E_NOTIMPL;
176 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
178 TRACE("(%p)->(%u,%p)\n", iface, chan, level);
179 if (!level)
180 return E_POINTER;
181 FIXME("stub\n");
182 return E_NOTIMPL;
185 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
187 TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
188 FIXME("stub\n");
189 return E_NOTIMPL;
192 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
194 TRACE("(%p)->(%p)\n", iface, mute);
195 if (!mute)
196 return E_POINTER;
197 FIXME("stub\n");
198 return E_NOTIMPL;
201 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
203 TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
204 if (!stepsize && !stepcount)
205 return E_POINTER;
206 FIXME("stub\n");
207 return E_NOTIMPL;
210 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
212 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
213 FIXME("stub\n");
214 return E_NOTIMPL;
217 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
219 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
220 FIXME("stub\n");
221 return E_NOTIMPL;
224 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
226 TRACE("(%p)->(%p)\n", iface, mask);
227 if (!mask)
228 return E_POINTER;
229 FIXME("stub\n");
230 return E_NOTIMPL;
233 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
235 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
236 if (!mindb || !maxdb || !inc)
237 return E_POINTER;
238 FIXME("stub\n");
239 return E_NOTIMPL;
242 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
244 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
245 if (!mindb || !maxdb || !inc)
246 return E_POINTER;
247 FIXME("stub\n");
248 return E_NOTIMPL;
251 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
252 AEV_QueryInterface,
253 AEV_AddRef,
254 AEV_Release,
255 AEV_RegisterControlChangeNotify,
256 AEV_UnregisterControlChangeNotify,
257 AEV_GetChannelCount,
258 AEV_SetMasterVolumeLevel,
259 AEV_SetMasterVolumeLevelScalar,
260 AEV_GetMasterVolumeLevel,
261 AEV_GetMasterVolumeLevelScalar,
262 AEV_SetChannelVolumeLevel,
263 AEV_SetChannelVolumeLevelScalar,
264 AEV_GetChannelVolumeLevel,
265 AEV_GetChannelVolumeLevelScalar,
266 AEV_SetMute,
267 AEV_GetMute,
268 AEV_GetVolumeStepInfo,
269 AEV_VolumeStepUp,
270 AEV_VolumeStepDown,
271 AEV_QueryHardwareSupport,
272 AEV_GetVolumeRange,
273 AEV_GetVolumeRangeChannel
276 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
278 AEVImpl *This;
280 *ppv = NULL;
281 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
282 if (!This)
283 return E_OUTOFMEMORY;
284 This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
285 This->ref = 1;
287 *ppv = (IAudioEndpointVolume*)&This->IAudioEndpointVolumeEx_iface;
288 return S_OK;