d3d8: Stop setting the device state in d3d8_device_SetPixelShaderConstant().
[wine.git] / dlls / mmdevapi / audiovolume.c
blob24d210a1c851ce291a5ccbe8cc9cc7e9e4ad45e2
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winnls.h"
26 #include "winreg.h"
27 #include "wine/debug.h"
29 #include "ole2.h"
30 #include "mmdeviceapi.h"
31 #include "mmsystem.h"
32 #include "dsound.h"
33 #include "audioclient.h"
34 #include "endpointvolume.h"
35 #include "audiopolicy.h"
37 #include "mmdevapi.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi);
41 typedef struct AEVImpl {
42 IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface;
43 LONG ref;
44 float master_vol;
45 BOOL mute;
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 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
125 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
127 if(leveldb < -100.f || leveldb > 0.f)
128 return E_INVALIDARG;
130 This->master_vol = leveldb;
132 return S_OK;
135 static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
137 TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
138 FIXME("stub\n");
139 return E_NOTIMPL;
142 static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
144 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
146 TRACE("(%p)->(%p)\n", iface, leveldb);
148 if (!leveldb)
149 return E_POINTER;
151 *leveldb = This->master_vol;
153 return S_OK;
156 static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
158 TRACE("(%p)->(%p)\n", iface, level);
159 if (!level)
160 return E_POINTER;
161 FIXME("stub\n");
162 return E_NOTIMPL;
165 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
167 TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
168 FIXME("stub\n");
169 return E_NOTIMPL;
172 static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
174 TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
175 FIXME("stub\n");
176 return E_NOTIMPL;
179 static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
181 TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
182 if (!leveldb)
183 return E_POINTER;
184 FIXME("stub\n");
185 return E_NOTIMPL;
188 static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
190 TRACE("(%p)->(%u,%p)\n", iface, chan, level);
191 if (!level)
192 return E_POINTER;
193 FIXME("stub\n");
194 return E_NOTIMPL;
197 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
199 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
200 HRESULT ret;
202 TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
204 ret = This->mute == mute ? S_FALSE : S_OK;
206 This->mute = mute;
208 return ret;
211 static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
213 AEVImpl *This = impl_from_IAudioEndpointVolumeEx(iface);
215 TRACE("(%p)->(%p)\n", iface, mute);
217 if (!mute)
218 return E_POINTER;
220 *mute = This->mute;
222 return S_OK;
225 static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
227 TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
228 if (!stepsize && !stepcount)
229 return E_POINTER;
230 FIXME("stub\n");
231 return E_NOTIMPL;
234 static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
236 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
237 FIXME("stub\n");
238 return E_NOTIMPL;
241 static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
243 TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
244 FIXME("stub\n");
245 return E_NOTIMPL;
248 static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
250 TRACE("(%p)->(%p)\n", iface, mask);
251 if (!mask)
252 return E_POINTER;
253 FIXME("stub\n");
254 return E_NOTIMPL;
257 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
259 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
261 if (!mindb || !maxdb || !inc)
262 return E_POINTER;
264 *mindb = -100.f;
265 *maxdb = 0.f;
266 *inc = 1.f;
268 return S_OK;
271 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
273 TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
274 if (!mindb || !maxdb || !inc)
275 return E_POINTER;
276 FIXME("stub\n");
277 return E_NOTIMPL;
280 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
281 AEV_QueryInterface,
282 AEV_AddRef,
283 AEV_Release,
284 AEV_RegisterControlChangeNotify,
285 AEV_UnregisterControlChangeNotify,
286 AEV_GetChannelCount,
287 AEV_SetMasterVolumeLevel,
288 AEV_SetMasterVolumeLevelScalar,
289 AEV_GetMasterVolumeLevel,
290 AEV_GetMasterVolumeLevelScalar,
291 AEV_SetChannelVolumeLevel,
292 AEV_SetChannelVolumeLevelScalar,
293 AEV_GetChannelVolumeLevel,
294 AEV_GetChannelVolumeLevelScalar,
295 AEV_SetMute,
296 AEV_GetMute,
297 AEV_GetVolumeStepInfo,
298 AEV_VolumeStepUp,
299 AEV_VolumeStepDown,
300 AEV_QueryHardwareSupport,
301 AEV_GetVolumeRange,
302 AEV_GetVolumeRangeChannel
305 HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv)
307 AEVImpl *This;
309 *ppv = NULL;
310 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
311 if (!This)
312 return E_OUTOFMEMORY;
313 This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
314 This->ref = 1;
316 *ppv = &This->IAudioEndpointVolumeEx_iface;
317 return S_OK;