SDL  2.0
SDL_xaudio2.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef _SDL_XAUDIO2_H
23 #define _SDL_XAUDIO2_H
24 
25 #include <windows.h>
26 #include <mmreg.h>
27 #include <objbase.h>
28 
29 /* XAudio2 packs its structure members together as tightly as possible.
30  This pragma is needed to ensure compatibility with XAudio2 on 64-bit
31  platforms.
32 */
33 #pragma pack(push, 1)
34 
35 typedef interface IXAudio2 IXAudio2;
40 typedef interface IXAudio2Voice IXAudio2Voice;
42 
43 typedef enum _AUDIO_STREAM_CATEGORY {
56 
57 typedef struct XAUDIO2_BUFFER {
58  UINT32 Flags;
59  UINT32 AudioBytes;
60  const BYTE *pAudioData;
61  UINT32 PlayBegin;
62  UINT32 PlayLength;
63  UINT32 LoopBegin;
64  UINT32 LoopLength;
65  UINT32 LoopCount;
66  void *pContext;
68 
69 typedef struct XAUDIO2_BUFFER_WMA {
71  UINT32 PacketCount;
73 
74 typedef struct XAUDIO2_SEND_DESCRIPTOR {
75  UINT32 Flags;
78 
79 typedef struct XAUDIO2_VOICE_SENDS {
80  UINT32 SendCount;
83 
84 typedef struct XAUDIO2_EFFECT_DESCRIPTOR {
85  IUnknown *pEffect;
89 
90 typedef struct XAUDIO2_EFFECT_CHAIN {
91  UINT32 EffectCount;
94 
95 typedef struct XAUDIO2_PERFORMANCE_DATA {
111 
113  UINT32 TraceMask;
114  UINT32 BreakMask;
118  BOOL LogTiming;
120 
121 typedef struct XAUDIO2_VOICE_DETAILS {
123  UINT32 ActiveFlags;
127 
128 typedef enum XAUDIO2_FILTER_TYPE {
136 
139  float Frequency;
140  float OneOverQ;
142 
143 typedef struct XAUDIO2_VOICE_STATE {
148 
149 
150 typedef UINT32 XAUDIO2_PROCESSOR;
151 #define Processor1 0x00000001
152 #define XAUDIO2_DEFAULT_PROCESSOR Processor1
153 
154 #define XAUDIO2_E_DEVICE_INVALIDATED 0x88960004
155 #define XAUDIO2_COMMIT_NOW 0
156 #define XAUDIO2_VOICE_NOSAMPLESPLAYED 0x0100
157 #define XAUDIO2_DEFAULT_CHANNELS 0
158 
159 extern HRESULT __stdcall XAudio2Create(
160  _Out_ IXAudio2 **ppXAudio2,
161  _In_ UINT32 Flags,
162  _In_ XAUDIO2_PROCESSOR XAudio2Processor
163  );
164 
165 #undef INTERFACE
166 #define INTERFACE IXAudio2
167 typedef interface IXAudio2 {
168  const struct IXAudio2Vtbl FAR* lpVtbl;
169 } IXAudio2;
170 typedef const struct IXAudio2Vtbl IXAudio2Vtbl;
171 const struct IXAudio2Vtbl
172 {
173  /* IUnknown */
174  STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
175  STDMETHOD_(ULONG, AddRef)(THIS) PURE;
176  STDMETHOD_(ULONG, Release)(THIS) PURE;
177 
178  /* IXAudio2 */
179  STDMETHOD_(HRESULT, RegisterForCallbacks)(THIS, IXAudio2EngineCallback *pCallback) PURE;
180  STDMETHOD_(VOID, UnregisterForCallbacks)(THIS, IXAudio2EngineCallback *pCallback) PURE;
181  STDMETHOD_(HRESULT, CreateSourceVoice)(THIS, IXAudio2SourceVoice **ppSourceVoice,
182  const WAVEFORMATEX *pSourceFormat,
183  UINT32 Flags,
184  float MaxFrequencyRatio,
185  IXAudio2VoiceCallback *pCallback,
186  const XAUDIO2_VOICE_SENDS *pSendList,
187  const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
188  STDMETHOD_(HRESULT, CreateSubmixVoice)(THIS, IXAudio2SubmixVoice **ppSubmixVoice,
189  UINT32 InputChannels,
190  UINT32 InputSampleRate,
191  UINT32 Flags,
192  UINT32 ProcessingStage,
193  const XAUDIO2_VOICE_SENDS *pSendList,
194  const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
195  STDMETHOD_(HRESULT, CreateMasteringVoice)(THIS, IXAudio2MasteringVoice **ppMasteringVoice,
196  UINT32 InputChannels,
197  UINT32 InputSampleRate,
198  UINT32 Flags,
199  LPCWSTR szDeviceId,
200  const XAUDIO2_EFFECT_CHAIN *pEffectChain,
201  AUDIO_STREAM_CATEGORY StreamCategory) PURE;
202  STDMETHOD_(HRESULT, StartEngine)(THIS) PURE;
203  STDMETHOD_(VOID, StopEngine)(THIS) PURE;
204  STDMETHOD_(HRESULT, CommitChanges)(THIS, UINT32 OperationSet) PURE;
205  STDMETHOD_(HRESULT, GetPerformanceData)(THIS, XAUDIO2_PERFORMANCE_DATA *pPerfData) PURE;
206  STDMETHOD_(HRESULT, SetDebugConfiguration)(THIS, XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
207  VOID *pReserved) PURE;
208 };
209 
210 #define IXAudio2_Release(A) ((A)->lpVtbl->Release(A))
211 #define IXAudio2_CreateSourceVoice(A,B,C,D,E,F,G,H) ((A)->lpVtbl->CreateSourceVoice(A,B,C,D,E,F,G,H))
212 #define IXAudio2_CreateMasteringVoice(A,B,C,D,E,F,G,H) ((A)->lpVtbl->CreateMasteringVoice(A,B,C,D,E,F,G,H))
213 #define IXAudio2_StartEngine(A) ((A)->lpVtbl->StartEngine(A))
214 #define IXAudio2_StopEngine(A) ((A)->lpVtbl->StopEngine(A))
215 
216 
217 #undef INTERFACE
218 #define INTERFACE IXAudio2SourceVoice
219 typedef interface IXAudio2SourceVoice {
220  const struct IXAudio2SourceVoiceVtbl FAR* lpVtbl;
224 {
225  /* MSDN says that IXAudio2Voice inherits from IXAudio2, but MSVC's debugger
226  * says otherwise, and that IXAudio2Voice doesn't inherit from any other
227  * interface!
228  */
229 
230  /* IXAudio2Voice */
231  STDMETHOD_(VOID, GetVoiceDetails)(THIS, XAUDIO2_VOICE_DETAILS *pVoiceDetails) PURE;
232  STDMETHOD_(HRESULT, SetOutputVoices)(THIS, const XAUDIO2_VOICE_SENDS *pSendList) PURE;
233  STDMETHOD_(HRESULT, SetEffectChain)(THIS, const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
234  STDMETHOD_(HRESULT, EnableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
235  STDMETHOD_(HRESULT, DisableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
236  STDMETHOD_(VOID, GetEffectState)(THIS, UINT32 EffectIndex, BOOL *pEnabled) PURE;
237  STDMETHOD_(HRESULT, SetEffectParameters)(THIS, UINT32 EffectIndex,
238  const void *pParameters,
239  UINT32 ParametersByteSize,
240  UINT32 OperationSet) PURE;
241  STDMETHOD_(VOID, GetEffectParameters)(THIS, UINT32 EffectIndex,
242  void *pParameters,
243  UINT32 ParametersByteSize) PURE;
244  STDMETHOD_(HRESULT, SetFilterParameters)(THIS, const XAUDIO2_FILTER_PARAMETERS *pParameters,
245  UINT32 OperationSet) PURE;
246  STDMETHOD_(VOID, GetFilterParameters)(THIS, XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
247  STDMETHOD_(HRESULT, SetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
248  XAUDIO2_FILTER_PARAMETERS *pParameters,
249  UINT32 OperationSet) PURE;
250  STDMETHOD_(VOID, GetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
251  XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
252  STDMETHOD_(HRESULT, SetVolume)(THIS, float Volume,
253  UINT32 OperationSet) PURE;
254  STDMETHOD_(VOID, GetVolume)(THIS, float *pVolume) PURE;
255  STDMETHOD_(HRESULT, SetChannelVolumes)(THIS, UINT32 Channels,
256  const float *pVolumes,
257  UINT32 OperationSet) PURE;
258  STDMETHOD_(VOID, GetChannelVolumes)(THIS, UINT32 Channels,
259  float *pVolumes) PURE;
260  STDMETHOD_(HRESULT, SetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
261  UINT32 SourceChannels,
262  UINT32 DestinationChannels,
263  const float *pLevelMatrix,
264  UINT32 OperationSet) PURE;
265  STDMETHOD_(VOID, GetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
266  UINT32 SourceChannels,
267  UINT32 DestinationChannels,
268  float *pLevelMatrix) PURE;
269  STDMETHOD_(VOID, DestroyVoice)(THIS) PURE;
270 
271  /* IXAudio2SourceVoice */
272  STDMETHOD_(HRESULT, Start)(THIS, UINT32 Flags,
273  UINT32 OperationSet) PURE;
274  STDMETHOD_(HRESULT, Stop)(THIS, UINT32 Flags,
275  UINT32 OperationSet) PURE;
276  STDMETHOD_(HRESULT, SubmitSourceBuffer)(THIS, const XAUDIO2_BUFFER *pBuffer,
277  const XAUDIO2_BUFFER_WMA *pBufferWMA) PURE;
278  STDMETHOD_(HRESULT, FlushSourceBuffers)(THIS) PURE;
279  STDMETHOD_(HRESULT, Discontinuity)(THIS) PURE;
280  STDMETHOD_(HRESULT, ExitLoop)(THIS, UINT32 OperationSet) PURE;
281  STDMETHOD_(VOID, GetState)(THIS, XAUDIO2_VOICE_STATE *pVoiceState,
282  UINT32 Flags) PURE;
283  STDMETHOD_(HRESULT, SetFrequencyRatio)(THIS, float Ratio,
284  UINT32 OperationSet) PURE;
285  STDMETHOD_(VOID, GetFrequencyRatio)(THIS, float *pRatio) PURE;
286  STDMETHOD_(HRESULT, SetSourceSampleRate)(THIS, UINT32 NewSourceSampleRate) PURE;
287 };
288 
289 #define IXAudio2SourceVoice_DestroyVoice(A) ((A)->lpVtbl->DestroyVoice(A))
290 #define IXAudio2SourceVoice_Start(A,B,C) ((A)->lpVtbl->Start(A,B,C))
291 #define IXAudio2SourceVoice_Stop(A,B,C) ((A)->lpVtbl->Stop(A,B,C))
292 #define IXAudio2SourceVoice_SubmitSourceBuffer(A,B,C) ((A)->lpVtbl->SubmitSourceBuffer(A,B,C))
293 #define IXAudio2SourceVoice_FlushSourceBuffers(A) ((A)->lpVtbl->FlushSourceBuffers(A))
294 #define IXAudio2SourceVoice_Discontinuity(A) ((A)->lpVtbl->Discontinuity(A))
295 #define IXAudio2SourceVoice_GetState(A,B,C) ((A)->lpVtbl->GetState(A,B,C))
296 
297 
298 #undef INTERFACE
299 #define INTERFACE IXAudio2MasteringVoice
300 typedef interface IXAudio2MasteringVoice {
301  const struct IXAudio2MasteringVoiceVtbl FAR* lpVtbl;
305 {
306  /* MSDN says that IXAudio2Voice inherits from IXAudio2, but MSVC's debugger
307  * says otherwise, and that IXAudio2Voice doesn't inherit from any other
308  * interface!
309  */
310 
311  /* IXAudio2Voice */
312  STDMETHOD_(VOID, GetVoiceDetails)(THIS, XAUDIO2_VOICE_DETAILS *pVoiceDetails) PURE;
313  STDMETHOD_(HRESULT, SetOutputVoices)(THIS, const XAUDIO2_VOICE_SENDS *pSendList) PURE;
314  STDMETHOD_(HRESULT, SetEffectChain)(THIS, const XAUDIO2_EFFECT_CHAIN *pEffectChain) PURE;
315  STDMETHOD_(HRESULT, EnableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
316  STDMETHOD_(HRESULT, DisableEffect)(THIS, UINT32 EffectIndex, UINT32 OperationSet) PURE;
317  STDMETHOD_(VOID, GetEffectState)(THIS, UINT32 EffectIndex, BOOL *pEnabled) PURE;
318  STDMETHOD_(HRESULT, SetEffectParameters)(THIS, UINT32 EffectIndex,
319  const void *pParameters,
320  UINT32 ParametersByteSize,
321  UINT32 OperationSet) PURE;
322  STDMETHOD_(VOID, GetEffectParameters)(THIS, UINT32 EffectIndex,
323  void *pParameters,
324  UINT32 ParametersByteSize) PURE;
325  STDMETHOD_(HRESULT, SetFilterParameters)(THIS, const XAUDIO2_FILTER_PARAMETERS *pParameters,
326  UINT32 OperationSet) PURE;
327  STDMETHOD_(VOID, GetFilterParameters)(THIS, XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
328  STDMETHOD_(HRESULT, SetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
329  XAUDIO2_FILTER_PARAMETERS *pParameters,
330  UINT32 OperationSet) PURE;
331  STDMETHOD_(VOID, GetOutputFilterParameters)(THIS, IXAudio2Voice *pDestinationVoice,
332  XAUDIO2_FILTER_PARAMETERS *pParameters) PURE;
333  STDMETHOD_(HRESULT, SetVolume)(THIS, float Volume,
334  UINT32 OperationSet) PURE;
335  STDMETHOD_(VOID, GetVolume)(THIS, float *pVolume) PURE;
336  STDMETHOD_(HRESULT, SetChannelVolumes)(THIS, UINT32 Channels,
337  const float *pVolumes,
338  UINT32 OperationSet) PURE;
339  STDMETHOD_(VOID, GetChannelVolumes)(THIS, UINT32 Channels,
340  float *pVolumes) PURE;
341  STDMETHOD_(HRESULT, SetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
342  UINT32 SourceChannels,
343  UINT32 DestinationChannels,
344  const float *pLevelMatrix,
345  UINT32 OperationSet) PURE;
346  STDMETHOD_(VOID, GetOutputMatrix)(THIS, IXAudio2Voice *pDestinationVoice,
347  UINT32 SourceChannels,
348  UINT32 DestinationChannels,
349  float *pLevelMatrix) PURE;
350  STDMETHOD_(VOID, DestroyVoice)(THIS) PURE;
351 
352  /* IXAudio2SourceVoice */
353  STDMETHOD_(VOID, GetChannelMask)(THIS, DWORD *pChannelMask) PURE;
354 };
355 
356 #define IXAudio2MasteringVoice_DestroyVoice(A) ((A)->lpVtbl->DestroyVoice(A))
357 
358 
359 #undef INTERFACE
360 #define INTERFACE IXAudio2VoiceCallback
361 typedef interface IXAudio2VoiceCallback {
362  const struct IXAudio2VoiceCallbackVtbl FAR* lpVtbl;
366 {
367  /* MSDN says that IXAudio2VoiceCallback inherits from IXAudio2, but SDL's
368  * own code says otherwise, and that IXAudio2VoiceCallback doesn't inherit
369  * from any other interface!
370  */
371 
372  /* IXAudio2VoiceCallback */
373  STDMETHOD_(VOID, OnVoiceProcessingPassStart)(THIS, UINT32 BytesRequired) PURE;
374  STDMETHOD_(VOID, OnVoiceProcessingPassEnd)(THIS) PURE;
375  STDMETHOD_(VOID, OnStreamEnd)(THIS) PURE;
376  STDMETHOD_(VOID, OnBufferStart)(THIS, void *pBufferContext) PURE;
377  STDMETHOD_(VOID, OnBufferEnd)(THIS, void *pBufferContext) PURE;
378  STDMETHOD_(VOID, OnLoopEnd)(THIS, void *pBufferContext) PURE;
379  STDMETHOD_(VOID, OnVoiceError)(THIS, void *pBufferContext, HRESULT Error) PURE;
380 };
381 
382 #pragma pack(pop) /* Undo pragma push */
383 
384 #endif /* _SDL_XAUDIO2_H */
385 
386 /* vi: set ts=4 sw=4 expandtab: */
void * pContext
Definition: SDL_xaudio2.h:66
IXAudio2Voice * pOutputVoice
Definition: SDL_xaudio2.h:76
UINT32 LoopBegin
Definition: SDL_xaudio2.h:63
interface IXAudio2MasteringVoice IXAudio2MasteringVoice
Definition: SDL_xaudio2.h:37
UINT32 LoopLength
Definition: SDL_xaudio2.h:64
UINT32 XAUDIO2_PROCESSOR
Definition: SDL_xaudio2.h:150
interface IXAudio2Voice IXAudio2Voice
Definition: SDL_xaudio2.h:40
XAUDIO2_VOICE_STATE * pVoiceState
Definition: SDL_xaudio2.h:281
interface IXAudio2EngineCallback IXAudio2EngineCallback
Definition: SDL_xaudio2.h:38
UINT32 AudioBytes
Definition: SDL_xaudio2.h:59
interface IXAudio2 IXAudio2
Definition: SDL_xaudio2.h:35
XAUDIO2_SEND_DESCRIPTOR * pSends
Definition: SDL_xaudio2.h:81
XAUDIO2_FILTER_TYPE
Definition: SDL_xaudio2.h:128
#define FAR
Definition: SDL_directx.h:37
AUDIO_STREAM_CATEGORY
Definition: SDL_xaudio2.h:43
UINT32 const float * pVolumes
Definition: SDL_xaudio2.h:336
IXAudio2MasteringVoice UINT32 UINT32 UINT32 LPCWSTR szDeviceId
Definition: SDL_xaudio2.h:195
IXAudio2Voice UINT32 SourceChannels
Definition: SDL_xaudio2.h:341
UINT32 const float * pVolumes
Definition: SDL_xaudio2.h:255
interface IXAudio2SourceVoice IXAudio2SourceVoice
Definition: SDL_xaudio2.h:36
IXAudio2Voice UINT32 SourceChannels
Definition: SDL_xaudio2.h:260
interface IXAudio2VoiceCallback IXAudio2VoiceCallback
Definition: SDL_xaudio2.h:39
const UINT32 * pDecodedPacketCumulativeBytes
Definition: SDL_xaudio2.h:70
interface IXAudio2SubmixVoice IXAudio2SubmixVoice
Definition: SDL_xaudio2.h:41
void * pCurrentBufferContext
Definition: SDL_xaudio2.h:144
HRESULT __stdcall XAudio2Create(_Out_ IXAudio2 **ppXAudio2, _In_ UINT32 Flags, _In_ XAUDIO2_PROCESSOR XAudio2Processor)
const BYTE * pAudioData
Definition: SDL_xaudio2.h:60
UINT32 LoopCount
Definition: SDL_xaudio2.h:65
UINT32 PlayLength
Definition: SDL_xaudio2.h:62
UINT32 PlayBegin
Definition: SDL_xaudio2.h:61
XAUDIO2_EFFECT_DESCRIPTOR * pEffectDescriptors
Definition: SDL_xaudio2.h:92
XAUDIO2_FILTER_TYPE Type
Definition: SDL_xaudio2.h:138