msi/tests: Use a different product code in the automation tests.
[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 #ifdef HAVE_AL_AL_H
26 #include <AL/al.h>
27 #include <AL/alc.h>
28 #elif defined(HAVE_OPENAL_AL_H)
29 #include <OpenAL/al.h>
30 #include <OpenAL/alc.h>
31 #endif
32
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winnls.h"
36 #include "winreg.h"
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
39
40 #include "ole2.h"
41 #include "mmdeviceapi.h"
42 #include "dshow.h"
43 #include "dsound.h"
44 #include "audioclient.h"
45 #include "endpointvolume.h"
46 #include "audiopolicy.h"
47
48 #include "mmdevapi.h"
49
50 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
51
52 #ifdef HAVE_OPENAL
53
54 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl;
55
56 typedef struct AEVImpl {
57     const IAudioEndpointVolumeExVtbl *lpVtbl;
58     LONG ref;
59 } AEVImpl;
60
61 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolume **ppv)
62 {
63     AEVImpl *This;
64     This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
65     *ppv = (IAudioEndpointVolume*)This;
66     if (!This)
67         return E_OUTOFMEMORY;
68     This->lpVtbl = &AEVImpl_Vtbl;
69     This->ref = 1;
70     return S_OK;
71 }
72
73 static void AudioEndpointVolume_Destroy(AEVImpl *This)
74 {
75     HeapFree(GetProcessHeap(), 0, This);
76 }
77
78 static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
79 {
80     AEVImpl *This = (AEVImpl*)iface;
81     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
82     if (!ppv)
83         return E_POINTER;
84     *ppv = NULL;
85     if (IsEqualIID(riid, &IID_IUnknown) ||
86         IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
87         IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) {
88         *ppv = This;
89     }
90     else
91         return E_NOINTERFACE;
92     IUnknown_AddRef((IUnknown *)*ppv);
93     return S_OK;
94 }
95
96 static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
97 {
98     AEVImpl *This = (AEVImpl*)iface;
99     ULONG ref = InterlockedIncrement(&This->ref);
100     TRACE("(%p) new ref %u\n", This, ref);
101     return ref;
102 }
103
104 static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
105 {
106     AEVImpl *This = (AEVImpl*)iface;
107     ULONG ref = InterlockedDecrement(&This->ref);
108     TRACE("(%p) new ref %u\n", This, ref);
109     if (!ref)
110         AudioEndpointVolume_Destroy(This);
111     return ref;
112 }
113
114 static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
115 {
116     TRACE("(%p)->(%p)\n", iface, notify);
117     if (!notify)
118         return E_POINTER;
119     FIXME("stub\n");
120     return S_OK;
121 }
122
123 static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
124 {
125     TRACE("(%p)->(%p)\n", iface, notify);
126     if (!notify)
127         return E_POINTER;
128     FIXME("stub\n");
129     return S_OK;
130 }
131
132 static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
133 {
134     TRACE("(%p)->(%p)\n", iface, count);
135     if (!count)
136         return E_POINTER;
137     FIXME("stub\n");
138     return E_NOTIMPL;
139 }
140
141 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
142 {
143     TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
144     FIXME("stub\n");
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
149 {
150     TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
151     FIXME("stub\n");
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
156 {
157     TRACE("(%p)->(%p)\n", iface, leveldb);
158     if (!leveldb)
159         return E_POINTER;
160     FIXME("stub\n");
161     return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
165 {
166     TRACE("(%p)->(%p)\n", iface, level);
167     if (!level)
168         return E_POINTER;
169     FIXME("stub\n");
170     return E_NOTIMPL;
171 }
172
173 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
174 {
175     TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
176     FIXME("stub\n");
177     return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
181 {
182     TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
183     FIXME("stub\n");
184     return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
188 {
189     TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
190     if (!leveldb)
191         return E_POINTER;
192     FIXME("stub\n");
193     return E_NOTIMPL;
194 }
195
196 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
197 {
198     TRACE("(%p)->(%u,%p)\n", iface, chan, level);
199     if (!level)
200         return E_POINTER;
201     FIXME("stub\n");
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
206 {
207     TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
208     FIXME("stub\n");
209     return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
213 {
214     TRACE("(%p)->(%p)\n", iface, mute);
215     if (!mute)
216         return E_POINTER;
217     FIXME("stub\n");
218     return E_NOTIMPL;
219 }
220
221 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
222 {
223     TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
224     if (!stepsize && !stepcount)
225         return E_POINTER;
226     FIXME("stub\n");
227     return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
231 {
232     TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
233     FIXME("stub\n");
234     return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
238 {
239     TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
240     FIXME("stub\n");
241     return E_NOTIMPL;
242 }
243
244 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
245 {
246     TRACE("(%p)->(%p)\n", iface, mask);
247     if (!mask)
248         return E_POINTER;
249     FIXME("stub\n");
250     return E_NOTIMPL;
251 }
252
253 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
254 {
255     TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
256     if (!mindb || !maxdb || !inc)
257         return E_POINTER;
258     FIXME("stub\n");
259     return E_NOTIMPL;
260 }
261
262 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
263 {
264     TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
265     if (!mindb || !maxdb || !inc)
266         return E_POINTER;
267     FIXME("stub\n");
268     return E_NOTIMPL;
269 }
270
271 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
272     AEV_QueryInterface,
273     AEV_AddRef,
274     AEV_Release,
275     AEV_RegisterControlChangeNotify,
276     AEV_UnregisterControlChangeNotify,
277     AEV_GetChannelCount,
278     AEV_SetMasterVolumeLevel,
279     AEV_SetMasterVolumeLevelScalar,
280     AEV_GetMasterVolumeLevel,
281     AEV_GetMasterVolumeLevelScalar,
282     AEV_SetChannelVolumeLevel,
283     AEV_SetChannelVolumeLevelScalar,
284     AEV_GetChannelVolumeLevel,
285     AEV_GetChannelVolumeLevelScalar,
286     AEV_SetMute,
287     AEV_GetMute,
288     AEV_GetVolumeStepInfo,
289     AEV_VolumeStepUp,
290     AEV_VolumeStepDown,
291     AEV_QueryHardwareSupport,
292     AEV_GetVolumeRange,
293     AEV_GetVolumeRangeChannel
294 };
295
296 #endif