webservices/tests: Add a test to show that the reader converts text to UTF-8.
[wine.git] / dlls / xaudio2_7 / xapofx.c
blob44dfb47a224368fa9930adc86fe1fd0470d20a6a
1 /*
2 * Copyright (c) 2015 Andrew Eikum 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 #include "config.h"
21 #include <stdarg.h>
23 #define NONAMELESSUNION
24 #define COBJMACROS
26 #include "initguid.h"
27 #include "xaudio_private.h"
28 #include "xapofx.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
34 #ifdef XAPOFX1_VER
35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, void *pReserved)
37 TRACE("(%p, %d, %p)\n", hinstDLL, reason, pReserved);
39 switch (reason)
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 DisableThreadLibraryCalls( hinstDLL );
45 break;
47 return TRUE;
49 #endif /* XAPOFX1_VER */
51 typedef struct _VUMeterImpl {
52 IXAPO IXAPO_iface;
53 IXAPOParameters IXAPOParameters_iface;
55 LONG ref;
56 } VUMeterImpl;
58 static VUMeterImpl *VUMeterImpl_from_IXAPO(IXAPO *iface)
60 return CONTAINING_RECORD(iface, VUMeterImpl, IXAPO_iface);
63 static VUMeterImpl *VUMeterImpl_from_IXAPOParameters(IXAPOParameters *iface)
65 return CONTAINING_RECORD(iface, VUMeterImpl, IXAPOParameters_iface);
68 static HRESULT WINAPI VUMXAPO_QueryInterface(IXAPO *iface, REFIID riid,
69 void **ppvObject)
71 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
73 TRACE("%p, %s, %p\n", This, wine_dbgstr_guid(riid), ppvObject);
75 if(IsEqualGUID(riid, &IID_IUnknown) ||
76 IsEqualGUID(riid, &IID_IXAPO) ||
77 IsEqualGUID(riid, &IID_IXAPO27))
78 *ppvObject = &This->IXAPO_iface;
79 else if(IsEqualGUID(riid, &IID_IXAPOParameters))
80 *ppvObject = &This->IXAPOParameters_iface;
81 else
82 *ppvObject = NULL;
84 if(*ppvObject){
85 IUnknown_AddRef((IUnknown*)*ppvObject);
86 return S_OK;
89 return E_NOINTERFACE;
92 static ULONG WINAPI VUMXAPO_AddRef(IXAPO *iface)
94 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
95 ULONG ref = InterlockedIncrement(&This->ref);
96 TRACE("(%p)->(): Refcount now %u\n", This, ref);
97 return ref;
100 static ULONG WINAPI VUMXAPO_Release(IXAPO *iface)
102 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
103 ULONG ref = InterlockedDecrement(&This->ref);
105 TRACE("(%p)->(): Refcount now %u\n", This, ref);
107 if(!ref)
108 HeapFree(GetProcessHeap(), 0, This);
110 return ref;
113 static HRESULT WINAPI VUMXAPO_GetRegistrationProperties(IXAPO *iface,
114 XAPO_REGISTRATION_PROPERTIES **props)
116 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
117 TRACE("%p, %p\n", This, props);
118 /* TODO: check for version == 20 and use XAPO20_REGISTRATION_PROPERTIES */
119 return E_NOTIMPL;
122 static HRESULT WINAPI VUMXAPO_IsInputFormatSupported(IXAPO *iface,
123 const WAVEFORMATEX *output_fmt, const WAVEFORMATEX *input_fmt,
124 WAVEFORMATEX **supported_fmt)
126 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
127 TRACE("%p, %p, %p, %p\n", This, output_fmt, input_fmt, supported_fmt);
128 return E_NOTIMPL;
131 static HRESULT WINAPI VUMXAPO_IsOutputFormatSupported(IXAPO *iface,
132 const WAVEFORMATEX *input_fmt, const WAVEFORMATEX *output_fmt,
133 WAVEFORMATEX **supported_fmt)
135 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
136 TRACE("%p, %p, %p, %p\n", This, input_fmt, output_fmt, supported_fmt);
137 return E_NOTIMPL;
140 static HRESULT WINAPI VUMXAPO_Initialize(IXAPO *iface, const void *data,
141 UINT32 data_len)
143 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
144 TRACE("%p, %p, %u\n", This, data, data_len);
145 return E_NOTIMPL;
148 static HRESULT WINAPI VUMXAPO_Reset(IXAPO *iface)
150 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
151 TRACE("%p\n", This);
152 return E_NOTIMPL;
155 static HRESULT WINAPI VUMXAPO_LockForProcess(IXAPO *iface,
156 UINT32 in_params_count,
157 const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *in_params,
158 UINT32 out_params_count,
159 const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *out_params)
161 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
162 TRACE("%p, %u, %p, %u, %p\n", This, in_params_count, in_params,
163 out_params_count, out_params);
164 return E_NOTIMPL;
167 static void WINAPI VUMXAPO_UnlockForProcess(IXAPO *iface)
169 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
170 TRACE("%p\n", This);
173 static void WINAPI VUMXAPO_Process(IXAPO *iface, UINT32 in_params_count,
174 const XAPO_PROCESS_BUFFER_PARAMETERS *in_params,
175 UINT32 out_params_count,
176 const XAPO_PROCESS_BUFFER_PARAMETERS *out_params, BOOL enabled)
178 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
179 TRACE("%p, %u, %p, %u, %p, %u\n", This, in_params_count, in_params,
180 out_params_count, out_params, enabled);
183 static UINT32 WINAPI VUMXAPO_CalcInputFrames(IXAPO *iface, UINT32 output_frames)
185 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
186 TRACE("%p, %u\n", This, output_frames);
187 return 0;
190 static UINT32 WINAPI VUMXAPO_CalcOutputFrames(IXAPO *iface, UINT32 input_frames)
192 VUMeterImpl *This = VUMeterImpl_from_IXAPO(iface);
193 TRACE("%p, %u\n", This, input_frames);
194 return 0;
197 static const IXAPOVtbl VUMXAPO_Vtbl = {
198 VUMXAPO_QueryInterface,
199 VUMXAPO_AddRef,
200 VUMXAPO_Release,
201 VUMXAPO_GetRegistrationProperties,
202 VUMXAPO_IsInputFormatSupported,
203 VUMXAPO_IsOutputFormatSupported,
204 VUMXAPO_Initialize,
205 VUMXAPO_Reset,
206 VUMXAPO_LockForProcess,
207 VUMXAPO_UnlockForProcess,
208 VUMXAPO_Process,
209 VUMXAPO_CalcInputFrames,
210 VUMXAPO_CalcOutputFrames
213 static HRESULT WINAPI VUMXAPOParams_QueryInterface(IXAPOParameters *iface,
214 REFIID riid, void **ppvObject)
216 VUMeterImpl *This = VUMeterImpl_from_IXAPOParameters(iface);
217 return VUMXAPO_QueryInterface(&This->IXAPO_iface, riid, ppvObject);
220 static ULONG WINAPI VUMXAPOParams_AddRef(IXAPOParameters *iface)
222 VUMeterImpl *This = VUMeterImpl_from_IXAPOParameters(iface);
223 return VUMXAPO_AddRef(&This->IXAPO_iface);
226 static ULONG WINAPI VUMXAPOParams_Release(IXAPOParameters *iface)
228 VUMeterImpl *This = VUMeterImpl_from_IXAPOParameters(iface);
229 return VUMXAPO_Release(&This->IXAPO_iface);
232 static void WINAPI VUMXAPOParams_SetParameters(IXAPOParameters *iface,
233 const void *params, UINT32 params_len)
235 VUMeterImpl *This = VUMeterImpl_from_IXAPOParameters(iface);
236 TRACE("%p, %p, %u\n", This, params, params_len);
239 static void WINAPI VUMXAPOParams_GetParameters(IXAPOParameters *iface,
240 void *params, UINT32 params_len)
242 VUMeterImpl *This = VUMeterImpl_from_IXAPOParameters(iface);
243 TRACE("%p, %p, %u\n", This, params, params_len);
246 static const IXAPOParametersVtbl VUMXAPOParameters_Vtbl = {
247 VUMXAPOParams_QueryInterface,
248 VUMXAPOParams_AddRef,
249 VUMXAPOParams_Release,
250 VUMXAPOParams_SetParameters,
251 VUMXAPOParams_GetParameters
254 typedef struct _ReverbImpl {
255 IXAPO IXAPO_iface;
256 IXAPOParameters IXAPOParameters_iface;
258 LONG ref;
259 } ReverbImpl;
261 static ReverbImpl *ReverbImpl_from_IXAPO(IXAPO *iface)
263 return CONTAINING_RECORD(iface, ReverbImpl, IXAPO_iface);
266 static ReverbImpl *ReverbImpl_from_IXAPOParameters(IXAPOParameters *iface)
268 return CONTAINING_RECORD(iface, ReverbImpl, IXAPOParameters_iface);
271 static HRESULT WINAPI RVBXAPO_QueryInterface(IXAPO *iface, REFIID riid, void **ppvObject)
273 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
275 TRACE("%p, %s, %p\n", This, wine_dbgstr_guid(riid), ppvObject);
277 if(IsEqualGUID(riid, &IID_IUnknown) ||
278 IsEqualGUID(riid, &IID_IXAPO) ||
279 IsEqualGUID(riid, &IID_IXAPO27))
280 *ppvObject = &This->IXAPO_iface;
281 else if(IsEqualGUID(riid, &IID_IXAPOParameters))
282 *ppvObject = &This->IXAPOParameters_iface;
283 else
284 *ppvObject = NULL;
286 if(*ppvObject){
287 IUnknown_AddRef((IUnknown*)*ppvObject);
288 return S_OK;
291 return E_NOINTERFACE;
294 static ULONG WINAPI RVBXAPO_AddRef(IXAPO *iface)
296 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
297 ULONG ref = InterlockedIncrement(&This->ref);
298 TRACE("(%p)->(): Refcount now %u\n", This, ref);
299 return ref;
302 static ULONG WINAPI RVBXAPO_Release(IXAPO *iface)
304 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
305 ULONG ref = InterlockedDecrement(&This->ref);
307 TRACE("(%p)->(): Refcount now %u\n", This, ref);
309 if(!ref)
310 HeapFree(GetProcessHeap(), 0, This);
312 return ref;
315 static HRESULT WINAPI RVBXAPO_GetRegistrationProperties(IXAPO *iface,
316 XAPO_REGISTRATION_PROPERTIES **props)
318 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
319 TRACE("%p, %p\n", This, props);
320 /* TODO: check for version == 20 and use XAPO20_REGISTRATION_PROPERTIES */
321 return E_NOTIMPL;
324 static HRESULT WINAPI RVBXAPO_IsInputFormatSupported(IXAPO *iface,
325 const WAVEFORMATEX *output_fmt, const WAVEFORMATEX *input_fmt,
326 WAVEFORMATEX **supported_fmt)
328 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
329 TRACE("%p, %p, %p, %p\n", This, output_fmt, input_fmt, supported_fmt);
330 return E_NOTIMPL;
333 static HRESULT WINAPI RVBXAPO_IsOutputFormatSupported(IXAPO *iface,
334 const WAVEFORMATEX *input_fmt, const WAVEFORMATEX *output_fmt,
335 WAVEFORMATEX **supported_fmt)
337 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
338 TRACE("%p, %p, %p, %p\n", This, input_fmt, output_fmt, supported_fmt);
339 return E_NOTIMPL;
342 static HRESULT WINAPI RVBXAPO_Initialize(IXAPO *iface, const void *data,
343 UINT32 data_len)
345 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
346 TRACE("%p, %p, %u\n", This, data, data_len);
347 return E_NOTIMPL;
350 static HRESULT WINAPI RVBXAPO_Reset(IXAPO *iface)
352 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
353 TRACE("%p\n", This);
354 return E_NOTIMPL;
357 static HRESULT WINAPI RVBXAPO_LockForProcess(IXAPO *iface, UINT32 in_params_count,
358 const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *in_params,
359 UINT32 out_params_count,
360 const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *out_params)
362 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
363 TRACE("%p, %u, %p, %u, %p\n", This, in_params_count, in_params,
364 out_params_count, out_params);
365 return E_NOTIMPL;
368 static void WINAPI RVBXAPO_UnlockForProcess(IXAPO *iface)
370 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
371 TRACE("%p\n", This);
374 static void WINAPI RVBXAPO_Process(IXAPO *iface, UINT32 in_params_count,
375 const XAPO_PROCESS_BUFFER_PARAMETERS *in_params,
376 UINT32 out_params_count,
377 const XAPO_PROCESS_BUFFER_PARAMETERS *out_params, BOOL enabled)
379 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
380 TRACE("%p, %u, %p, %u, %p, %u\n", This, in_params_count, in_params,
381 out_params_count, out_params, enabled);
384 static UINT32 WINAPI RVBXAPO_CalcInputFrames(IXAPO *iface, UINT32 output_frames)
386 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
387 TRACE("%p, %u\n", This, output_frames);
388 return 0;
391 static UINT32 WINAPI RVBXAPO_CalcOutputFrames(IXAPO *iface, UINT32 input_frames)
393 ReverbImpl *This = ReverbImpl_from_IXAPO(iface);
394 TRACE("%p, %u\n", This, input_frames);
395 return 0;
398 static const IXAPOVtbl RVBXAPO_Vtbl = {
399 RVBXAPO_QueryInterface,
400 RVBXAPO_AddRef,
401 RVBXAPO_Release,
402 RVBXAPO_GetRegistrationProperties,
403 RVBXAPO_IsInputFormatSupported,
404 RVBXAPO_IsOutputFormatSupported,
405 RVBXAPO_Initialize,
406 RVBXAPO_Reset,
407 RVBXAPO_LockForProcess,
408 RVBXAPO_UnlockForProcess,
409 RVBXAPO_Process,
410 RVBXAPO_CalcInputFrames,
411 RVBXAPO_CalcOutputFrames
414 static HRESULT WINAPI RVBXAPOParams_QueryInterface(IXAPOParameters *iface,
415 REFIID riid, void **ppvObject)
417 ReverbImpl *This = ReverbImpl_from_IXAPOParameters(iface);
418 return RVBXAPO_QueryInterface(&This->IXAPO_iface, riid, ppvObject);
421 static ULONG WINAPI RVBXAPOParams_AddRef(IXAPOParameters *iface)
423 ReverbImpl *This = ReverbImpl_from_IXAPOParameters(iface);
424 return RVBXAPO_AddRef(&This->IXAPO_iface);
427 static ULONG WINAPI RVBXAPOParams_Release(IXAPOParameters *iface)
429 ReverbImpl *This = ReverbImpl_from_IXAPOParameters(iface);
430 return RVBXAPO_Release(&This->IXAPO_iface);
433 static void WINAPI RVBXAPOParams_SetParameters(IXAPOParameters *iface,
434 const void *params, UINT32 params_len)
436 ReverbImpl *This = ReverbImpl_from_IXAPOParameters(iface);
437 TRACE("%p, %p, %u\n", This, params, params_len);
440 static void WINAPI RVBXAPOParams_GetParameters(IXAPOParameters *iface, void *params,
441 UINT32 params_len)
443 ReverbImpl *This = ReverbImpl_from_IXAPOParameters(iface);
444 TRACE("%p, %p, %u\n", This, params, params_len);
447 static const IXAPOParametersVtbl RVBXAPOParameters_Vtbl = {
448 RVBXAPOParams_QueryInterface,
449 RVBXAPOParams_AddRef,
450 RVBXAPOParams_Release,
451 RVBXAPOParams_SetParameters,
452 RVBXAPOParams_GetParameters
455 typedef struct _EQImpl {
456 IXAPO IXAPO_iface;
457 IXAPOParameters IXAPOParameters_iface;
459 LONG ref;
460 } EQImpl;
462 static EQImpl *EQImpl_from_IXAPO(IXAPO *iface)
464 return CONTAINING_RECORD(iface, EQImpl, IXAPO_iface);
467 static EQImpl *EQImpl_from_IXAPOParameters(IXAPOParameters *iface)
469 return CONTAINING_RECORD(iface, EQImpl, IXAPOParameters_iface);
472 static HRESULT WINAPI EQXAPO_QueryInterface(IXAPO *iface, REFIID riid, void **ppvObject)
474 EQImpl *This = EQImpl_from_IXAPO(iface);
476 TRACE("%p, %s, %p\n", This, wine_dbgstr_guid(riid), ppvObject);
478 if(IsEqualGUID(riid, &IID_IUnknown) ||
479 IsEqualGUID(riid, &IID_IXAPO) ||
480 IsEqualGUID(riid, &IID_IXAPO27))
481 *ppvObject = &This->IXAPO_iface;
482 else if(IsEqualGUID(riid, &IID_IXAPOParameters))
483 *ppvObject = &This->IXAPOParameters_iface;
484 else
485 *ppvObject = NULL;
487 if(*ppvObject){
488 IUnknown_AddRef((IUnknown*)*ppvObject);
489 return S_OK;
492 return E_NOINTERFACE;
495 static ULONG WINAPI EQXAPO_AddRef(IXAPO *iface)
497 EQImpl *This = EQImpl_from_IXAPO(iface);
498 ULONG ref = InterlockedIncrement(&This->ref);
499 TRACE("(%p)->(): Refcount now %u\n", This, ref);
500 return ref;
503 static ULONG WINAPI EQXAPO_Release(IXAPO *iface)
505 EQImpl *This = EQImpl_from_IXAPO(iface);
506 ULONG ref = InterlockedDecrement(&This->ref);
508 TRACE("(%p)->(): Refcount now %u\n", This, ref);
510 if(!ref)
511 HeapFree(GetProcessHeap(), 0, This);
513 return ref;
516 static HRESULT WINAPI EQXAPO_GetRegistrationProperties(IXAPO *iface,
517 XAPO_REGISTRATION_PROPERTIES **props)
519 EQImpl *This = EQImpl_from_IXAPO(iface);
520 TRACE("%p, %p\n", This, props);
521 /* TODO: check for version == 20 and use XAPO20_REGISTRATION_PROPERTIES */
522 return E_NOTIMPL;
525 static HRESULT WINAPI EQXAPO_IsInputFormatSupported(IXAPO *iface,
526 const WAVEFORMATEX *output_fmt, const WAVEFORMATEX *input_fmt,
527 WAVEFORMATEX **supported_fmt)
529 EQImpl *This = EQImpl_from_IXAPO(iface);
530 TRACE("%p, %p, %p, %p\n", This, output_fmt, input_fmt, supported_fmt);
531 return E_NOTIMPL;
534 static HRESULT WINAPI EQXAPO_IsOutputFormatSupported(IXAPO *iface,
535 const WAVEFORMATEX *input_fmt, const WAVEFORMATEX *output_fmt,
536 WAVEFORMATEX **supported_fmt)
538 EQImpl *This = EQImpl_from_IXAPO(iface);
539 TRACE("%p, %p, %p, %p\n", This, input_fmt, output_fmt, supported_fmt);
540 return E_NOTIMPL;
543 static HRESULT WINAPI EQXAPO_Initialize(IXAPO *iface, const void *data,
544 UINT32 data_len)
546 EQImpl *This = EQImpl_from_IXAPO(iface);
547 TRACE("%p, %p, %u\n", This, data, data_len);
548 return E_NOTIMPL;
551 static HRESULT WINAPI EQXAPO_Reset(IXAPO *iface)
553 EQImpl *This = EQImpl_from_IXAPO(iface);
554 TRACE("%p\n", This);
555 return E_NOTIMPL;
558 static HRESULT WINAPI EQXAPO_LockForProcess(IXAPO *iface, UINT32 in_params_count,
559 const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *in_params,
560 UINT32 out_params_count,
561 const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS *out_params)
563 EQImpl *This = EQImpl_from_IXAPO(iface);
564 TRACE("%p, %u, %p, %u, %p\n", This, in_params_count, in_params,
565 out_params_count, out_params);
566 return E_NOTIMPL;
569 static void WINAPI EQXAPO_UnlockForProcess(IXAPO *iface)
571 EQImpl *This = EQImpl_from_IXAPO(iface);
572 TRACE("%p\n", This);
575 static void WINAPI EQXAPO_Process(IXAPO *iface, UINT32 in_params_count,
576 const XAPO_PROCESS_BUFFER_PARAMETERS *in_params,
577 UINT32 out_params_count,
578 const XAPO_PROCESS_BUFFER_PARAMETERS *out_params, BOOL enabled)
580 EQImpl *This = EQImpl_from_IXAPO(iface);
581 TRACE("%p, %u, %p, %u, %p, %u\n", This, in_params_count, in_params,
582 out_params_count, out_params, enabled);
585 static UINT32 WINAPI EQXAPO_CalcInputFrames(IXAPO *iface, UINT32 output_frames)
587 EQImpl *This = EQImpl_from_IXAPO(iface);
588 TRACE("%p, %u\n", This, output_frames);
589 return 0;
592 static UINT32 WINAPI EQXAPO_CalcOutputFrames(IXAPO *iface, UINT32 input_frames)
594 EQImpl *This = EQImpl_from_IXAPO(iface);
595 TRACE("%p, %u\n", This, input_frames);
596 return 0;
599 static const IXAPOVtbl EQXAPO_Vtbl = {
600 EQXAPO_QueryInterface,
601 EQXAPO_AddRef,
602 EQXAPO_Release,
603 EQXAPO_GetRegistrationProperties,
604 EQXAPO_IsInputFormatSupported,
605 EQXAPO_IsOutputFormatSupported,
606 EQXAPO_Initialize,
607 EQXAPO_Reset,
608 EQXAPO_LockForProcess,
609 EQXAPO_UnlockForProcess,
610 EQXAPO_Process,
611 EQXAPO_CalcInputFrames,
612 EQXAPO_CalcOutputFrames
615 static HRESULT WINAPI EQXAPOParams_QueryInterface(IXAPOParameters *iface,
616 REFIID riid, void **ppvObject)
618 EQImpl *This = EQImpl_from_IXAPOParameters(iface);
619 return EQXAPO_QueryInterface(&This->IXAPO_iface, riid, ppvObject);
622 static ULONG WINAPI EQXAPOParams_AddRef(IXAPOParameters *iface)
624 EQImpl *This = EQImpl_from_IXAPOParameters(iface);
625 return EQXAPO_AddRef(&This->IXAPO_iface);
628 static ULONG WINAPI EQXAPOParams_Release(IXAPOParameters *iface)
630 EQImpl *This = EQImpl_from_IXAPOParameters(iface);
631 return EQXAPO_Release(&This->IXAPO_iface);
634 static void WINAPI EQXAPOParams_SetParameters(IXAPOParameters *iface,
635 const void *params, UINT32 params_len)
637 EQImpl *This = EQImpl_from_IXAPOParameters(iface);
638 TRACE("%p, %p, %u\n", This, params, params_len);
641 static void WINAPI EQXAPOParams_GetParameters(IXAPOParameters *iface, void *params,
642 UINT32 params_len)
644 EQImpl *This = EQImpl_from_IXAPOParameters(iface);
645 TRACE("%p, %p, %u\n", This, params, params_len);
648 static const IXAPOParametersVtbl EQXAPOParameters_Vtbl = {
649 EQXAPOParams_QueryInterface,
650 EQXAPOParams_AddRef,
651 EQXAPOParams_Release,
652 EQXAPOParams_SetParameters,
653 EQXAPOParams_GetParameters
656 struct xapo_cf {
657 IClassFactory IClassFactory_iface;
658 LONG ref;
659 const CLSID *class;
662 static struct xapo_cf *xapo_impl_from_IClassFactory(IClassFactory *iface)
664 return CONTAINING_RECORD(iface, struct xapo_cf, IClassFactory_iface);
667 static HRESULT WINAPI xapocf_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
669 if(IsEqualGUID(riid, &IID_IUnknown)
670 || IsEqualGUID(riid, &IID_IClassFactory))
672 IClassFactory_AddRef(iface);
673 *ppobj = iface;
674 return S_OK;
677 *ppobj = NULL;
678 WARN("(%p)->(%s, %p): interface not found\n", iface, debugstr_guid(riid), ppobj);
679 return E_NOINTERFACE;
682 static ULONG WINAPI xapocf_AddRef(IClassFactory *iface)
684 struct xapo_cf *This = xapo_impl_from_IClassFactory(iface);
685 ULONG ref = InterlockedIncrement(&This->ref);
686 TRACE("(%p)->(): Refcount now %u\n", This, ref);
687 return ref;
690 static ULONG WINAPI xapocf_Release(IClassFactory *iface)
692 struct xapo_cf *This = xapo_impl_from_IClassFactory(iface);
693 ULONG ref = InterlockedDecrement(&This->ref);
694 TRACE("(%p)->(): Refcount now %u\n", This, ref);
695 if (!ref)
696 HeapFree(GetProcessHeap(), 0, This);
697 return ref;
700 static HRESULT WINAPI xapocf_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
701 REFIID riid, void **ppobj)
703 struct xapo_cf *This = xapo_impl_from_IClassFactory(iface);
704 HRESULT hr;
706 TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
708 *ppobj = NULL;
710 if(pOuter)
711 return CLASS_E_NOAGGREGATION;
713 if(IsEqualGUID(This->class, &CLSID_AudioVolumeMeter27)){
714 VUMeterImpl *object;
716 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
717 if(!object)
718 return E_OUTOFMEMORY;
720 object->IXAPO_iface.lpVtbl = &VUMXAPO_Vtbl;
721 object->IXAPOParameters_iface.lpVtbl = &VUMXAPOParameters_Vtbl;
723 hr = IXAPO_QueryInterface(&object->IXAPO_iface, riid, ppobj);
724 if(FAILED(hr)){
725 HeapFree(GetProcessHeap(), 0, object);
726 return hr;
728 }else if(IsEqualGUID(This->class, &CLSID_FXReverb)){
729 ReverbImpl *object;
731 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
732 if(!object)
733 return E_OUTOFMEMORY;
735 object->IXAPO_iface.lpVtbl = &RVBXAPO_Vtbl;
736 object->IXAPOParameters_iface.lpVtbl = &RVBXAPOParameters_Vtbl;
738 hr = IXAPO_QueryInterface(&object->IXAPO_iface, riid, ppobj);
739 if(FAILED(hr)){
740 HeapFree(GetProcessHeap(), 0, object);
741 return hr;
743 }else if(IsEqualGUID(This->class, &CLSID_FXEQ)){
744 EQImpl *object;
746 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
747 if(!object)
748 return E_OUTOFMEMORY;
750 object->IXAPO_iface.lpVtbl = &EQXAPO_Vtbl;
751 object->IXAPOParameters_iface.lpVtbl = &EQXAPOParameters_Vtbl;
753 hr = IXAPO_QueryInterface(&object->IXAPO_iface, riid, ppobj);
754 if(FAILED(hr)){
755 HeapFree(GetProcessHeap(), 0, object);
756 return hr;
758 }else
759 /* TODO FXECHO, FXMasteringLimiter, */
760 return E_INVALIDARG;
762 return S_OK;
765 static HRESULT WINAPI xapocf_LockServer(IClassFactory *iface, BOOL dolock)
767 FIXME("(static)->(%d): stub!\n", dolock);
768 return S_OK;
771 static const IClassFactoryVtbl xapo_Vtbl =
773 xapocf_QueryInterface,
774 xapocf_AddRef,
775 xapocf_Release,
776 xapocf_CreateInstance,
777 xapocf_LockServer
780 IClassFactory *make_xapo_factory(REFCLSID clsid)
782 struct xapo_cf *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct xapo_cf));
783 ret->IClassFactory_iface.lpVtbl = &xapo_Vtbl;
784 ret->class = clsid;
785 ret->ref = 0;
786 return &ret->IClassFactory_iface;
789 #if XAUDIO2_VER >= 8
790 HRESULT WINAPI CreateAudioVolumeMeter(IUnknown **out)
792 IClassFactory *cf;
793 HRESULT hr;
795 cf = make_xapo_factory(&CLSID_AudioVolumeMeter27);
797 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)out);
799 IClassFactory_Release(cf);
801 return hr;
804 HRESULT WINAPI CreateAudioReverb(IUnknown **out)
806 IClassFactory *cf;
807 HRESULT hr;
809 cf = make_xapo_factory(&CLSID_FXReverb);
811 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)out);
813 IClassFactory_Release(cf);
815 return hr;
818 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out, void *initdata, UINT32 initdata_bytes)
820 HRESULT hr;
821 IUnknown *obj;
822 const GUID *class = NULL;
823 IClassFactory *cf;
825 *out = NULL;
827 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
828 IsEqualGUID(clsid, &CLSID_FXReverb))
829 class = &CLSID_FXReverb;
830 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
831 IsEqualGUID(clsid, &CLSID_FXEQ))
832 class = &CLSID_FXEQ;
834 if(class){
835 cf = make_xapo_factory(class);
837 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
838 IClassFactory_Release(cf);
839 if(FAILED(hr))
840 return hr;
841 }else{
842 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
843 if(FAILED(hr)){
844 WARN("CoCreateInstance failed: %08x\n", hr);
845 return hr;
849 if(initdata && initdata_bytes > 0){
850 IXAPO *xapo;
852 hr = IUnknown_QueryInterface(obj, &IID_IXAPO, (void**)&xapo);
853 if(SUCCEEDED(hr)){
854 hr = IXAPO_Initialize(xapo, initdata, initdata_bytes);
856 IXAPO_Release(xapo);
858 if(FAILED(hr)){
859 WARN("Initialize failed: %08x\n", hr);
860 IUnknown_Release(obj);
861 return hr;
866 *out = obj;
868 return S_OK;
870 #endif /* XAUDIO2_VER >= 8 */
872 #ifdef XAPOFX1_VER
873 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out)
875 HRESULT hr;
876 IUnknown *obj;
877 const GUID *class = NULL;
878 IClassFactory *cf;
880 TRACE("%s %p\n", debugstr_guid(clsid), out);
882 *out = NULL;
884 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
885 IsEqualGUID(clsid, &CLSID_FXReverb))
886 class = &CLSID_FXReverb;
887 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
888 IsEqualGUID(clsid, &CLSID_FXEQ))
889 class = &CLSID_FXEQ;
890 /* TODO FXECHO, FXMasteringLimiter, */
892 if(class){
893 cf = make_xapo_factory(class);
895 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
896 IClassFactory_Release(cf);
897 if(FAILED(hr))
898 return hr;
899 }else{
900 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
901 if(FAILED(hr)){
902 WARN("CoCreateInstance failed: %08x\n", hr);
903 return hr;
907 *out = obj;
909 return S_OK;
911 #endif /* XAPOFX1_VER */