msvcp90: Add codecvt<wchar_t>::do_encoding that returns 0.
[wine.git] / dlls / xaudio2_7 / compat.c
blobf2f7cd8530c85628744b81507d819407f5a4d93e
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
18 ***************
20 * Some versions of XAudio2 add or remove functions to the COM vtables, or
21 * incompatibly change structures. This file provides implementations of the
22 * older XAudio2 versions onto the new XAudio2 APIs.
24 * Below is a list of significant changes to the main XAudio2 interfaces and
25 * API. There may be further changes to effects and other parts that Wine
26 * doesn't currently implement.
28 * 2.0
29 * Initial version
31 * 2.1
32 * Change CLSID_XAudio2
33 * Re-order Error codes
34 * Change XAUDIO2_LOOP_INFINITE
35 * Change struct XAUDIO2_PERFORMANCE_DATA
36 * Change IXAudio2Voice::GetOutputMatrix return value to void
37 * Add parameter to IXAudio2VoiceCallback::OnVoiceProcessingPassStart
38 * Change struct XAPO_REGISTRATION_PROPERTIES. CAREFUL when using! Not all
39 * implementations of IXAPO are Wine implementations.
41 * 2.2
42 * Change CLSID_XAudio2
43 * No ABI break
45 * 2.3
46 * Change CLSID_XAudio2
47 * ABI break:
48 * Change struct XAUDIO2_PERFORMANCE_DATA
50 * 2.4
51 * Change CLSID_XAudio2
52 * ABI break:
53 * Add IXAudio2Voice::SetOutputFilterParameters
54 * Add IXAudio2Voice::GetOutputFilterParameters
55 * Add IXAudio2SourceVoice::SetSourceSampleRate
56 * Change struct XAUDIO2_VOICE_SENDS
58 * 2.5
59 * Change CLSID_XAudio2
60 * No ABI break
62 * 2.6
63 * Change CLSID_XAudio2
64 * No ABI break
66 * 2.7
67 * Change CLSID_XAudio2
68 * No ABI break
70 * 2.8
71 * Remove CLSID_XAudio2
72 * Change IID_IXAudio2
73 * Add xaudio2_8.XAudio2Create
74 * ABI break:
75 * Remove IXAudio2::GetDeviceCount
76 * Remove IXAudio2::GetDeviceDetails
77 * Remove IXAudio2::Initialize
78 * Change parameter of IXAudio2::CreateMasteringVoice
79 * Add Flags parameter to IXAudio2SourceVoice::GetState
80 * Add IXAudio2MasteringVoice::GetChannelMask
81 * Add DisableLateField member to XAUDIO2FX_REVERB_PARAMETERS
83 * 2.9
84 * Change IID_IXAudio2
85 * New flags: XAUDIO2_STOP_ENGINE_WHEN_IDLE, XAUDIO2_1024_QUANTUM,
86 * XAUDIO2_NO_VIRTUAL_AUDIO_CLIENT
87 * ABI break:
88 * Add SideDelay member to XAUDIO2FX_REVERB_PARAMETERS
91 #include "config.h"
93 #define NONAMELESSUNION
94 #define NONAMELESSSTRUCT
95 #define COBJMACROS
97 #include <stdarg.h>
99 #include "xaudio_private.h"
101 #include "wine/debug.h"
103 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
105 /* BEGIN IXAudio2SourceVoice */
106 #if XAUDIO2_VER == 0
107 static XA2SourceImpl *impl_from_IXAudio20SourceVoice(IXAudio20SourceVoice *iface)
109 return CONTAINING_RECORD(iface, XA2SourceImpl, IXAudio20SourceVoice_iface);
112 static void WINAPI XA20SRC_GetVoiceDetails(IXAudio20SourceVoice *iface,
113 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
115 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
116 return IXAudio2SourceVoice_GetVoiceDetails(&This->IXAudio2SourceVoice_iface, pVoiceDetails);
119 static HRESULT WINAPI XA20SRC_SetOutputVoices(IXAudio20SourceVoice *iface,
120 const XAUDIO23_VOICE_SENDS *pSendList)
122 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
123 XAUDIO2_VOICE_SENDS sends;
124 HRESULT hr;
125 DWORD i;
127 TRACE("%p, %p\n", This, pSendList);
129 sends.SendCount = pSendList->OutputCount;
130 sends.pSends = HeapAlloc(GetProcessHeap(), 0, sends.SendCount * sizeof(*sends.pSends));
131 for(i = 0; i < sends.SendCount; ++i){
132 sends.pSends[i].Flags = 0;
133 sends.pSends[i].pOutputVoice = pSendList->pOutputVoices[i];
136 hr = IXAudio2SourceVoice_SetOutputVoices(&This->IXAudio2SourceVoice_iface, &sends);
138 HeapFree(GetProcessHeap(), 0, sends.pSends);
140 return hr;
143 static HRESULT WINAPI XA20SRC_SetEffectChain(IXAudio20SourceVoice *iface,
144 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
146 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
147 return IXAudio2SourceVoice_SetEffectChain(&This->IXAudio2SourceVoice_iface, pEffectChain);
150 static HRESULT WINAPI XA20SRC_EnableEffect(IXAudio20SourceVoice *iface,
151 UINT32 EffectIndex, UINT32 OperationSet)
153 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
154 return IXAudio2SourceVoice_EnableEffect(&This->IXAudio2SourceVoice_iface,
155 EffectIndex, OperationSet);
158 static HRESULT WINAPI XA20SRC_DisableEffect(IXAudio20SourceVoice *iface,
159 UINT32 EffectIndex, UINT32 OperationSet)
161 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
162 return IXAudio2SourceVoice_DisableEffect(&This->IXAudio2SourceVoice_iface,
163 EffectIndex, OperationSet);
166 static void WINAPI XA20SRC_GetEffectState(IXAudio20SourceVoice *iface,
167 UINT32 EffectIndex, BOOL *pEnabled)
169 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
170 return IXAudio2SourceVoice_GetEffectState(&This->IXAudio2SourceVoice_iface,
171 EffectIndex, pEnabled);
174 static HRESULT WINAPI XA20SRC_SetEffectParameters(IXAudio20SourceVoice *iface,
175 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
176 UINT32 OperationSet)
178 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
179 return IXAudio2SourceVoice_SetEffectParameters(&This->IXAudio2SourceVoice_iface,
180 EffectIndex, pParameters, ParametersByteSize, OperationSet);
183 static HRESULT WINAPI XA20SRC_GetEffectParameters(IXAudio20SourceVoice *iface,
184 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
186 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
187 return IXAudio2SourceVoice_GetEffectParameters(&This->IXAudio2SourceVoice_iface,
188 EffectIndex, pParameters, ParametersByteSize);
191 static HRESULT WINAPI XA20SRC_SetFilterParameters(IXAudio20SourceVoice *iface,
192 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
194 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
195 return IXAudio2SourceVoice_SetFilterParameters(&This->IXAudio2SourceVoice_iface,
196 pParameters, OperationSet);
199 static void WINAPI XA20SRC_GetFilterParameters(IXAudio20SourceVoice *iface,
200 XAUDIO2_FILTER_PARAMETERS *pParameters)
202 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
203 return IXAudio2SourceVoice_GetFilterParameters(&This->IXAudio2SourceVoice_iface, pParameters);
206 static HRESULT WINAPI XA20SRC_SetVolume(IXAudio20SourceVoice *iface,
207 float Volume, UINT32 OperationSet)
209 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
210 return IXAudio2SourceVoice_SetVolume(&This->IXAudio2SourceVoice_iface,
211 Volume, OperationSet);
214 static void WINAPI XA20SRC_GetVolume(IXAudio20SourceVoice *iface,
215 float *pVolume)
217 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
218 return IXAudio2SourceVoice_GetVolume(&This->IXAudio2SourceVoice_iface, pVolume);
221 static HRESULT WINAPI XA20SRC_SetChannelVolumes(IXAudio20SourceVoice *iface,
222 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
224 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
225 return IXAudio2SourceVoice_SetChannelVolumes(&This->IXAudio2SourceVoice_iface,
226 Channels, pVolumes, OperationSet);
229 static void WINAPI XA20SRC_GetChannelVolumes(IXAudio20SourceVoice *iface,
230 UINT32 Channels, float *pVolumes)
232 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
233 return IXAudio2SourceVoice_GetChannelVolumes(&This->IXAudio2SourceVoice_iface,
234 Channels, pVolumes);
237 static HRESULT WINAPI XA20SRC_SetOutputMatrix(IXAudio20SourceVoice *iface,
238 IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
239 UINT32 DestinationChannels, const float *pLevelMatrix,
240 UINT32 OperationSet)
242 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
243 return IXAudio2SourceVoice_SetOutputMatrix(&This->IXAudio2SourceVoice_iface,
244 pDestinationVoice, SourceChannels, DestinationChannels,
245 pLevelMatrix, OperationSet);
248 static HRESULT WINAPI XA20SRC_GetOutputMatrix(IXAudio20SourceVoice *iface,
249 IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
250 UINT32 DestinationChannels, float *pLevelMatrix)
252 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
253 IXAudio2SourceVoice_GetOutputMatrix(&This->IXAudio2SourceVoice_iface,
254 pDestinationVoice, SourceChannels, DestinationChannels,
255 pLevelMatrix);
256 return S_OK;
259 static void WINAPI XA20SRC_DestroyVoice(IXAudio20SourceVoice *iface)
261 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
262 return IXAudio2SourceVoice_DestroyVoice(&This->IXAudio2SourceVoice_iface);
265 static HRESULT WINAPI XA20SRC_Start(IXAudio20SourceVoice *iface, UINT32 Flags,
266 UINT32 OperationSet)
268 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
269 return IXAudio2SourceVoice_Start(&This->IXAudio2SourceVoice_iface, Flags, OperationSet);
272 static HRESULT WINAPI XA20SRC_Stop(IXAudio20SourceVoice *iface, UINT32 Flags,
273 UINT32 OperationSet)
275 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
276 return IXAudio2SourceVoice_Stop(&This->IXAudio2SourceVoice_iface, Flags, OperationSet);
279 static HRESULT WINAPI XA20SRC_SubmitSourceBuffer(IXAudio20SourceVoice *iface,
280 const XAUDIO2_BUFFER *pBuffer, const XAUDIO2_BUFFER_WMA *pBufferWMA)
282 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
283 return IXAudio2SourceVoice_SubmitSourceBuffer(&This->IXAudio2SourceVoice_iface,
284 pBuffer, pBufferWMA);
287 static HRESULT WINAPI XA20SRC_FlushSourceBuffers(IXAudio20SourceVoice *iface)
289 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
290 return IXAudio2SourceVoice_FlushSourceBuffers(&This->IXAudio2SourceVoice_iface);
293 static HRESULT WINAPI XA20SRC_Discontinuity(IXAudio20SourceVoice *iface)
295 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
296 return IXAudio2SourceVoice_Discontinuity(&This->IXAudio2SourceVoice_iface);
299 static HRESULT WINAPI XA20SRC_ExitLoop(IXAudio20SourceVoice *iface,
300 UINT32 OperationSet)
302 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
303 return IXAudio2SourceVoice_ExitLoop(&This->IXAudio2SourceVoice_iface, OperationSet);
306 static void WINAPI XA20SRC_GetState(IXAudio20SourceVoice *iface,
307 XAUDIO2_VOICE_STATE *pVoiceState)
309 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
310 return IXAudio2SourceVoice_GetState(&This->IXAudio2SourceVoice_iface, pVoiceState, 0);
313 static HRESULT WINAPI XA20SRC_SetFrequencyRatio(IXAudio20SourceVoice *iface,
314 float Ratio, UINT32 OperationSet)
316 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
317 return IXAudio2SourceVoice_SetFrequencyRatio(&This->IXAudio2SourceVoice_iface,
318 Ratio, OperationSet);
321 static void WINAPI XA20SRC_GetFrequencyRatio(IXAudio20SourceVoice *iface,
322 float *pRatio)
324 XA2SourceImpl *This = impl_from_IXAudio20SourceVoice(iface);
325 return IXAudio2SourceVoice_GetFrequencyRatio(&This->IXAudio2SourceVoice_iface, pRatio);
328 const IXAudio20SourceVoiceVtbl XAudio20SourceVoice_Vtbl = {
329 XA20SRC_GetVoiceDetails,
330 XA20SRC_SetOutputVoices,
331 XA20SRC_SetEffectChain,
332 XA20SRC_EnableEffect,
333 XA20SRC_DisableEffect,
334 XA20SRC_GetEffectState,
335 XA20SRC_SetEffectParameters,
336 XA20SRC_GetEffectParameters,
337 XA20SRC_SetFilterParameters,
338 XA20SRC_GetFilterParameters,
339 XA20SRC_SetVolume,
340 XA20SRC_GetVolume,
341 XA20SRC_SetChannelVolumes,
342 XA20SRC_GetChannelVolumes,
343 XA20SRC_SetOutputMatrix,
344 XA20SRC_GetOutputMatrix,
345 XA20SRC_DestroyVoice,
346 XA20SRC_Start,
347 XA20SRC_Stop,
348 XA20SRC_SubmitSourceBuffer,
349 XA20SRC_FlushSourceBuffers,
350 XA20SRC_Discontinuity,
351 XA20SRC_ExitLoop,
352 XA20SRC_GetState,
353 XA20SRC_SetFrequencyRatio,
354 XA20SRC_GetFrequencyRatio,
357 #elif XAUDIO2_VER <= 3
359 static XA2SourceImpl *impl_from_IXAudio23SourceVoice(IXAudio23SourceVoice *iface)
361 return CONTAINING_RECORD(iface, XA2SourceImpl, IXAudio23SourceVoice_iface);
364 static void WINAPI XA23SRC_GetVoiceDetails(IXAudio23SourceVoice *iface,
365 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
367 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
368 return IXAudio2SourceVoice_GetVoiceDetails(&This->IXAudio2SourceVoice_iface, pVoiceDetails);
371 static HRESULT WINAPI XA23SRC_SetOutputVoices(IXAudio23SourceVoice *iface,
372 const XAUDIO23_VOICE_SENDS *pSendList)
374 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
375 XAUDIO2_VOICE_SENDS sends;
376 HRESULT hr;
377 DWORD i;
379 TRACE("%p, %p\n", This, pSendList);
381 sends.SendCount = pSendList->OutputCount;
382 sends.pSends = HeapAlloc(GetProcessHeap(), 0, sends.SendCount * sizeof(*sends.pSends));
383 for(i = 0; i < sends.SendCount; ++i){
384 sends.pSends[i].Flags = 0;
385 sends.pSends[i].pOutputVoice = pSendList->pOutputVoices[i];
388 hr = IXAudio2SourceVoice_SetOutputVoices(&This->IXAudio2SourceVoice_iface, &sends);
390 HeapFree(GetProcessHeap(), 0, sends.pSends);
392 return hr;
395 static HRESULT WINAPI XA23SRC_SetEffectChain(IXAudio23SourceVoice *iface,
396 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
398 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
399 return IXAudio2SourceVoice_SetEffectChain(&This->IXAudio2SourceVoice_iface, pEffectChain);
402 static HRESULT WINAPI XA23SRC_EnableEffect(IXAudio23SourceVoice *iface,
403 UINT32 EffectIndex, UINT32 OperationSet)
405 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
406 return IXAudio2SourceVoice_EnableEffect(&This->IXAudio2SourceVoice_iface,
407 EffectIndex, OperationSet);
410 static HRESULT WINAPI XA23SRC_DisableEffect(IXAudio23SourceVoice *iface,
411 UINT32 EffectIndex, UINT32 OperationSet)
413 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
414 return IXAudio2SourceVoice_DisableEffect(&This->IXAudio2SourceVoice_iface,
415 EffectIndex, OperationSet);
418 static void WINAPI XA23SRC_GetEffectState(IXAudio23SourceVoice *iface,
419 UINT32 EffectIndex, BOOL *pEnabled)
421 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
422 return IXAudio2SourceVoice_GetEffectState(&This->IXAudio2SourceVoice_iface,
423 EffectIndex, pEnabled);
426 static HRESULT WINAPI XA23SRC_SetEffectParameters(IXAudio23SourceVoice *iface,
427 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
428 UINT32 OperationSet)
430 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
431 return IXAudio2SourceVoice_SetEffectParameters(&This->IXAudio2SourceVoice_iface,
432 EffectIndex, pParameters, ParametersByteSize, OperationSet);
435 static HRESULT WINAPI XA23SRC_GetEffectParameters(IXAudio23SourceVoice *iface,
436 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
438 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
439 return IXAudio2SourceVoice_GetEffectParameters(&This->IXAudio2SourceVoice_iface,
440 EffectIndex, pParameters, ParametersByteSize);
443 static HRESULT WINAPI XA23SRC_SetFilterParameters(IXAudio23SourceVoice *iface,
444 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
446 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
447 return IXAudio2SourceVoice_SetFilterParameters(&This->IXAudio2SourceVoice_iface,
448 pParameters, OperationSet);
451 static void WINAPI XA23SRC_GetFilterParameters(IXAudio23SourceVoice *iface,
452 XAUDIO2_FILTER_PARAMETERS *pParameters)
454 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
455 return IXAudio2SourceVoice_GetFilterParameters(&This->IXAudio2SourceVoice_iface, pParameters);
458 static HRESULT WINAPI XA23SRC_SetVolume(IXAudio23SourceVoice *iface,
459 float Volume, UINT32 OperationSet)
461 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
462 return IXAudio2SourceVoice_SetVolume(&This->IXAudio2SourceVoice_iface,
463 Volume, OperationSet);
466 static void WINAPI XA23SRC_GetVolume(IXAudio23SourceVoice *iface,
467 float *pVolume)
469 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
470 return IXAudio2SourceVoice_GetVolume(&This->IXAudio2SourceVoice_iface, pVolume);
473 static HRESULT WINAPI XA23SRC_SetChannelVolumes(IXAudio23SourceVoice *iface,
474 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
476 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
477 return IXAudio2SourceVoice_SetChannelVolumes(&This->IXAudio2SourceVoice_iface,
478 Channels, pVolumes, OperationSet);
481 static void WINAPI XA23SRC_GetChannelVolumes(IXAudio23SourceVoice *iface,
482 UINT32 Channels, float *pVolumes)
484 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
485 return IXAudio2SourceVoice_GetChannelVolumes(&This->IXAudio2SourceVoice_iface,
486 Channels, pVolumes);
489 static HRESULT WINAPI XA23SRC_SetOutputMatrix(IXAudio23SourceVoice *iface,
490 IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
491 UINT32 DestinationChannels, const float *pLevelMatrix,
492 UINT32 OperationSet)
494 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
495 return IXAudio2SourceVoice_SetOutputMatrix(&This->IXAudio2SourceVoice_iface,
496 pDestinationVoice, SourceChannels, DestinationChannels,
497 pLevelMatrix, OperationSet);
500 static void WINAPI XA23SRC_GetOutputMatrix(IXAudio23SourceVoice *iface,
501 IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
502 UINT32 DestinationChannels, float *pLevelMatrix)
504 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
505 return IXAudio2SourceVoice_GetOutputMatrix(&This->IXAudio2SourceVoice_iface,
506 pDestinationVoice, SourceChannels, DestinationChannels,
507 pLevelMatrix);
510 static void WINAPI XA23SRC_DestroyVoice(IXAudio23SourceVoice *iface)
512 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
513 return IXAudio2SourceVoice_DestroyVoice(&This->IXAudio2SourceVoice_iface);
516 static HRESULT WINAPI XA23SRC_Start(IXAudio23SourceVoice *iface, UINT32 Flags,
517 UINT32 OperationSet)
519 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
520 return IXAudio2SourceVoice_Start(&This->IXAudio2SourceVoice_iface, Flags, OperationSet);
523 static HRESULT WINAPI XA23SRC_Stop(IXAudio23SourceVoice *iface, UINT32 Flags,
524 UINT32 OperationSet)
526 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
527 return IXAudio2SourceVoice_Stop(&This->IXAudio2SourceVoice_iface, Flags, OperationSet);
530 static HRESULT WINAPI XA23SRC_SubmitSourceBuffer(IXAudio23SourceVoice *iface,
531 const XAUDIO2_BUFFER *pBuffer, const XAUDIO2_BUFFER_WMA *pBufferWMA)
533 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
534 return IXAudio2SourceVoice_SubmitSourceBuffer(&This->IXAudio2SourceVoice_iface,
535 pBuffer, pBufferWMA);
538 static HRESULT WINAPI XA23SRC_FlushSourceBuffers(IXAudio23SourceVoice *iface)
540 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
541 return IXAudio2SourceVoice_FlushSourceBuffers(&This->IXAudio2SourceVoice_iface);
544 static HRESULT WINAPI XA23SRC_Discontinuity(IXAudio23SourceVoice *iface)
546 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
547 return IXAudio2SourceVoice_Discontinuity(&This->IXAudio2SourceVoice_iface);
550 static HRESULT WINAPI XA23SRC_ExitLoop(IXAudio23SourceVoice *iface,
551 UINT32 OperationSet)
553 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
554 return IXAudio2SourceVoice_ExitLoop(&This->IXAudio2SourceVoice_iface, OperationSet);
557 static void WINAPI XA23SRC_GetState(IXAudio23SourceVoice *iface,
558 XAUDIO2_VOICE_STATE *pVoiceState)
560 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
561 return IXAudio2SourceVoice_GetState(&This->IXAudio2SourceVoice_iface, pVoiceState, 0);
564 static HRESULT WINAPI XA23SRC_SetFrequencyRatio(IXAudio23SourceVoice *iface,
565 float Ratio, UINT32 OperationSet)
567 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
568 return IXAudio2SourceVoice_SetFrequencyRatio(&This->IXAudio2SourceVoice_iface,
569 Ratio, OperationSet);
572 static void WINAPI XA23SRC_GetFrequencyRatio(IXAudio23SourceVoice *iface,
573 float *pRatio)
575 XA2SourceImpl *This = impl_from_IXAudio23SourceVoice(iface);
576 return IXAudio2SourceVoice_GetFrequencyRatio(&This->IXAudio2SourceVoice_iface, pRatio);
579 const IXAudio23SourceVoiceVtbl XAudio23SourceVoice_Vtbl = {
580 XA23SRC_GetVoiceDetails,
581 XA23SRC_SetOutputVoices,
582 XA23SRC_SetEffectChain,
583 XA23SRC_EnableEffect,
584 XA23SRC_DisableEffect,
585 XA23SRC_GetEffectState,
586 XA23SRC_SetEffectParameters,
587 XA23SRC_GetEffectParameters,
588 XA23SRC_SetFilterParameters,
589 XA23SRC_GetFilterParameters,
590 XA23SRC_SetVolume,
591 XA23SRC_GetVolume,
592 XA23SRC_SetChannelVolumes,
593 XA23SRC_GetChannelVolumes,
594 XA23SRC_SetOutputMatrix,
595 XA23SRC_GetOutputMatrix,
596 XA23SRC_DestroyVoice,
597 XA23SRC_Start,
598 XA23SRC_Stop,
599 XA23SRC_SubmitSourceBuffer,
600 XA23SRC_FlushSourceBuffers,
601 XA23SRC_Discontinuity,
602 XA23SRC_ExitLoop,
603 XA23SRC_GetState,
604 XA23SRC_SetFrequencyRatio,
605 XA23SRC_GetFrequencyRatio,
608 #elif XAUDIO2_VER <= 7
610 static XA2SourceImpl *impl_from_IXAudio27SourceVoice(IXAudio27SourceVoice *iface)
612 return CONTAINING_RECORD(iface, XA2SourceImpl, IXAudio27SourceVoice_iface);
615 static void WINAPI XA27SRC_GetVoiceDetails(IXAudio27SourceVoice *iface,
616 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
618 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
619 return IXAudio2SourceVoice_GetVoiceDetails(&This->IXAudio2SourceVoice_iface, pVoiceDetails);
622 static HRESULT WINAPI XA27SRC_SetOutputVoices(IXAudio27SourceVoice *iface,
623 const XAUDIO2_VOICE_SENDS *pSendList)
625 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
626 return IXAudio2SourceVoice_SetOutputVoices(&This->IXAudio2SourceVoice_iface, pSendList);
629 static HRESULT WINAPI XA27SRC_SetEffectChain(IXAudio27SourceVoice *iface,
630 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
632 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
633 return IXAudio2SourceVoice_SetEffectChain(&This->IXAudio2SourceVoice_iface, pEffectChain);
636 static HRESULT WINAPI XA27SRC_EnableEffect(IXAudio27SourceVoice *iface,
637 UINT32 EffectIndex, UINT32 OperationSet)
639 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
640 return IXAudio2SourceVoice_EnableEffect(&This->IXAudio2SourceVoice_iface, EffectIndex, OperationSet);
643 static HRESULT WINAPI XA27SRC_DisableEffect(IXAudio27SourceVoice *iface,
644 UINT32 EffectIndex, UINT32 OperationSet)
646 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
647 return IXAudio2SourceVoice_DisableEffect(&This->IXAudio2SourceVoice_iface, EffectIndex, OperationSet);
650 static void WINAPI XA27SRC_GetEffectState(IXAudio27SourceVoice *iface,
651 UINT32 EffectIndex, BOOL *pEnabled)
653 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
654 IXAudio2SourceVoice_GetEffectState(&This->IXAudio2SourceVoice_iface, EffectIndex, pEnabled);
657 static HRESULT WINAPI XA27SRC_SetEffectParameters(IXAudio27SourceVoice *iface,
658 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
659 UINT32 OperationSet)
661 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
662 return IXAudio2SourceVoice_SetEffectParameters(&This->IXAudio2SourceVoice_iface,
663 EffectIndex, pParameters, ParametersByteSize, OperationSet);
666 static HRESULT WINAPI XA27SRC_GetEffectParameters(IXAudio27SourceVoice *iface,
667 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
669 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
670 return IXAudio2SourceVoice_GetEffectParameters(&This->IXAudio2SourceVoice_iface,
671 EffectIndex, pParameters, ParametersByteSize);
674 static HRESULT WINAPI XA27SRC_SetFilterParameters(IXAudio27SourceVoice *iface,
675 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
677 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
678 return IXAudio2SourceVoice_SetFilterParameters(&This->IXAudio2SourceVoice_iface,
679 pParameters, OperationSet);
682 static void WINAPI XA27SRC_GetFilterParameters(IXAudio27SourceVoice *iface,
683 XAUDIO2_FILTER_PARAMETERS *pParameters)
685 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
686 IXAudio2SourceVoice_GetFilterParameters(&This->IXAudio2SourceVoice_iface, pParameters);
689 static HRESULT WINAPI XA27SRC_SetOutputFilterParameters(IXAudio27SourceVoice *iface,
690 IXAudio2Voice *pDestinationVoice,
691 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
693 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
694 return IXAudio2SourceVoice_SetOutputFilterParameters(&This->IXAudio2SourceVoice_iface,
695 pDestinationVoice, pParameters, OperationSet);
698 static void WINAPI XA27SRC_GetOutputFilterParameters(IXAudio27SourceVoice *iface,
699 IXAudio2Voice *pDestinationVoice,
700 XAUDIO2_FILTER_PARAMETERS *pParameters)
702 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
703 IXAudio2SourceVoice_GetOutputFilterParameters(&This->IXAudio2SourceVoice_iface,
704 pDestinationVoice, pParameters);
707 static HRESULT WINAPI XA27SRC_SetVolume(IXAudio27SourceVoice *iface, float Volume,
708 UINT32 OperationSet)
710 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
711 return IXAudio2SourceVoice_SetVolume(&This->IXAudio2SourceVoice_iface, Volume,
712 OperationSet);
715 static void WINAPI XA27SRC_GetVolume(IXAudio27SourceVoice *iface, float *pVolume)
717 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
718 IXAudio2SourceVoice_GetVolume(&This->IXAudio2SourceVoice_iface, pVolume);
721 static HRESULT WINAPI XA27SRC_SetChannelVolumes(IXAudio27SourceVoice *iface,
722 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
724 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
725 return IXAudio2SourceVoice_SetChannelVolumes(&This->IXAudio2SourceVoice_iface, Channels,
726 pVolumes, OperationSet);
729 static void WINAPI XA27SRC_GetChannelVolumes(IXAudio27SourceVoice *iface,
730 UINT32 Channels, float *pVolumes)
732 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
733 IXAudio2SourceVoice_GetChannelVolumes(&This->IXAudio2SourceVoice_iface, Channels,
734 pVolumes);
737 static HRESULT WINAPI XA27SRC_SetOutputMatrix(IXAudio27SourceVoice *iface,
738 IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
739 UINT32 DestinationChannels, const float *pLevelMatrix,
740 UINT32 OperationSet)
742 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
743 return IXAudio2SourceVoice_SetOutputMatrix(&This->IXAudio2SourceVoice_iface,
744 pDestinationVoice, SourceChannels, DestinationChannels,
745 pLevelMatrix, OperationSet);
748 static void WINAPI XA27SRC_GetOutputMatrix(IXAudio27SourceVoice *iface,
749 IXAudio2Voice *pDestinationVoice, UINT32 SourceChannels,
750 UINT32 DestinationChannels, float *pLevelMatrix)
752 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
753 IXAudio2SourceVoice_GetOutputMatrix(&This->IXAudio2SourceVoice_iface, pDestinationVoice,
754 SourceChannels, DestinationChannels, pLevelMatrix);
757 static void WINAPI XA27SRC_DestroyVoice(IXAudio27SourceVoice *iface)
759 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
760 IXAudio2SourceVoice_DestroyVoice(&This->IXAudio2SourceVoice_iface);
763 static HRESULT WINAPI XA27SRC_Start(IXAudio27SourceVoice *iface, UINT32 Flags,
764 UINT32 OperationSet)
766 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
767 return IXAudio2SourceVoice_Start(&This->IXAudio2SourceVoice_iface, Flags, OperationSet);
770 static HRESULT WINAPI XA27SRC_Stop(IXAudio27SourceVoice *iface, UINT32 Flags,
771 UINT32 OperationSet)
773 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
774 return IXAudio2SourceVoice_Stop(&This->IXAudio2SourceVoice_iface, Flags, OperationSet);
777 static HRESULT WINAPI XA27SRC_SubmitSourceBuffer(IXAudio27SourceVoice *iface,
778 const XAUDIO2_BUFFER *pBuffer, const XAUDIO2_BUFFER_WMA *pBufferWMA)
780 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
781 return IXAudio2SourceVoice_SubmitSourceBuffer(&This->IXAudio2SourceVoice_iface, pBuffer,
782 pBufferWMA);
785 static HRESULT WINAPI XA27SRC_FlushSourceBuffers(IXAudio27SourceVoice *iface)
787 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
788 return IXAudio2SourceVoice_FlushSourceBuffers(&This->IXAudio2SourceVoice_iface);
791 static HRESULT WINAPI XA27SRC_Discontinuity(IXAudio27SourceVoice *iface)
793 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
794 return IXAudio2SourceVoice_Discontinuity(&This->IXAudio2SourceVoice_iface);
797 static HRESULT WINAPI XA27SRC_ExitLoop(IXAudio27SourceVoice *iface, UINT32 OperationSet)
799 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
800 return IXAudio2SourceVoice_ExitLoop(&This->IXAudio2SourceVoice_iface, OperationSet);
803 static void WINAPI XA27SRC_GetState(IXAudio27SourceVoice *iface,
804 XAUDIO2_VOICE_STATE *pVoiceState)
806 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
807 return IXAudio2SourceVoice_GetState(&This->IXAudio2SourceVoice_iface, pVoiceState, 0);
810 static HRESULT WINAPI XA27SRC_SetFrequencyRatio(IXAudio27SourceVoice *iface,
811 float Ratio, UINT32 OperationSet)
813 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
814 return IXAudio2SourceVoice_SetFrequencyRatio(&This->IXAudio2SourceVoice_iface, Ratio, OperationSet);
817 static void WINAPI XA27SRC_GetFrequencyRatio(IXAudio27SourceVoice *iface, float *pRatio)
819 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
820 return IXAudio2SourceVoice_GetFrequencyRatio(&This->IXAudio2SourceVoice_iface, pRatio);
823 static HRESULT WINAPI XA27SRC_SetSourceSampleRate(
824 IXAudio27SourceVoice *iface,
825 UINT32 NewSourceSampleRate)
827 XA2SourceImpl *This = impl_from_IXAudio27SourceVoice(iface);
828 return IXAudio2SourceVoice_SetSourceSampleRate(&This->IXAudio2SourceVoice_iface, NewSourceSampleRate);
831 const IXAudio27SourceVoiceVtbl XAudio27SourceVoice_Vtbl = {
832 XA27SRC_GetVoiceDetails,
833 XA27SRC_SetOutputVoices,
834 XA27SRC_SetEffectChain,
835 XA27SRC_EnableEffect,
836 XA27SRC_DisableEffect,
837 XA27SRC_GetEffectState,
838 XA27SRC_SetEffectParameters,
839 XA27SRC_GetEffectParameters,
840 XA27SRC_SetFilterParameters,
841 XA27SRC_GetFilterParameters,
842 XA27SRC_SetOutputFilterParameters,
843 XA27SRC_GetOutputFilterParameters,
844 XA27SRC_SetVolume,
845 XA27SRC_GetVolume,
846 XA27SRC_SetChannelVolumes,
847 XA27SRC_GetChannelVolumes,
848 XA27SRC_SetOutputMatrix,
849 XA27SRC_GetOutputMatrix,
850 XA27SRC_DestroyVoice,
851 XA27SRC_Start,
852 XA27SRC_Stop,
853 XA27SRC_SubmitSourceBuffer,
854 XA27SRC_FlushSourceBuffers,
855 XA27SRC_Discontinuity,
856 XA27SRC_ExitLoop,
857 XA27SRC_GetState,
858 XA27SRC_SetFrequencyRatio,
859 XA27SRC_GetFrequencyRatio,
860 XA27SRC_SetSourceSampleRate
862 #endif
863 /* END IXAudio2SourceVoice */
866 /* BEGIN IXAudio2SubmixVoice */
867 #if XAUDIO2_VER == 0
868 static XA2SubmixImpl *impl_from_IXAudio20SubmixVoice(IXAudio20SubmixVoice *iface)
870 return CONTAINING_RECORD(iface, XA2SubmixImpl, IXAudio20SubmixVoice_iface);
873 static void WINAPI XA20SUB_GetVoiceDetails(IXAudio20SubmixVoice *iface,
874 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
876 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
877 return IXAudio2SubmixVoice_GetVoiceDetails(&This->IXAudio2SubmixVoice_iface, pVoiceDetails);
880 static HRESULT WINAPI XA20SUB_SetOutputVoices(IXAudio20SubmixVoice *iface,
881 const XAUDIO23_VOICE_SENDS *pSendList)
883 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
884 XAUDIO2_VOICE_SENDS sends;
885 HRESULT hr;
886 DWORD i;
888 TRACE("%p, %p\n", This, pSendList);
890 sends.SendCount = pSendList->OutputCount;
891 sends.pSends = HeapAlloc(GetProcessHeap(), 0, sends.SendCount * sizeof(*sends.pSends));
892 for(i = 0; i < sends.SendCount; ++i){
893 sends.pSends[i].Flags = 0;
894 sends.pSends[i].pOutputVoice = pSendList->pOutputVoices[i];
897 hr = IXAudio2SubmixVoice_SetOutputVoices(&This->IXAudio2SubmixVoice_iface, &sends);
899 HeapFree(GetProcessHeap(), 0, sends.pSends);
901 return hr;
904 static HRESULT WINAPI XA20SUB_SetEffectChain(IXAudio20SubmixVoice *iface,
905 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
907 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
908 return IXAudio2SubmixVoice_SetEffectChain(&This->IXAudio2SubmixVoice_iface, pEffectChain);
911 static HRESULT WINAPI XA20SUB_EnableEffect(IXAudio20SubmixVoice *iface,
912 UINT32 EffectIndex, UINT32 OperationSet)
914 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
915 return IXAudio2SubmixVoice_EnableEffect(&This->IXAudio2SubmixVoice_iface,
916 EffectIndex, OperationSet);
919 static HRESULT WINAPI XA20SUB_DisableEffect(IXAudio20SubmixVoice *iface,
920 UINT32 EffectIndex, UINT32 OperationSet)
922 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
923 return IXAudio2SubmixVoice_DisableEffect(&This->IXAudio2SubmixVoice_iface,
924 EffectIndex, OperationSet);
927 static void WINAPI XA20SUB_GetEffectState(IXAudio20SubmixVoice *iface,
928 UINT32 EffectIndex, BOOL *pEnabled)
930 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
931 return IXAudio2SubmixVoice_GetEffectState(&This->IXAudio2SubmixVoice_iface,
932 EffectIndex, pEnabled);
935 static HRESULT WINAPI XA20SUB_SetEffectParameters(IXAudio20SubmixVoice *iface,
936 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
937 UINT32 OperationSet)
939 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
940 return IXAudio2SubmixVoice_SetEffectParameters(&This->IXAudio2SubmixVoice_iface,
941 EffectIndex, pParameters, ParametersByteSize, OperationSet);
944 static HRESULT WINAPI XA20SUB_GetEffectParameters(IXAudio20SubmixVoice *iface,
945 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
947 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
948 return IXAudio2SubmixVoice_GetEffectParameters(&This->IXAudio2SubmixVoice_iface,
949 EffectIndex, pParameters, ParametersByteSize);
952 static HRESULT WINAPI XA20SUB_SetFilterParameters(IXAudio20SubmixVoice *iface,
953 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
955 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
956 return IXAudio2SubmixVoice_SetFilterParameters(&This->IXAudio2SubmixVoice_iface,
957 pParameters, OperationSet);
960 static void WINAPI XA20SUB_GetFilterParameters(IXAudio20SubmixVoice *iface,
961 XAUDIO2_FILTER_PARAMETERS *pParameters)
963 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
964 return IXAudio2SubmixVoice_GetFilterParameters(&This->IXAudio2SubmixVoice_iface, pParameters);
967 static HRESULT WINAPI XA20SUB_SetVolume(IXAudio20SubmixVoice *iface,
968 float Volume, UINT32 OperationSet)
970 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
971 return IXAudio2SubmixVoice_SetVolume(&This->IXAudio2SubmixVoice_iface,
972 Volume, OperationSet);
975 static void WINAPI XA20SUB_GetVolume(IXAudio20SubmixVoice *iface,
976 float *pVolume)
978 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
979 return IXAudio2SubmixVoice_GetVolume(&This->IXAudio2SubmixVoice_iface, pVolume);
982 static HRESULT WINAPI XA20SUB_SetChannelVolumes(IXAudio20SubmixVoice *iface,
983 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
985 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
986 return IXAudio2SubmixVoice_SetChannelVolumes(&This->IXAudio2SubmixVoice_iface,
987 Channels, pVolumes, OperationSet);
990 static void WINAPI XA20SUB_GetChannelVolumes(IXAudio20SubmixVoice *iface,
991 UINT32 Channels, float *pVolumes)
993 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
994 return IXAudio2SubmixVoice_GetChannelVolumes(&This->IXAudio2SubmixVoice_iface,
995 Channels, pVolumes);
998 static HRESULT WINAPI XA20SUB_SetOutputMatrix(IXAudio20SubmixVoice *iface,
999 IXAudio2Voice *pDestinationVoice, UINT32 SubmixChannels,
1000 UINT32 DestinationChannels, const float *pLevelMatrix,
1001 UINT32 OperationSet)
1003 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
1004 return IXAudio2SubmixVoice_SetOutputMatrix(&This->IXAudio2SubmixVoice_iface,
1005 pDestinationVoice, SubmixChannels, DestinationChannels,
1006 pLevelMatrix, OperationSet);
1009 static HRESULT WINAPI XA20SUB_GetOutputMatrix(IXAudio20SubmixVoice *iface,
1010 IXAudio2Voice *pDestinationVoice, UINT32 SubmixChannels,
1011 UINT32 DestinationChannels, float *pLevelMatrix)
1013 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
1014 IXAudio2SubmixVoice_GetOutputMatrix(&This->IXAudio2SubmixVoice_iface,
1015 pDestinationVoice, SubmixChannels, DestinationChannels,
1016 pLevelMatrix);
1017 return S_OK;
1020 static void WINAPI XA20SUB_DestroyVoice(IXAudio20SubmixVoice *iface)
1022 XA2SubmixImpl *This = impl_from_IXAudio20SubmixVoice(iface);
1023 return IXAudio2SubmixVoice_DestroyVoice(&This->IXAudio2SubmixVoice_iface);
1026 const IXAudio20SubmixVoiceVtbl XAudio20SubmixVoice_Vtbl = {
1027 XA20SUB_GetVoiceDetails,
1028 XA20SUB_SetOutputVoices,
1029 XA20SUB_SetEffectChain,
1030 XA20SUB_EnableEffect,
1031 XA20SUB_DisableEffect,
1032 XA20SUB_GetEffectState,
1033 XA20SUB_SetEffectParameters,
1034 XA20SUB_GetEffectParameters,
1035 XA20SUB_SetFilterParameters,
1036 XA20SUB_GetFilterParameters,
1037 XA20SUB_SetVolume,
1038 XA20SUB_GetVolume,
1039 XA20SUB_SetChannelVolumes,
1040 XA20SUB_GetChannelVolumes,
1041 XA20SUB_SetOutputMatrix,
1042 XA20SUB_GetOutputMatrix,
1043 XA20SUB_DestroyVoice
1046 #elif XAUDIO2_VER <= 3
1048 static XA2SubmixImpl *impl_from_IXAudio23SubmixVoice(IXAudio23SubmixVoice *iface)
1050 return CONTAINING_RECORD(iface, XA2SubmixImpl, IXAudio23SubmixVoice_iface);
1053 static void WINAPI XA23SUB_GetVoiceDetails(IXAudio23SubmixVoice *iface,
1054 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
1056 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1057 return IXAudio2SubmixVoice_GetVoiceDetails(&This->IXAudio2SubmixVoice_iface, pVoiceDetails);
1060 static HRESULT WINAPI XA23SUB_SetOutputVoices(IXAudio23SubmixVoice *iface,
1061 const XAUDIO23_VOICE_SENDS *pSendList)
1063 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1064 XAUDIO2_VOICE_SENDS sends;
1065 HRESULT hr;
1066 DWORD i;
1068 TRACE("%p, %p\n", This, pSendList);
1070 sends.SendCount = pSendList->OutputCount;
1071 sends.pSends = HeapAlloc(GetProcessHeap(), 0, sends.SendCount * sizeof(*sends.pSends));
1072 for(i = 0; i < sends.SendCount; ++i){
1073 sends.pSends[i].Flags = 0;
1074 sends.pSends[i].pOutputVoice = pSendList->pOutputVoices[i];
1077 hr = IXAudio2SubmixVoice_SetOutputVoices(&This->IXAudio2SubmixVoice_iface, &sends);
1079 HeapFree(GetProcessHeap(), 0, sends.pSends);
1081 return hr;
1084 static HRESULT WINAPI XA23SUB_SetEffectChain(IXAudio23SubmixVoice *iface,
1085 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1087 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1088 return IXAudio2SubmixVoice_SetEffectChain(&This->IXAudio2SubmixVoice_iface, pEffectChain);
1091 static HRESULT WINAPI XA23SUB_EnableEffect(IXAudio23SubmixVoice *iface,
1092 UINT32 EffectIndex, UINT32 OperationSet)
1094 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1095 return IXAudio2SubmixVoice_EnableEffect(&This->IXAudio2SubmixVoice_iface,
1096 EffectIndex, OperationSet);
1099 static HRESULT WINAPI XA23SUB_DisableEffect(IXAudio23SubmixVoice *iface,
1100 UINT32 EffectIndex, UINT32 OperationSet)
1102 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1103 return IXAudio2SubmixVoice_DisableEffect(&This->IXAudio2SubmixVoice_iface,
1104 EffectIndex, OperationSet);
1107 static void WINAPI XA23SUB_GetEffectState(IXAudio23SubmixVoice *iface,
1108 UINT32 EffectIndex, BOOL *pEnabled)
1110 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1111 return IXAudio2SubmixVoice_GetEffectState(&This->IXAudio2SubmixVoice_iface,
1112 EffectIndex, pEnabled);
1115 static HRESULT WINAPI XA23SUB_SetEffectParameters(IXAudio23SubmixVoice *iface,
1116 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
1117 UINT32 OperationSet)
1119 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1120 return IXAudio2SubmixVoice_SetEffectParameters(&This->IXAudio2SubmixVoice_iface,
1121 EffectIndex, pParameters, ParametersByteSize, OperationSet);
1124 static HRESULT WINAPI XA23SUB_GetEffectParameters(IXAudio23SubmixVoice *iface,
1125 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
1127 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1128 return IXAudio2SubmixVoice_GetEffectParameters(&This->IXAudio2SubmixVoice_iface,
1129 EffectIndex, pParameters, ParametersByteSize);
1132 static HRESULT WINAPI XA23SUB_SetFilterParameters(IXAudio23SubmixVoice *iface,
1133 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
1135 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1136 return IXAudio2SubmixVoice_SetFilterParameters(&This->IXAudio2SubmixVoice_iface,
1137 pParameters, OperationSet);
1140 static void WINAPI XA23SUB_GetFilterParameters(IXAudio23SubmixVoice *iface,
1141 XAUDIO2_FILTER_PARAMETERS *pParameters)
1143 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1144 return IXAudio2SubmixVoice_GetFilterParameters(&This->IXAudio2SubmixVoice_iface, pParameters);
1147 static HRESULT WINAPI XA23SUB_SetVolume(IXAudio23SubmixVoice *iface,
1148 float Volume, UINT32 OperationSet)
1150 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1151 return IXAudio2SubmixVoice_SetVolume(&This->IXAudio2SubmixVoice_iface,
1152 Volume, OperationSet);
1155 static void WINAPI XA23SUB_GetVolume(IXAudio23SubmixVoice *iface,
1156 float *pVolume)
1158 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1159 return IXAudio2SubmixVoice_GetVolume(&This->IXAudio2SubmixVoice_iface, pVolume);
1162 static HRESULT WINAPI XA23SUB_SetChannelVolumes(IXAudio23SubmixVoice *iface,
1163 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
1165 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1166 return IXAudio2SubmixVoice_SetChannelVolumes(&This->IXAudio2SubmixVoice_iface,
1167 Channels, pVolumes, OperationSet);
1170 static void WINAPI XA23SUB_GetChannelVolumes(IXAudio23SubmixVoice *iface,
1171 UINT32 Channels, float *pVolumes)
1173 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1174 return IXAudio2SubmixVoice_GetChannelVolumes(&This->IXAudio2SubmixVoice_iface,
1175 Channels, pVolumes);
1178 static HRESULT WINAPI XA23SUB_SetOutputMatrix(IXAudio23SubmixVoice *iface,
1179 IXAudio2Voice *pDestinationVoice, UINT32 SubmixChannels,
1180 UINT32 DestinationChannels, const float *pLevelMatrix,
1181 UINT32 OperationSet)
1183 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1184 return IXAudio2SubmixVoice_SetOutputMatrix(&This->IXAudio2SubmixVoice_iface,
1185 pDestinationVoice, SubmixChannels, DestinationChannels,
1186 pLevelMatrix, OperationSet);
1189 static void WINAPI XA23SUB_GetOutputMatrix(IXAudio23SubmixVoice *iface,
1190 IXAudio2Voice *pDestinationVoice, UINT32 SubmixChannels,
1191 UINT32 DestinationChannels, float *pLevelMatrix)
1193 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1194 return IXAudio2SubmixVoice_GetOutputMatrix(&This->IXAudio2SubmixVoice_iface,
1195 pDestinationVoice, SubmixChannels, DestinationChannels,
1196 pLevelMatrix);
1199 static void WINAPI XA23SUB_DestroyVoice(IXAudio23SubmixVoice *iface)
1201 XA2SubmixImpl *This = impl_from_IXAudio23SubmixVoice(iface);
1202 return IXAudio2SubmixVoice_DestroyVoice(&This->IXAudio2SubmixVoice_iface);
1205 const IXAudio23SubmixVoiceVtbl XAudio23SubmixVoice_Vtbl = {
1206 XA23SUB_GetVoiceDetails,
1207 XA23SUB_SetOutputVoices,
1208 XA23SUB_SetEffectChain,
1209 XA23SUB_EnableEffect,
1210 XA23SUB_DisableEffect,
1211 XA23SUB_GetEffectState,
1212 XA23SUB_SetEffectParameters,
1213 XA23SUB_GetEffectParameters,
1214 XA23SUB_SetFilterParameters,
1215 XA23SUB_GetFilterParameters,
1216 XA23SUB_SetVolume,
1217 XA23SUB_GetVolume,
1218 XA23SUB_SetChannelVolumes,
1219 XA23SUB_GetChannelVolumes,
1220 XA23SUB_SetOutputMatrix,
1221 XA23SUB_GetOutputMatrix,
1222 XA23SUB_DestroyVoice
1224 #endif
1225 /* END IXAudio2SubmixVoice */
1228 /* BEGIN IXAudio2MasteringVoice */
1229 #if XAUDIO2_VER == 0
1230 static IXAudio2Impl *impl_from_IXAudio20MasteringVoice(IXAudio20MasteringVoice *iface)
1232 return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio20MasteringVoice_iface);
1235 static void WINAPI XA20M_GetVoiceDetails(IXAudio20MasteringVoice *iface,
1236 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
1238 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1239 return IXAudio2MasteringVoice_GetVoiceDetails(&This->IXAudio2MasteringVoice_iface, pVoiceDetails);
1242 static HRESULT WINAPI XA20M_SetOutputVoices(IXAudio20MasteringVoice *iface,
1243 const XAUDIO23_VOICE_SENDS *pSendList)
1245 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1246 XAUDIO2_VOICE_SENDS sends;
1247 HRESULT hr;
1248 DWORD i;
1250 TRACE("%p, %p\n", This, pSendList);
1252 sends.SendCount = pSendList->OutputCount;
1253 sends.pSends = HeapAlloc(GetProcessHeap(), 0, sends.SendCount * sizeof(*sends.pSends));
1254 for(i = 0; i < sends.SendCount; ++i){
1255 sends.pSends[i].Flags = 0;
1256 sends.pSends[i].pOutputVoice = pSendList->pOutputVoices[i];
1259 hr = IXAudio2MasteringVoice_SetOutputVoices(&This->IXAudio2MasteringVoice_iface, &sends);
1261 HeapFree(GetProcessHeap(), 0, sends.pSends);
1263 return hr;
1266 static HRESULT WINAPI XA20M_SetEffectChain(IXAudio20MasteringVoice *iface,
1267 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1269 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1270 return IXAudio2MasteringVoice_SetEffectChain(&This->IXAudio2MasteringVoice_iface, pEffectChain);
1273 static HRESULT WINAPI XA20M_EnableEffect(IXAudio20MasteringVoice *iface,
1274 UINT32 EffectIndex, UINT32 OperationSet)
1276 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1277 return IXAudio2MasteringVoice_EnableEffect(&This->IXAudio2MasteringVoice_iface,
1278 EffectIndex, OperationSet);
1281 static HRESULT WINAPI XA20M_DisableEffect(IXAudio20MasteringVoice *iface,
1282 UINT32 EffectIndex, UINT32 OperationSet)
1284 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1285 return IXAudio2MasteringVoice_DisableEffect(&This->IXAudio2MasteringVoice_iface,
1286 EffectIndex, OperationSet);
1289 static void WINAPI XA20M_GetEffectState(IXAudio20MasteringVoice *iface,
1290 UINT32 EffectIndex, BOOL *pEnabled)
1292 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1293 return IXAudio2MasteringVoice_GetEffectState(&This->IXAudio2MasteringVoice_iface,
1294 EffectIndex, pEnabled);
1297 static HRESULT WINAPI XA20M_SetEffectParameters(IXAudio20MasteringVoice *iface,
1298 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
1299 UINT32 OperationSet)
1301 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1302 return IXAudio2MasteringVoice_SetEffectParameters(&This->IXAudio2MasteringVoice_iface,
1303 EffectIndex, pParameters, ParametersByteSize, OperationSet);
1306 static HRESULT WINAPI XA20M_GetEffectParameters(IXAudio20MasteringVoice *iface,
1307 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
1309 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1310 return IXAudio2MasteringVoice_GetEffectParameters(&This->IXAudio2MasteringVoice_iface,
1311 EffectIndex, pParameters, ParametersByteSize);
1314 static HRESULT WINAPI XA20M_SetFilterParameters(IXAudio20MasteringVoice *iface,
1315 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
1317 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1318 return IXAudio2MasteringVoice_SetFilterParameters(&This->IXAudio2MasteringVoice_iface,
1319 pParameters, OperationSet);
1322 static void WINAPI XA20M_GetFilterParameters(IXAudio20MasteringVoice *iface,
1323 XAUDIO2_FILTER_PARAMETERS *pParameters)
1325 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1326 return IXAudio2MasteringVoice_GetFilterParameters(&This->IXAudio2MasteringVoice_iface, pParameters);
1329 static HRESULT WINAPI XA20M_SetVolume(IXAudio20MasteringVoice *iface,
1330 float Volume, UINT32 OperationSet)
1332 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1333 return IXAudio2MasteringVoice_SetVolume(&This->IXAudio2MasteringVoice_iface,
1334 Volume, OperationSet);
1337 static void WINAPI XA20M_GetVolume(IXAudio20MasteringVoice *iface,
1338 float *pVolume)
1340 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1341 return IXAudio2MasteringVoice_GetVolume(&This->IXAudio2MasteringVoice_iface, pVolume);
1344 static HRESULT WINAPI XA20M_SetChannelVolumes(IXAudio20MasteringVoice *iface,
1345 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
1347 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1348 return IXAudio2MasteringVoice_SetChannelVolumes(&This->IXAudio2MasteringVoice_iface,
1349 Channels, pVolumes, OperationSet);
1352 static void WINAPI XA20M_GetChannelVolumes(IXAudio20MasteringVoice *iface,
1353 UINT32 Channels, float *pVolumes)
1355 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1356 return IXAudio2MasteringVoice_GetChannelVolumes(&This->IXAudio2MasteringVoice_iface,
1357 Channels, pVolumes);
1360 static HRESULT WINAPI XA20M_SetOutputMatrix(IXAudio20MasteringVoice *iface,
1361 IXAudio2Voice *pDestinationVoice, UINT32 MasteringChannels,
1362 UINT32 DestinationChannels, const float *pLevelMatrix,
1363 UINT32 OperationSet)
1365 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1366 return IXAudio2MasteringVoice_SetOutputMatrix(&This->IXAudio2MasteringVoice_iface,
1367 pDestinationVoice, MasteringChannels, DestinationChannels,
1368 pLevelMatrix, OperationSet);
1371 static HRESULT WINAPI XA20M_GetOutputMatrix(IXAudio20MasteringVoice *iface,
1372 IXAudio2Voice *pDestinationVoice, UINT32 MasteringChannels,
1373 UINT32 DestinationChannels, float *pLevelMatrix)
1375 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1376 IXAudio2MasteringVoice_GetOutputMatrix(&This->IXAudio2MasteringVoice_iface,
1377 pDestinationVoice, MasteringChannels, DestinationChannels,
1378 pLevelMatrix);
1379 return S_OK;
1382 static void WINAPI XA20M_DestroyVoice(IXAudio20MasteringVoice *iface)
1384 IXAudio2Impl *This = impl_from_IXAudio20MasteringVoice(iface);
1385 return IXAudio2MasteringVoice_DestroyVoice(&This->IXAudio2MasteringVoice_iface);
1388 const IXAudio20MasteringVoiceVtbl XAudio20MasteringVoice_Vtbl = {
1389 XA20M_GetVoiceDetails,
1390 XA20M_SetOutputVoices,
1391 XA20M_SetEffectChain,
1392 XA20M_EnableEffect,
1393 XA20M_DisableEffect,
1394 XA20M_GetEffectState,
1395 XA20M_SetEffectParameters,
1396 XA20M_GetEffectParameters,
1397 XA20M_SetFilterParameters,
1398 XA20M_GetFilterParameters,
1399 XA20M_SetVolume,
1400 XA20M_GetVolume,
1401 XA20M_SetChannelVolumes,
1402 XA20M_GetChannelVolumes,
1403 XA20M_SetOutputMatrix,
1404 XA20M_GetOutputMatrix,
1405 XA20M_DestroyVoice
1408 #elif XAUDIO2_VER <= 3
1410 static IXAudio2Impl *impl_from_IXAudio23MasteringVoice(IXAudio23MasteringVoice *iface)
1412 return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio23MasteringVoice_iface);
1415 static void WINAPI XA23M_GetVoiceDetails(IXAudio23MasteringVoice *iface,
1416 XAUDIO2_VOICE_DETAILS *pVoiceDetails)
1418 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1419 return IXAudio2MasteringVoice_GetVoiceDetails(&This->IXAudio2MasteringVoice_iface, pVoiceDetails);
1422 static HRESULT WINAPI XA23M_SetOutputVoices(IXAudio23MasteringVoice *iface,
1423 const XAUDIO23_VOICE_SENDS *pSendList)
1425 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1426 XAUDIO2_VOICE_SENDS sends;
1427 HRESULT hr;
1428 DWORD i;
1430 TRACE("%p, %p\n", This, pSendList);
1432 sends.SendCount = pSendList->OutputCount;
1433 sends.pSends = HeapAlloc(GetProcessHeap(), 0, sends.SendCount * sizeof(*sends.pSends));
1434 for(i = 0; i < sends.SendCount; ++i){
1435 sends.pSends[i].Flags = 0;
1436 sends.pSends[i].pOutputVoice = pSendList->pOutputVoices[i];
1439 hr = IXAudio2MasteringVoice_SetOutputVoices(&This->IXAudio2MasteringVoice_iface, &sends);
1441 HeapFree(GetProcessHeap(), 0, sends.pSends);
1443 return hr;
1446 static HRESULT WINAPI XA23M_SetEffectChain(IXAudio23MasteringVoice *iface,
1447 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1449 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1450 return IXAudio2MasteringVoice_SetEffectChain(&This->IXAudio2MasteringVoice_iface, pEffectChain);
1453 static HRESULT WINAPI XA23M_EnableEffect(IXAudio23MasteringVoice *iface,
1454 UINT32 EffectIndex, UINT32 OperationSet)
1456 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1457 return IXAudio2MasteringVoice_EnableEffect(&This->IXAudio2MasteringVoice_iface,
1458 EffectIndex, OperationSet);
1461 static HRESULT WINAPI XA23M_DisableEffect(IXAudio23MasteringVoice *iface,
1462 UINT32 EffectIndex, UINT32 OperationSet)
1464 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1465 return IXAudio2MasteringVoice_DisableEffect(&This->IXAudio2MasteringVoice_iface,
1466 EffectIndex, OperationSet);
1469 static void WINAPI XA23M_GetEffectState(IXAudio23MasteringVoice *iface,
1470 UINT32 EffectIndex, BOOL *pEnabled)
1472 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1473 return IXAudio2MasteringVoice_GetEffectState(&This->IXAudio2MasteringVoice_iface,
1474 EffectIndex, pEnabled);
1477 static HRESULT WINAPI XA23M_SetEffectParameters(IXAudio23MasteringVoice *iface,
1478 UINT32 EffectIndex, const void *pParameters, UINT32 ParametersByteSize,
1479 UINT32 OperationSet)
1481 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1482 return IXAudio2MasteringVoice_SetEffectParameters(&This->IXAudio2MasteringVoice_iface,
1483 EffectIndex, pParameters, ParametersByteSize, OperationSet);
1486 static HRESULT WINAPI XA23M_GetEffectParameters(IXAudio23MasteringVoice *iface,
1487 UINT32 EffectIndex, void *pParameters, UINT32 ParametersByteSize)
1489 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1490 return IXAudio2MasteringVoice_GetEffectParameters(&This->IXAudio2MasteringVoice_iface,
1491 EffectIndex, pParameters, ParametersByteSize);
1494 static HRESULT WINAPI XA23M_SetFilterParameters(IXAudio23MasteringVoice *iface,
1495 const XAUDIO2_FILTER_PARAMETERS *pParameters, UINT32 OperationSet)
1497 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1498 return IXAudio2MasteringVoice_SetFilterParameters(&This->IXAudio2MasteringVoice_iface,
1499 pParameters, OperationSet);
1502 static void WINAPI XA23M_GetFilterParameters(IXAudio23MasteringVoice *iface,
1503 XAUDIO2_FILTER_PARAMETERS *pParameters)
1505 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1506 return IXAudio2MasteringVoice_GetFilterParameters(&This->IXAudio2MasteringVoice_iface, pParameters);
1509 static HRESULT WINAPI XA23M_SetVolume(IXAudio23MasteringVoice *iface,
1510 float Volume, UINT32 OperationSet)
1512 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1513 return IXAudio2MasteringVoice_SetVolume(&This->IXAudio2MasteringVoice_iface,
1514 Volume, OperationSet);
1517 static void WINAPI XA23M_GetVolume(IXAudio23MasteringVoice *iface,
1518 float *pVolume)
1520 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1521 return IXAudio2MasteringVoice_GetVolume(&This->IXAudio2MasteringVoice_iface, pVolume);
1524 static HRESULT WINAPI XA23M_SetChannelVolumes(IXAudio23MasteringVoice *iface,
1525 UINT32 Channels, const float *pVolumes, UINT32 OperationSet)
1527 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1528 return IXAudio2MasteringVoice_SetChannelVolumes(&This->IXAudio2MasteringVoice_iface,
1529 Channels, pVolumes, OperationSet);
1532 static void WINAPI XA23M_GetChannelVolumes(IXAudio23MasteringVoice *iface,
1533 UINT32 Channels, float *pVolumes)
1535 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1536 return IXAudio2MasteringVoice_GetChannelVolumes(&This->IXAudio2MasteringVoice_iface,
1537 Channels, pVolumes);
1540 static HRESULT WINAPI XA23M_SetOutputMatrix(IXAudio23MasteringVoice *iface,
1541 IXAudio2Voice *pDestinationVoice, UINT32 MasteringChannels,
1542 UINT32 DestinationChannels, const float *pLevelMatrix,
1543 UINT32 OperationSet)
1545 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1546 return IXAudio2MasteringVoice_SetOutputMatrix(&This->IXAudio2MasteringVoice_iface,
1547 pDestinationVoice, MasteringChannels, DestinationChannels,
1548 pLevelMatrix, OperationSet);
1551 static void WINAPI XA23M_GetOutputMatrix(IXAudio23MasteringVoice *iface,
1552 IXAudio2Voice *pDestinationVoice, UINT32 MasteringChannels,
1553 UINT32 DestinationChannels, float *pLevelMatrix)
1555 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1556 return IXAudio2MasteringVoice_GetOutputMatrix(&This->IXAudio2MasteringVoice_iface,
1557 pDestinationVoice, MasteringChannels, DestinationChannels,
1558 pLevelMatrix);
1561 static void WINAPI XA23M_DestroyVoice(IXAudio23MasteringVoice *iface)
1563 IXAudio2Impl *This = impl_from_IXAudio23MasteringVoice(iface);
1564 return IXAudio2MasteringVoice_DestroyVoice(&This->IXAudio2MasteringVoice_iface);
1567 const IXAudio23MasteringVoiceVtbl XAudio23MasteringVoice_Vtbl = {
1568 XA23M_GetVoiceDetails,
1569 XA23M_SetOutputVoices,
1570 XA23M_SetEffectChain,
1571 XA23M_EnableEffect,
1572 XA23M_DisableEffect,
1573 XA23M_GetEffectState,
1574 XA23M_SetEffectParameters,
1575 XA23M_GetEffectParameters,
1576 XA23M_SetFilterParameters,
1577 XA23M_GetFilterParameters,
1578 XA23M_SetVolume,
1579 XA23M_GetVolume,
1580 XA23M_SetChannelVolumes,
1581 XA23M_GetChannelVolumes,
1582 XA23M_SetOutputMatrix,
1583 XA23M_GetOutputMatrix,
1584 XA23M_DestroyVoice
1586 #endif
1587 /* END IXAudio2MasteringVoice */
1590 /* BEGIN IXAudio2 */
1591 #if XAUDIO2_VER == 0
1592 static inline IXAudio2Impl *impl_from_IXAudio20(IXAudio20 *iface)
1594 return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio20_iface);
1597 static HRESULT WINAPI XA20_QueryInterface(IXAudio20 *iface, REFIID riid,
1598 void **ppvObject)
1600 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1601 return IXAudio2_QueryInterface(&This->IXAudio2_iface, riid, ppvObject);
1604 static ULONG WINAPI XA20_AddRef(IXAudio20 *iface)
1606 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1607 return IXAudio2_AddRef(&This->IXAudio2_iface);
1610 static ULONG WINAPI XA20_Release(IXAudio20 *iface)
1612 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1613 return IXAudio2_Release(&This->IXAudio2_iface);
1616 static HRESULT WINAPI XA20_GetDeviceCount(IXAudio20 *iface, UINT32 *pCount)
1618 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1620 TRACE("%p, %p\n", This, pCount);
1622 *pCount = This->ndevs;
1624 return S_OK;
1627 static HRESULT WINAPI XA20_GetDeviceDetails(IXAudio20 *iface, UINT32 index,
1628 XAUDIO2_DEVICE_DETAILS *pDeviceDetails)
1630 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1631 HRESULT hr;
1632 IMMDevice *dev;
1633 IAudioClient *client;
1634 IPropertyStore *ps;
1635 WAVEFORMATEX *wfx;
1636 PROPVARIANT var;
1638 TRACE("%p, %u, %p\n", This, index, pDeviceDetails);
1640 if(index >= This->ndevs)
1641 return E_INVALIDARG;
1643 hr = IMMDeviceEnumerator_GetDevice(This->devenum, This->devids[index], &dev);
1644 if(FAILED(hr)){
1645 WARN("GetDevice failed: %08x\n", hr);
1646 return hr;
1649 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1650 NULL, (void**)&client);
1651 if(FAILED(hr)){
1652 WARN("Activate failed: %08x\n", hr);
1653 IMMDevice_Release(dev);
1654 return hr;
1657 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &ps);
1658 if(FAILED(hr)){
1659 WARN("OpenPropertyStore failed: %08x\n", hr);
1660 IAudioClient_Release(client);
1661 IMMDevice_Release(dev);
1662 return hr;
1665 PropVariantInit(&var);
1667 hr = IPropertyStore_GetValue(ps, (PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &var);
1668 if(FAILED(hr)){
1669 WARN("GetValue failed: %08x\n", hr);
1670 goto done;
1673 lstrcpynW(pDeviceDetails->DisplayName, var.u.pwszVal, sizeof(pDeviceDetails->DisplayName)/sizeof(WCHAR));
1675 PropVariantClear(&var);
1677 hr = IAudioClient_GetMixFormat(client, &wfx);
1678 if(FAILED(hr)){
1679 WARN("GetMixFormat failed: %08x\n", hr);
1680 goto done;
1683 lstrcpyW(pDeviceDetails->DeviceID, This->devids[index]);
1685 if(index == 0)
1686 pDeviceDetails->Role = GlobalDefaultDevice;
1687 else
1688 pDeviceDetails->Role = NotDefaultDevice;
1690 if(sizeof(WAVEFORMATEX) + wfx->cbSize > sizeof(pDeviceDetails->OutputFormat)){
1691 FIXME("AudioClient format is too large to fit into WAVEFORMATEXTENSIBLE!\n");
1692 CoTaskMemFree(wfx);
1693 hr = E_FAIL;
1694 goto done;
1696 memcpy(&pDeviceDetails->OutputFormat, wfx, sizeof(WAVEFORMATEX) + wfx->cbSize);
1698 CoTaskMemFree(wfx);
1700 done:
1701 IPropertyStore_Release(ps);
1702 IAudioClient_Release(client);
1703 IMMDevice_Release(dev);
1705 return hr;
1708 static HRESULT WINAPI XA20_Initialize(IXAudio20 *iface, UINT32 flags,
1709 XAUDIO2_PROCESSOR processor)
1711 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1712 TRACE("(%p)->(0x%x, 0x%x)\n", This, flags, processor);
1713 return xaudio2_initialize(This, flags, processor);
1716 static HRESULT WINAPI XA20_RegisterForCallbacks(IXAudio20 *iface,
1717 IXAudio2EngineCallback *pCallback)
1719 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1720 return IXAudio2_RegisterForCallbacks(&This->IXAudio2_iface, pCallback);
1723 static void WINAPI XA20_UnregisterForCallbacks(IXAudio20 *iface,
1724 IXAudio2EngineCallback *pCallback)
1726 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1727 return IXAudio2_UnregisterForCallbacks(&This->IXAudio2_iface, pCallback);
1730 static HRESULT WINAPI XA20_CreateSourceVoice(IXAudio20 *iface,
1731 IXAudio2SourceVoice **ppSourceVoice, const WAVEFORMATEX *pSourceFormat,
1732 UINT32 flags, float maxFrequencyRatio,
1733 IXAudio2VoiceCallback *pCallback, const XAUDIO2_VOICE_SENDS *pSendList,
1734 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1736 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1737 return IXAudio2_CreateSourceVoice(&This->IXAudio2_iface, ppSourceVoice,
1738 pSourceFormat, flags, maxFrequencyRatio, pCallback, pSendList,
1739 pEffectChain);
1742 static HRESULT WINAPI XA20_CreateSubmixVoice(IXAudio20 *iface,
1743 IXAudio2SubmixVoice **ppSubmixVoice, UINT32 inputChannels,
1744 UINT32 inputSampleRate, UINT32 flags, UINT32 processingStage,
1745 const XAUDIO2_VOICE_SENDS *pSendList,
1746 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1748 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1749 return IXAudio2_CreateSubmixVoice(&This->IXAudio2_iface, ppSubmixVoice,
1750 inputChannels, inputSampleRate, flags, processingStage, pSendList,
1751 pEffectChain);
1754 static HRESULT WINAPI XA20_CreateMasteringVoice(IXAudio20 *iface,
1755 IXAudio2MasteringVoice **ppMasteringVoice, UINT32 inputChannels,
1756 UINT32 inputSampleRate, UINT32 flags, UINT32 deviceIndex,
1757 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1759 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1761 TRACE("(%p)->(%p, %u, %u, 0x%x, %u, %p)\n", This, ppMasteringVoice,
1762 inputChannels, inputSampleRate, flags, deviceIndex,
1763 pEffectChain);
1765 if(deviceIndex >= This->ndevs)
1766 return E_INVALIDARG;
1768 return IXAudio2_CreateMasteringVoice(&This->IXAudio2_iface, ppMasteringVoice,
1769 inputChannels, inputSampleRate, flags, This->devids[deviceIndex],
1770 pEffectChain, AudioCategory_GameEffects);
1773 static HRESULT WINAPI XA20_StartEngine(IXAudio20 *iface)
1775 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1776 return IXAudio2_StartEngine(&This->IXAudio2_iface);
1779 static void WINAPI XA20_StopEngine(IXAudio20 *iface)
1781 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1782 return IXAudio2_StopEngine(&This->IXAudio2_iface);
1785 static HRESULT WINAPI XA20_CommitChanges(IXAudio20 *iface, UINT32 operationSet)
1787 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1788 return IXAudio2_CommitChanges(&This->IXAudio2_iface, operationSet);
1791 static void WINAPI XA20_GetPerformanceData(IXAudio20 *iface,
1792 XAUDIO20_PERFORMANCE_DATA *pPerfData)
1794 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1795 XAUDIO2_PERFORMANCE_DATA data;
1797 IXAudio2_GetPerformanceData(&This->IXAudio2_iface, &data);
1799 pPerfData->AudioCyclesSinceLastQuery = data.AudioCyclesSinceLastQuery;
1800 pPerfData->TotalCyclesSinceLastQuery = data.TotalCyclesSinceLastQuery;
1801 pPerfData->MinimumCyclesPerQuantum = data.MinimumCyclesPerQuantum;
1802 pPerfData->MaximumCyclesPerQuantum = data.MaximumCyclesPerQuantum;
1803 pPerfData->MemoryUsageInBytes = data.MemoryUsageInBytes;
1804 pPerfData->CurrentLatencyInSamples = data.CurrentLatencyInSamples;
1805 pPerfData->GlitchesSinceLastQuery = data.GlitchesSinceEngineStarted - This->last_query_glitches;
1806 This->last_query_glitches = data.GlitchesSinceEngineStarted;
1807 pPerfData->ActiveSourceVoiceCount = data.ActiveSourceVoiceCount;
1808 pPerfData->TotalSourceVoiceCount = data.TotalSourceVoiceCount;
1810 pPerfData->ActiveSubmixVoiceCount = data.ActiveSubmixVoiceCount;
1811 pPerfData->TotalSubmixVoiceCount = data.ActiveSubmixVoiceCount;
1813 pPerfData->ActiveXmaSourceVoices = data.ActiveXmaSourceVoices;
1814 pPerfData->ActiveXmaStreams = data.ActiveXmaStreams;
1817 static void WINAPI XA20_SetDebugConfiguration(IXAudio20 *iface,
1818 const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
1819 void *pReserved)
1821 IXAudio2Impl *This = impl_from_IXAudio20(iface);
1822 return IXAudio2_SetDebugConfiguration(&This->IXAudio2_iface,
1823 pDebugConfiguration, pReserved);
1826 const IXAudio20Vtbl XAudio20_Vtbl = {
1827 XA20_QueryInterface,
1828 XA20_AddRef,
1829 XA20_Release,
1830 XA20_GetDeviceCount,
1831 XA20_GetDeviceDetails,
1832 XA20_Initialize,
1833 XA20_RegisterForCallbacks,
1834 XA20_UnregisterForCallbacks,
1835 XA20_CreateSourceVoice,
1836 XA20_CreateSubmixVoice,
1837 XA20_CreateMasteringVoice,
1838 XA20_StartEngine,
1839 XA20_StopEngine,
1840 XA20_CommitChanges,
1841 XA20_GetPerformanceData,
1842 XA20_SetDebugConfiguration
1845 #elif XAUDIO2_VER <= 2
1847 static inline IXAudio2Impl *impl_from_IXAudio22(IXAudio22 *iface)
1849 return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio22_iface);
1852 static HRESULT WINAPI XA22_QueryInterface(IXAudio22 *iface, REFIID riid,
1853 void **ppvObject)
1855 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1856 return IXAudio2_QueryInterface(&This->IXAudio2_iface, riid, ppvObject);
1859 static ULONG WINAPI XA22_AddRef(IXAudio22 *iface)
1861 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1862 return IXAudio2_AddRef(&This->IXAudio2_iface);
1865 static ULONG WINAPI XA22_Release(IXAudio22 *iface)
1867 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1868 return IXAudio2_Release(&This->IXAudio2_iface);
1871 static HRESULT WINAPI XA22_GetDeviceCount(IXAudio22 *iface, UINT32 *pCount)
1873 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1875 TRACE("%p, %p\n", This, pCount);
1877 *pCount = This->ndevs;
1879 return S_OK;
1882 static HRESULT WINAPI XA22_GetDeviceDetails(IXAudio22 *iface, UINT32 index,
1883 XAUDIO2_DEVICE_DETAILS *pDeviceDetails)
1885 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1886 HRESULT hr;
1887 IMMDevice *dev;
1888 IAudioClient *client;
1889 IPropertyStore *ps;
1890 WAVEFORMATEX *wfx;
1891 PROPVARIANT var;
1893 TRACE("%p, %u, %p\n", This, index, pDeviceDetails);
1895 if(index >= This->ndevs)
1896 return E_INVALIDARG;
1898 hr = IMMDeviceEnumerator_GetDevice(This->devenum, This->devids[index], &dev);
1899 if(FAILED(hr)){
1900 WARN("GetDevice failed: %08x\n", hr);
1901 return hr;
1904 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
1905 NULL, (void**)&client);
1906 if(FAILED(hr)){
1907 WARN("Activate failed: %08x\n", hr);
1908 IMMDevice_Release(dev);
1909 return hr;
1912 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &ps);
1913 if(FAILED(hr)){
1914 WARN("OpenPropertyStore failed: %08x\n", hr);
1915 IAudioClient_Release(client);
1916 IMMDevice_Release(dev);
1917 return hr;
1920 PropVariantInit(&var);
1922 hr = IPropertyStore_GetValue(ps, (PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &var);
1923 if(FAILED(hr)){
1924 WARN("GetValue failed: %08x\n", hr);
1925 goto done;
1928 lstrcpynW(pDeviceDetails->DisplayName, var.u.pwszVal, sizeof(pDeviceDetails->DisplayName)/sizeof(WCHAR));
1930 PropVariantClear(&var);
1932 hr = IAudioClient_GetMixFormat(client, &wfx);
1933 if(FAILED(hr)){
1934 WARN("GetMixFormat failed: %08x\n", hr);
1935 goto done;
1938 lstrcpyW(pDeviceDetails->DeviceID, This->devids[index]);
1940 if(index == 0)
1941 pDeviceDetails->Role = GlobalDefaultDevice;
1942 else
1943 pDeviceDetails->Role = NotDefaultDevice;
1945 if(sizeof(WAVEFORMATEX) + wfx->cbSize > sizeof(pDeviceDetails->OutputFormat)){
1946 FIXME("AudioClient format is too large to fit into WAVEFORMATEXTENSIBLE!\n");
1947 CoTaskMemFree(wfx);
1948 hr = E_FAIL;
1949 goto done;
1951 memcpy(&pDeviceDetails->OutputFormat, wfx, sizeof(WAVEFORMATEX) + wfx->cbSize);
1953 CoTaskMemFree(wfx);
1955 done:
1956 IPropertyStore_Release(ps);
1957 IAudioClient_Release(client);
1958 IMMDevice_Release(dev);
1960 return hr;
1963 static HRESULT WINAPI XA22_Initialize(IXAudio22 *iface, UINT32 flags,
1964 XAUDIO2_PROCESSOR processor)
1966 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1967 TRACE("(%p)->(0x%x, 0x%x)\n", This, flags, processor);
1968 return xaudio2_initialize(This, flags, processor);
1971 static HRESULT WINAPI XA22_RegisterForCallbacks(IXAudio22 *iface,
1972 IXAudio2EngineCallback *pCallback)
1974 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1975 return IXAudio2_RegisterForCallbacks(&This->IXAudio2_iface, pCallback);
1978 static void WINAPI XA22_UnregisterForCallbacks(IXAudio22 *iface,
1979 IXAudio2EngineCallback *pCallback)
1981 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1982 IXAudio2_UnregisterForCallbacks(&This->IXAudio2_iface, pCallback);
1985 static HRESULT WINAPI XA22_CreateSourceVoice(IXAudio22 *iface,
1986 IXAudio2SourceVoice **ppSourceVoice, const WAVEFORMATEX *pSourceFormat,
1987 UINT32 flags, float maxFrequencyRatio,
1988 IXAudio2VoiceCallback *pCallback, const XAUDIO2_VOICE_SENDS *pSendList,
1989 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
1991 IXAudio2Impl *This = impl_from_IXAudio22(iface);
1992 return IXAudio2_CreateSourceVoice(&This->IXAudio2_iface, ppSourceVoice,
1993 pSourceFormat, flags, maxFrequencyRatio, pCallback, pSendList,
1994 pEffectChain);
1997 static HRESULT WINAPI XA22_CreateSubmixVoice(IXAudio22 *iface,
1998 IXAudio2SubmixVoice **ppSubmixVoice, UINT32 inputChannels,
1999 UINT32 inputSampleRate, UINT32 flags, UINT32 processingStage,
2000 const XAUDIO2_VOICE_SENDS *pSendList,
2001 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
2003 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2004 return IXAudio2_CreateSubmixVoice(&This->IXAudio2_iface, ppSubmixVoice,
2005 inputChannels, inputSampleRate, flags, processingStage, pSendList,
2006 pEffectChain);
2009 static HRESULT WINAPI XA22_CreateMasteringVoice(IXAudio22 *iface,
2010 IXAudio2MasteringVoice **ppMasteringVoice, UINT32 inputChannels,
2011 UINT32 inputSampleRate, UINT32 flags, UINT32 deviceIndex,
2012 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
2014 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2016 TRACE("(%p)->(%p, %u, %u, 0x%x, %u, %p)\n", This, ppMasteringVoice,
2017 inputChannels, inputSampleRate, flags, deviceIndex,
2018 pEffectChain);
2020 if(deviceIndex >= This->ndevs)
2021 return E_INVALIDARG;
2023 return IXAudio2_CreateMasteringVoice(&This->IXAudio2_iface, ppMasteringVoice,
2024 inputChannels, inputSampleRate, flags, This->devids[deviceIndex],
2025 pEffectChain, AudioCategory_GameEffects);
2028 static HRESULT WINAPI XA22_StartEngine(IXAudio22 *iface)
2030 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2031 return IXAudio2_StartEngine(&This->IXAudio2_iface);
2034 static void WINAPI XA22_StopEngine(IXAudio22 *iface)
2036 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2037 return IXAudio2_StopEngine(&This->IXAudio2_iface);
2040 static HRESULT WINAPI XA22_CommitChanges(IXAudio22 *iface, UINT32 operationSet)
2042 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2043 return IXAudio2_CommitChanges(&This->IXAudio2_iface, operationSet);
2046 static void WINAPI XA22_GetPerformanceData(IXAudio22 *iface,
2047 XAUDIO22_PERFORMANCE_DATA *pPerfData)
2049 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2050 XAUDIO2_PERFORMANCE_DATA data;
2052 IXAudio2_GetPerformanceData(&This->IXAudio2_iface, &data);
2054 pPerfData->AudioCyclesSinceLastQuery = data.AudioCyclesSinceLastQuery;
2055 pPerfData->TotalCyclesSinceLastQuery = data.TotalCyclesSinceLastQuery;
2056 pPerfData->MinimumCyclesPerQuantum = data.MinimumCyclesPerQuantum;
2057 pPerfData->MaximumCyclesPerQuantum = data.MaximumCyclesPerQuantum;
2058 pPerfData->MemoryUsageInBytes = data.MemoryUsageInBytes;
2059 pPerfData->CurrentLatencyInSamples = data.CurrentLatencyInSamples;
2060 pPerfData->GlitchesSinceEngineStarted = data.GlitchesSinceEngineStarted;
2061 pPerfData->ActiveSourceVoiceCount = data.ActiveSourceVoiceCount;
2062 pPerfData->TotalSourceVoiceCount = data.TotalSourceVoiceCount;
2064 pPerfData->ActiveSubmixVoiceCount = data.ActiveSubmixVoiceCount;
2065 pPerfData->TotalSubmixVoiceCount = data.ActiveSubmixVoiceCount;
2067 pPerfData->ActiveXmaSourceVoices = data.ActiveXmaSourceVoices;
2068 pPerfData->ActiveXmaStreams = data.ActiveXmaStreams;
2071 static void WINAPI XA22_SetDebugConfiguration(IXAudio22 *iface,
2072 const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
2073 void *pReserved)
2075 IXAudio2Impl *This = impl_from_IXAudio22(iface);
2076 return IXAudio2_SetDebugConfiguration(&This->IXAudio2_iface,
2077 pDebugConfiguration, pReserved);
2080 const IXAudio22Vtbl XAudio22_Vtbl = {
2081 XA22_QueryInterface,
2082 XA22_AddRef,
2083 XA22_Release,
2084 XA22_GetDeviceCount,
2085 XA22_GetDeviceDetails,
2086 XA22_Initialize,
2087 XA22_RegisterForCallbacks,
2088 XA22_UnregisterForCallbacks,
2089 XA22_CreateSourceVoice,
2090 XA22_CreateSubmixVoice,
2091 XA22_CreateMasteringVoice,
2092 XA22_StartEngine,
2093 XA22_StopEngine,
2094 XA22_CommitChanges,
2095 XA22_GetPerformanceData,
2096 XA22_SetDebugConfiguration
2099 #elif XAUDIO2_VER <= 7
2101 static inline IXAudio2Impl *impl_from_IXAudio27(IXAudio27 *iface)
2103 return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio27_iface);
2106 static HRESULT WINAPI XA27_QueryInterface(IXAudio27 *iface, REFIID riid,
2107 void **ppvObject)
2109 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2110 return IXAudio2_QueryInterface(&This->IXAudio2_iface, riid, ppvObject);
2113 static ULONG WINAPI XA27_AddRef(IXAudio27 *iface)
2115 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2116 return IXAudio2_AddRef(&This->IXAudio2_iface);
2119 static ULONG WINAPI XA27_Release(IXAudio27 *iface)
2121 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2122 return IXAudio2_Release(&This->IXAudio2_iface);
2125 static HRESULT WINAPI XA27_GetDeviceCount(IXAudio27 *iface, UINT32 *pCount)
2127 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2129 TRACE("%p, %p\n", This, pCount);
2131 *pCount = This->ndevs;
2133 return S_OK;
2136 static HRESULT WINAPI XA27_GetDeviceDetails(IXAudio27 *iface, UINT32 index,
2137 XAUDIO2_DEVICE_DETAILS *pDeviceDetails)
2139 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2140 HRESULT hr;
2141 IMMDevice *dev;
2142 IAudioClient *client;
2143 IPropertyStore *ps;
2144 WAVEFORMATEX *wfx;
2145 PROPVARIANT var;
2147 TRACE("%p, %u, %p\n", This, index, pDeviceDetails);
2149 if(index >= This->ndevs)
2150 return E_INVALIDARG;
2152 hr = IMMDeviceEnumerator_GetDevice(This->devenum, This->devids[index], &dev);
2153 if(FAILED(hr)){
2154 WARN("GetDevice failed: %08x\n", hr);
2155 return hr;
2158 hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_INPROC_SERVER,
2159 NULL, (void**)&client);
2160 if(FAILED(hr)){
2161 WARN("Activate failed: %08x\n", hr);
2162 IMMDevice_Release(dev);
2163 return hr;
2166 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &ps);
2167 if(FAILED(hr)){
2168 WARN("OpenPropertyStore failed: %08x\n", hr);
2169 IAudioClient_Release(client);
2170 IMMDevice_Release(dev);
2171 return hr;
2174 PropVariantInit(&var);
2176 hr = IPropertyStore_GetValue(ps, (PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &var);
2177 if(FAILED(hr)){
2178 WARN("GetValue failed: %08x\n", hr);
2179 goto done;
2182 lstrcpynW(pDeviceDetails->DisplayName, var.u.pwszVal, sizeof(pDeviceDetails->DisplayName)/sizeof(WCHAR));
2184 PropVariantClear(&var);
2186 hr = IAudioClient_GetMixFormat(client, &wfx);
2187 if(FAILED(hr)){
2188 WARN("GetMixFormat failed: %08x\n", hr);
2189 goto done;
2192 lstrcpyW(pDeviceDetails->DeviceID, This->devids[index]);
2194 if(index == 0)
2195 pDeviceDetails->Role = GlobalDefaultDevice;
2196 else
2197 pDeviceDetails->Role = NotDefaultDevice;
2199 if(sizeof(WAVEFORMATEX) + wfx->cbSize > sizeof(pDeviceDetails->OutputFormat)){
2200 FIXME("AudioClient format is too large to fit into WAVEFORMATEXTENSIBLE!\n");
2201 CoTaskMemFree(wfx);
2202 hr = E_FAIL;
2203 goto done;
2205 memcpy(&pDeviceDetails->OutputFormat, wfx, sizeof(WAVEFORMATEX) + wfx->cbSize);
2207 CoTaskMemFree(wfx);
2209 done:
2210 IPropertyStore_Release(ps);
2211 IAudioClient_Release(client);
2212 IMMDevice_Release(dev);
2214 return hr;
2217 static HRESULT WINAPI XA27_Initialize(IXAudio27 *iface, UINT32 flags,
2218 XAUDIO2_PROCESSOR processor)
2220 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2221 TRACE("(%p)->(0x%x, 0x%x)\n", This, flags, processor);
2222 return xaudio2_initialize(This, flags, processor);
2225 static HRESULT WINAPI XA27_RegisterForCallbacks(IXAudio27 *iface,
2226 IXAudio2EngineCallback *pCallback)
2228 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2229 return IXAudio2_RegisterForCallbacks(&This->IXAudio2_iface, pCallback);
2232 static void WINAPI XA27_UnregisterForCallbacks(IXAudio27 *iface,
2233 IXAudio2EngineCallback *pCallback)
2235 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2236 IXAudio2_UnregisterForCallbacks(&This->IXAudio2_iface, pCallback);
2239 static HRESULT WINAPI XA27_CreateSourceVoice(IXAudio27 *iface,
2240 IXAudio2SourceVoice **ppSourceVoice, const WAVEFORMATEX *pSourceFormat,
2241 UINT32 flags, float maxFrequencyRatio,
2242 IXAudio2VoiceCallback *pCallback, const XAUDIO2_VOICE_SENDS *pSendList,
2243 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
2245 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2246 return IXAudio2_CreateSourceVoice(&This->IXAudio2_iface, ppSourceVoice,
2247 pSourceFormat, flags, maxFrequencyRatio, pCallback, pSendList,
2248 pEffectChain);
2251 static HRESULT WINAPI XA27_CreateSubmixVoice(IXAudio27 *iface,
2252 IXAudio2SubmixVoice **ppSubmixVoice, UINT32 inputChannels,
2253 UINT32 inputSampleRate, UINT32 flags, UINT32 processingStage,
2254 const XAUDIO2_VOICE_SENDS *pSendList,
2255 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
2257 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2258 return IXAudio2_CreateSubmixVoice(&This->IXAudio2_iface, ppSubmixVoice,
2259 inputChannels, inputSampleRate, flags, processingStage, pSendList,
2260 pEffectChain);
2263 static HRESULT WINAPI XA27_CreateMasteringVoice(IXAudio27 *iface,
2264 IXAudio2MasteringVoice **ppMasteringVoice, UINT32 inputChannels,
2265 UINT32 inputSampleRate, UINT32 flags, UINT32 deviceIndex,
2266 const XAUDIO2_EFFECT_CHAIN *pEffectChain)
2268 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2270 TRACE("(%p)->(%p, %u, %u, 0x%x, %u, %p)\n", This, ppMasteringVoice,
2271 inputChannels, inputSampleRate, flags, deviceIndex,
2272 pEffectChain);
2274 if(deviceIndex >= This->ndevs)
2275 return E_INVALIDARG;
2277 return IXAudio2_CreateMasteringVoice(&This->IXAudio2_iface, ppMasteringVoice,
2278 inputChannels, inputSampleRate, flags, This->devids[deviceIndex],
2279 pEffectChain, AudioCategory_GameEffects);
2282 static HRESULT WINAPI XA27_StartEngine(IXAudio27 *iface)
2284 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2285 return IXAudio2_StartEngine(&This->IXAudio2_iface);
2288 static void WINAPI XA27_StopEngine(IXAudio27 *iface)
2290 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2291 return IXAudio2_StopEngine(&This->IXAudio2_iface);
2294 static HRESULT WINAPI XA27_CommitChanges(IXAudio27 *iface, UINT32 operationSet)
2296 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2297 return IXAudio2_CommitChanges(&This->IXAudio2_iface, operationSet);
2300 static void WINAPI XA27_GetPerformanceData(IXAudio27 *iface,
2301 XAUDIO2_PERFORMANCE_DATA *pPerfData)
2303 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2304 return IXAudio2_GetPerformanceData(&This->IXAudio2_iface, pPerfData);
2307 static void WINAPI XA27_SetDebugConfiguration(IXAudio27 *iface,
2308 const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
2309 void *pReserved)
2311 IXAudio2Impl *This = impl_from_IXAudio27(iface);
2312 return IXAudio2_SetDebugConfiguration(&This->IXAudio2_iface,
2313 pDebugConfiguration, pReserved);
2316 const IXAudio27Vtbl XAudio27_Vtbl = {
2317 XA27_QueryInterface,
2318 XA27_AddRef,
2319 XA27_Release,
2320 XA27_GetDeviceCount,
2321 XA27_GetDeviceDetails,
2322 XA27_Initialize,
2323 XA27_RegisterForCallbacks,
2324 XA27_UnregisterForCallbacks,
2325 XA27_CreateSourceVoice,
2326 XA27_CreateSubmixVoice,
2327 XA27_CreateMasteringVoice,
2328 XA27_StartEngine,
2329 XA27_StopEngine,
2330 XA27_CommitChanges,
2331 XA27_GetPerformanceData,
2332 XA27_SetDebugConfiguration
2334 #endif
2335 /* END IXAudio2 */