ReactOS  0.4.13-dev-1089-g05f0b08
audiovolume.c
Go to the documentation of this file.
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 #define COBJMACROS
20 #include "config.h"
21 
22 #include <stdarg.h>
23 
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"
30 
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"
38 
39 #include "mmdevapi.h"
40 
42 
43 typedef struct AEVImpl {
46  float master_vol;
48 } AEVImpl;
49 
51 {
52  return CONTAINING_RECORD(iface, AEVImpl, IAudioEndpointVolumeEx_iface);
53 }
54 
56 {
58 }
59 
61 {
63  TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppv);
64  if (!ppv)
65  return E_POINTER;
66  *ppv = NULL;
67  if (IsEqualIID(riid, &IID_IUnknown) ||
68  IsEqualIID(riid, &IID_IAudioEndpointVolume) ||
69  IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) {
70  *ppv = &This->IAudioEndpointVolumeEx_iface;
71  }
72  else
73  return E_NOINTERFACE;
74  IUnknown_AddRef((IUnknown *)*ppv);
75  return S_OK;
76 }
77 
79 {
82  TRACE("(%p) new ref %u\n", This, ref);
83  return ref;
84 }
85 
87 {
90  TRACE("(%p) new ref %u\n", This, ref);
91  if (!ref)
93  return ref;
94 }
95 
97 {
98  TRACE("(%p)->(%p)\n", iface, notify);
99  if (!notify)
100  return E_POINTER;
101  FIXME("stub\n");
102  return S_OK;
103 }
104 
106 {
107  TRACE("(%p)->(%p)\n", iface, notify);
108  if (!notify)
109  return E_POINTER;
110  FIXME("stub\n");
111  return S_OK;
112 }
113 
115 {
116  TRACE("(%p)->(%p)\n", iface, count);
117  if (!count)
118  return E_POINTER;
119  FIXME("stub\n");
120  return E_NOTIMPL;
121 }
122 
123 static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
124 {
126 
127  TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
128 
129  if(leveldb < -100.f || leveldb > 0.f)
130  return E_INVALIDARG;
131 
132  This->master_vol = leveldb;
133 
134  return S_OK;
135 }
136 
138 {
139  TRACE("(%p)->(%f,%s)\n", iface, level, debugstr_guid(ctx));
140  FIXME("stub\n");
141  return E_NOTIMPL;
142 }
143 
145 {
147 
148  TRACE("(%p)->(%p)\n", iface, leveldb);
149 
150  if (!leveldb)
151  return E_POINTER;
152 
153  *leveldb = This->master_vol;
154 
155  return S_OK;
156 }
157 
159 {
160  TRACE("(%p)->(%p)\n", iface, level);
161  if (!level)
162  return E_POINTER;
163  FIXME("stub\n");
164  return E_NOTIMPL;
165 }
166 
167 static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
168 {
169  TRACE("(%p)->(%f,%s)\n", iface, leveldb, debugstr_guid(ctx));
170  FIXME("stub\n");
171  return E_NOTIMPL;
172 }
173 
175 {
176  TRACE("(%p)->(%u,%f,%s)\n", iface, chan, level, debugstr_guid(ctx));
177  FIXME("stub\n");
178  return E_NOTIMPL;
179 }
180 
182 {
183  TRACE("(%p)->(%u,%p)\n", iface, chan, leveldb);
184  if (!leveldb)
185  return E_POINTER;
186  FIXME("stub\n");
187  return E_NOTIMPL;
188 }
189 
191 {
192  TRACE("(%p)->(%u,%p)\n", iface, chan, level);
193  if (!level)
194  return E_POINTER;
195  FIXME("stub\n");
196  return E_NOTIMPL;
197 }
198 
199 static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
200 {
202  HRESULT ret;
203 
204  TRACE("(%p)->(%u,%s)\n", iface, mute, debugstr_guid(ctx));
205 
206  ret = This->mute == mute ? S_FALSE : S_OK;
207 
208  This->mute = mute;
209 
210  return ret;
211 }
212 
214 {
216 
217  TRACE("(%p)->(%p)\n", iface, mute);
218 
219  if (!mute)
220  return E_POINTER;
221 
222  *mute = This->mute;
223 
224  return S_OK;
225 }
226 
228 {
229  TRACE("(%p)->(%p,%p)\n", iface, stepsize, stepcount);
230  if (!stepsize && !stepcount)
231  return E_POINTER;
232  FIXME("stub\n");
233  return E_NOTIMPL;
234 }
235 
237 {
238  TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
239  FIXME("stub\n");
240  return E_NOTIMPL;
241 }
242 
244 {
245  TRACE("(%p)->(%s)\n", iface, debugstr_guid(ctx));
246  FIXME("stub\n");
247  return E_NOTIMPL;
248 }
249 
251 {
252  TRACE("(%p)->(%p)\n", iface, mask);
253  if (!mask)
254  return E_POINTER;
255  FIXME("stub\n");
256  return E_NOTIMPL;
257 }
258 
259 static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
260 {
261  TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
262 
263  if (!mindb || !maxdb || !inc)
264  return E_POINTER;
265 
266  *mindb = -100.f;
267  *maxdb = 0.f;
268  *inc = 1.f;
269 
270  return S_OK;
271 }
272 
273 static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
274 {
275  TRACE("(%p)->(%p,%p,%p)\n", iface, mindb, maxdb, inc);
276  if (!mindb || !maxdb || !inc)
277  return E_POINTER;
278  FIXME("stub\n");
279  return E_NOTIMPL;
280 }
281 
282 static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl = {
284  AEV_AddRef,
285  AEV_Release,
297  AEV_SetMute,
298  AEV_GetMute,
305 };
306 
308 {
309  AEVImpl *This;
310 
311  *ppv = NULL;
313  if (!This)
314  return E_OUTOFMEMORY;
315  This->IAudioEndpointVolumeEx_iface.lpVtbl = &AEVImpl_Vtbl;
316  This->ref = 1;
317 
318  *ppv = &This->IAudioEndpointVolumeEx_iface;
319  return S_OK;
320 }
static HRESULT WINAPI AEV_RegisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
Definition: audiovolume.c:96
static HRESULT WINAPI AEV_SetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float leveldb, const GUID *ctx)
Definition: audiovolume.c:123
GLint level
Definition: gl.h:1546
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
struct AEVImpl AEVImpl
REFIID riid
Definition: precomp.h:44
GLuint GLuint GLsizei count
Definition: gl.h:1545
static HRESULT WINAPI AEV_QueryInterface(IAudioEndpointVolumeEx *iface, REFIID riid, void **ppv)
Definition: audiovolume.c:60
int notify
Definition: msacm.c:1353
REFIID LPVOID * ppv
Definition: atlbase.h:39
static HRESULT WINAPI AEV_GetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float *level)
Definition: audiovolume.c:158
static HRESULT WINAPI AEV_GetVolumeRange(IAudioEndpointVolumeEx *iface, float *mindb, float *maxdb, float *inc)
Definition: audiovolume.c:259
IAudioEndpointVolumeEx IAudioEndpointVolumeEx_iface
Definition: audiovolume.c:44
static HRESULT WINAPI AEV_VolumeStepUp(IAudioEndpointVolumeEx *iface, const GUID *ctx)
Definition: audiovolume.c:236
Definition: send.c:47
GLenum GLint GLuint mask
Definition: glext.h:6028
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static ULONG WINAPI AEV_AddRef(IAudioEndpointVolumeEx *iface)
Definition: audiovolume.c:78
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi)
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
static ULONG WINAPI AEV_Release(IAudioEndpointVolumeEx *iface)
Definition: audiovolume.c:86
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static HRESULT WINAPI AEV_GetVolumeRangeChannel(IAudioEndpointVolumeEx *iface, UINT chan, float *mindb, float *maxdb, float *inc)
Definition: audiovolume.c:273
GLfloat f
Definition: glext.h:7540
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
r parent
Definition: btrfs.c:2897
static HRESULT WINAPI AEV_GetMasterVolumeLevel(IAudioEndpointVolumeEx *iface, float *leveldb)
Definition: audiovolume.c:144
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT WINAPI AEV_SetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float leveldb, const GUID *ctx)
Definition: audiovolume.c:167
int ret
#define InterlockedDecrement
Definition: armddk.h:52
static HRESULT WINAPI AEV_GetVolumeStepInfo(IAudioEndpointVolumeEx *iface, UINT *stepsize, UINT *stepcount)
Definition: audiovolume.c:227
static HRESULT WINAPI AEV_UnregisterControlChangeNotify(IAudioEndpointVolumeEx *iface, IAudioEndpointVolumeCallback *notify)
Definition: audiovolume.c:105
static HRESULT WINAPI AEV_GetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float *level)
Definition: audiovolume.c:190
static HRESULT WINAPI AEV_SetChannelVolumeLevelScalar(IAudioEndpointVolumeEx *iface, UINT chan, float level, const GUID *ctx)
Definition: audiovolume.c:174
static HRESULT WINAPI AEV_GetChannelCount(IAudioEndpointVolumeEx *iface, UINT *count)
Definition: audiovolume.c:114
static HRESULT WINAPI AEV_SetMute(IAudioEndpointVolumeEx *iface, BOOL mute, const GUID *ctx)
Definition: audiovolume.c:199
#define S_OK
Definition: intsafe.h:59
HRESULT AudioEndpointVolume_Create(MMDevice *parent, IAudioEndpointVolumeEx **ppv)
Definition: audiovolume.c:307
#define InterlockedIncrement
Definition: armddk.h:53
BOOL mute
Definition: audiovolume.c:47
static HRESULT WINAPI AEV_QueryHardwareSupport(IAudioEndpointVolumeEx *iface, DWORD *mask)
Definition: audiovolume.c:250
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT WINAPI AEV_SetMasterVolumeLevelScalar(IAudioEndpointVolumeEx *iface, float level, const GUID *ctx)
Definition: audiovolume.c:137
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
float master_vol
Definition: audiovolume.c:46
static HRESULT WINAPI AEV_VolumeStepDown(IAudioEndpointVolumeEx *iface, const GUID *ctx)
Definition: audiovolume.c:243
static const IAudioEndpointVolumeExVtbl AEVImpl_Vtbl
Definition: audiovolume.c:282
unsigned int ULONG
Definition: retypes.h:1
static HRESULT WINAPI AEV_GetMute(IAudioEndpointVolumeEx *iface, BOOL *mute)
Definition: audiovolume.c:213
static HRESULT WINAPI AEV_GetChannelVolumeLevel(IAudioEndpointVolumeEx *iface, UINT chan, float *leveldb)
Definition: audiovolume.c:181
#define E_POINTER
Definition: winerror.h:2365
LONG ref
Definition: audiovolume.c:45
static AEVImpl * impl_from_IAudioEndpointVolumeEx(IAudioEndpointVolumeEx *iface)
Definition: audiovolume.c:50
#define HeapFree(x, y, z)
Definition: compat.h:394
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static void AudioEndpointVolume_Destroy(AEVImpl *This)
Definition: audiovolume.c:55