dmsynth: Dump data passed to Download method.
[wine] / dlls / 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
20 #define NONAMELESSUNION
21 #define COBJMACROS
22 #include "config.h"
23
24 #include <stdarg.h>
25
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"
32
33 #include "ole2.h"
34 #include "mmdeviceapi.h"
35 #include "mmsystem.h"
36 #include "dsound.h"
37 #include "audioclient.h"
38 #include "endpointvolume.h"
39 #include "audiopolicy.h"
40
41 #include "mmdevapi.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
44
45 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl;
46
47 typedef struct AEVImpl {
48     IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
49     LONG ref;
50 } AEVImpl;
51
52 static inline AEVImpl *impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface)
53 {
54     return CONTAINING_RECORD(iface, AEVImpl, IAudioEndpointVolumeEx_iface);
55 }
56
57 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
58 {
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;
67 }
68
69 static void AudioEndpointVolume_Destroy(AEVImpl *This)
70 {
71     HeapFree(GetProcessHeap(), 0, This);
72 }
73
74 static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
75 {
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;
85     }
86     else
87         return E_NOINTERFACE;
88     IUnknown_AddRef((IUnknown *)*ppv);
89     return S_OK;
90 }
91
92 static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
93 {
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;
98 }
99
100 static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
101 {
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;
108 }
109
110 static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
111 {
112     TRACE("(%p)->(%p)\n", iface, notify);
113     if (!notify)
114         return E_POINTER;
115     FIXME("stub\n");
116     return S_OK;
117 }
118
119 static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
120 {
121     TRACE("(%p)->(%p)\n", iface, notify);
122     if (!notify)
123         return E_POINTER;
124     FIXME("stub\n");
125     return S_OK;
126 }
127
128 static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
129 {
130     TRACE("(%p)->(%p)\n", iface, count);
131     if (!count)
132         return E_POINTER;
133     FIXME("stub\n");
134     return E_NOTIMPL;
135 }
136
137 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
138 {
139     TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
140     FIXME("stub\n");
141     return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
145 {
146     TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
147     FIXME("stub\n");
148     return E_NOTIMPL;
149 }
150
151 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
152 {
153     TRACE("(%p)->(%p)\n", iface, leveldb);
154     if (!leveldb)
155         return E_POINTER;
156     FIXME("stub\n");
157     return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
161 {
162     TRACE("(%p)->(%p)\n", iface, level);
163     if (!level)
164         return E_POINTER;
165     FIXME("stub\n");
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
170 {
171     TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
172     FIXME("stub\n");
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
177 {
178     TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
179     FIXME("stub\n");
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
184 {
185     TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
186     if (!leveldb)
187         return E_POINTER;
188     FIXME("stub\n");
189     return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
193 {
194     TRACE("(%p)->(%u,%p)\n", iface, chan, level);
195     if (!level)
196         return E_POINTER;
197     FIXME("stub\n");
198     return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
202 {
203     TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
204     FIXME("stub\n");
205     return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
209 {
210     TRACE("(%p)->(%p)\n", iface, mute);
211     if (!mute)
212         return E_POINTER;
213     FIXME("stub\n");
214     return E_NOTIMPL;
215 }
216
217 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
218 {
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;
224 }
225
226 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
227 {
228     TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
229     FIXME("stub\n");
230     return E_NOTIMPL;
231 }
232
233 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
234 {
235     TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
236     FIXME("stub\n");
237     return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
241 {
242     TRACE("(%p)->(%p)\n", iface, mask);
243     if (!mask)
244         return E_POINTER;
245     FIXME("stub\n");
246     return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
250 {
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;
256 }
257
258 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
259 {
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;
265 }
266
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
290 };