RetroArch
xaudio29.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2018 - Krzysztof Haładyn
3  *
4  * RetroArch is free software: you can redistribute it and/or modify it under the terms
5  * of the GNU General Public License as published by the Free Software Found-
6  * ation, either version 3 of the License, or (at your option) any later version.
7  *
8  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  * PURPOSE. See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along with RetroArch.
13  * If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16  /**************************************************************************
17  *
18  * Copyright (c) Microsoft Corporation. All rights reserved.
19  *
20  * File: xaudio2.h
21  * Content: Declarations for the XAudio2 game audio API.
22  *
23  **************************************************************************/
24 
25  /* Modified slightly to build without requiring the WinRT compiler since that is only available in C++ sources */
26 
27 #ifdef _MSC_VER
28 #pragma once
29 #endif
30 
31 #ifndef __XAUDIO2_INCLUDED__
32 #define __XAUDIO2_INCLUDED__
33 
34 #include <sdkddkver.h>
35 
36 #include <retro_inline.h>
37 
38 #if(_WIN32_WINNT < _WIN32_WINNT_WIN8)
39 #error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."
40 #endif // (_WIN32_WINNT < _WIN32_WINNT_WIN8)
41 
42 #include <winapifamily.h>
43 
44 #pragma region Application Family
45 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE)
46 
47 // Current name of the DLL shipped in the same SDK as this header.
48 // The name reflects the current version
49 #if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
50 #define XAUDIO2_DLL_A "xaudio2_9.dll"
51 #define XAUDIO2_DLL_W L"xaudio2_9.dll"
52 #define XAUDIO2D_DLL_A "xaudio2_9d.dll"
53 #define XAUDIO2D_DLL_W L"xaudio2_9d.dll"
54 #else
55 #define XAUDIO2_DLL_A "xaudio2_8.dll"
56 #define XAUDIO2_DLL_W L"xaudio2_8.dll"
57 #define XAUDIO2D_DLL_A "xaudio2_8.dll"
58 #define XAUDIO2D_DLL_W L"xaudio2_8.dll"
59 #endif
60 
61 #ifdef UNICODE
62 #define XAUDIO2_DLL XAUDIO2_DLL_W
63 #define XAUDIO2D_DLL XAUDIO2D_DLL_W
64 #else
65 #define XAUDIO2_DLL XAUDIO2_DLL_A
66 #define XAUDIO2D_DLL XAUDIO2D_DLL_A
67 #endif
68 
69 
70 /**************************************************************************
71  *
72  * XAudio2 COM object class and interface IDs.
73  *
74  **************************************************************************/
75 
76 #include <basetyps.h>
77 
78 #if defined(__cplusplus__) && defined(__WINRT__)
79 
80 #if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
81  // XAudio 2.9
82 interface __declspec(uuid("2B02E3CF-2E0B-4ec3-BE45-1B2A3FE7210D")) IXAudio2;
83 #else
84  // XAudio 2.8
85 interface __declspec(uuid("60d8dac8-5aa1-4e8e-b597-2f5e2883d484")) IXAudio2;
86 #endif
87 
88 #else
89 
90  /* Modified for C support */
91 #define DEFINE_GUID_X(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
92  static const GUID n = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
93 #define DEFINE_CLSID_X(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
94  DEFINE_GUID_X(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
95 #define DEFINE_IID_X(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
96  DEFINE_GUID_X(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
97 
98 #if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
99 DEFINE_IID_X(IXAudio2, 2B02E3CF, 2E0B, 4ec3, BE, 45, 1B, 2A, 3F, E7, 21, 0D);
100 #else
101 DEFINE_IID_X(IXAudio2, 60d8dac8, 5aa1, 4e8e, b5, 97, 2f, 5e, 28, 83, d4, 84);
102 #endif
103 
104 #endif
105 
106 
107 // Ignore the rest of this header if only the GUID definitions were requested
108 #ifndef GUID_DEFS_ONLY
109 
110 #include <objbase.h> // Windows COM declarations
111 #include <sal.h> // Markers for documenting API semantics
112 #include <mmreg.h> // Basic data types and constants for audio work
113 #include <audiosessiontypes.h> // For AUDIO_STREAM_CATEGORY
114 
115 // All structures defined in this file use tight field packing
116 #pragma pack(push, 1)
117 
118 
119 /**************************************************************************
120  *
121  * XAudio2 constants, flags and error codes.
122  *
123  **************************************************************************/
124 
125  // Numeric boundary values
126 #define XAUDIO2_MAX_BUFFER_BYTES 0x80000000 // Maximum bytes allowed in a source buffer
127 #define XAUDIO2_MAX_QUEUED_BUFFERS 64 // Maximum buffers allowed in a voice queue
128 #define XAUDIO2_MAX_BUFFERS_SYSTEM 2 // Maximum buffers allowed for system threads (Xbox 360 only)
129 #define XAUDIO2_MAX_AUDIO_CHANNELS 64 // Maximum channels in an audio stream
130 #define XAUDIO2_MIN_SAMPLE_RATE 1000 // Minimum audio sample rate supported
131 #define XAUDIO2_MAX_SAMPLE_RATE 200000 // Maximum audio sample rate supported
132 #define XAUDIO2_MAX_VOLUME_LEVEL 16777216.0f // Maximum acceptable volume level (2^24)
133 #define XAUDIO2_MIN_FREQ_RATIO (1/1024.0f) // Minimum SetFrequencyRatio argument
134 #define XAUDIO2_MAX_FREQ_RATIO 1024.0f // Maximum MaxFrequencyRatio argument
135 #define XAUDIO2_DEFAULT_FREQ_RATIO 2.0f // Default MaxFrequencyRatio argument
136 #define XAUDIO2_MAX_FILTER_ONEOVERQ 1.5f // Maximum XAUDIO2_FILTER_PARAMETERS.OneOverQ
137 #define XAUDIO2_MAX_FILTER_FREQUENCY 1.0f // Maximum XAUDIO2_FILTER_PARAMETERS.Frequency
138 #define XAUDIO2_MAX_LOOP_COUNT 254 // Maximum non-infinite XAUDIO2_BUFFER.LoopCount
139 #define XAUDIO2_MAX_INSTANCES 8 // Maximum simultaneous XAudio2 objects on Xbox 360
140 
141 // For XMA voices on Xbox 360 there is an additional restriction on the MaxFrequencyRatio
142 // argument and the voice's sample rate: the product of these numbers cannot exceed 600000
143 // for one-channel voices or 300000 for voices with more than one channel.
144 #define XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MONO 600000
145 #define XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MULTICHANNEL 300000
146 
147 // Numeric values with special meanings
148 #define XAUDIO2_COMMIT_NOW 0 // Used as an OperationSet argument
149 #define XAUDIO2_COMMIT_ALL 0 // Used in IXAudio2::CommitChanges
150 #define XAUDIO2_INVALID_OPSET (UINT32)(-1) // Not allowed for OperationSet arguments
151 #define XAUDIO2_NO_LOOP_REGION 0 // Used in XAUDIO2_BUFFER.LoopCount
152 #define XAUDIO2_LOOP_INFINITE 255 // Used in XAUDIO2_BUFFER.LoopCount
153 #define XAUDIO2_DEFAULT_CHANNELS 0 // Used in CreateMasteringVoice
154 #define XAUDIO2_DEFAULT_SAMPLERATE 0 // Used in CreateMasteringVoice
155 
156 // Flags
157 #define XAUDIO2_DEBUG_ENGINE 0x0001 // Used in XAudio2Create
158 #define XAUDIO2_VOICE_NOPITCH 0x0002 // Used in IXAudio2::CreateSourceVoice
159 #define XAUDIO2_VOICE_NOSRC 0x0004 // Used in IXAudio2::CreateSourceVoice
160 #define XAUDIO2_VOICE_USEFILTER 0x0008 // Used in IXAudio2::CreateSource/SubmixVoice
161 #define XAUDIO2_PLAY_TAILS 0x0020 // Used in IXAudio2SourceVoice::Stop
162 #define XAUDIO2_END_OF_STREAM 0x0040 // Used in XAUDIO2_BUFFER.Flags
163 #define XAUDIO2_SEND_USEFILTER 0x0080 // Used in XAUDIO2_SEND_DESCRIPTOR.Flags
164 #define XAUDIO2_VOICE_NOSAMPLESPLAYED 0x0100 // Used in IXAudio2SourceVoice::GetState
165 #define XAUDIO2_STOP_ENGINE_WHEN_IDLE 0x2000 // Used in XAudio2Create to force the engine to Stop when no source voices are Started, and Start when a voice is Started
166 #define XAUDIO2_1024_QUANTUM 0x8000 // Used in XAudio2Create to specify nondefault processing quantum of 21.33 ms (1024 samples at 48KHz)
167 #define XAUDIO2_NO_VIRTUAL_AUDIO_CLIENT 0x10000 // Used in CreateMasteringVoice to create a virtual audio client
168 
169 // Default parameters for the built-in filter
170 #define XAUDIO2_DEFAULT_FILTER_TYPE LowPassFilter
171 #define XAUDIO2_DEFAULT_FILTER_FREQUENCY XAUDIO2_MAX_FILTER_FREQUENCY
172 #define XAUDIO2_DEFAULT_FILTER_ONEOVERQ 1.0f
173 
174 // Internal XAudio2 constants
175 // The audio frame quantum can be calculated by reducing the fraction:
176 // SamplesPerAudioFrame / SamplesPerSecond
177 #define XAUDIO2_QUANTUM_NUMERATOR 1 // On Windows, XAudio2 processes audio
178 #define XAUDIO2_QUANTUM_DENOMINATOR 100 // in 10ms chunks (= 1/100 seconds)
179 #define XAUDIO2_QUANTUM_MS (1000.0f * XAUDIO2_QUANTUM_NUMERATOR / XAUDIO2_QUANTUM_DENOMINATOR)
180 
181 // XAudio2 error codes
182 #define FACILITY_XAUDIO2 0x896
183 #define XAUDIO2_E_INVALID_CALL 0x88960001 // An API call or one of its arguments was illegal
184 #define XAUDIO2_E_XMA_DECODER_ERROR 0x88960002 // The XMA hardware suffered an unrecoverable error
185 #define XAUDIO2_E_XAPO_CREATION_FAILED 0x88960003 // XAudio2 failed to initialize an XAPO effect
186 #define XAUDIO2_E_DEVICE_INVALIDATED 0x88960004 // An audio device became unusable (unplugged, etc)
187 
188 /**************************************************************************
189  *
190  * Forward declarations for the XAudio2 interfaces.
191  *
192  **************************************************************************/
193 
194 #ifdef __cplusplus
195 #define FWD_DECLARE(x) interface x
196 #else
197 #define FWD_DECLARE(x) typedef interface x x
198 #endif
199 
200 FWD_DECLARE(IXAudio2);
201 FWD_DECLARE(IXAudio2Voice);
202 FWD_DECLARE(IXAudio2SourceVoice);
203 FWD_DECLARE(IXAudio2SubmixVoice);
204 FWD_DECLARE(IXAudio2MasteringVoice);
205 FWD_DECLARE(IXAudio2EngineCallback);
206 FWD_DECLARE(IXAudio2VoiceCallback);
207 
208 
209 /**************************************************************************
210  *
211  * XAudio2 structures and enumerations.
212  *
213  **************************************************************************/
214 
215  // Used in XAudio2Create, specifies which CPU(s) to use.
216 typedef UINT32 XAUDIO2_PROCESSOR;
217 #define Processor1 0x00000001
218 #define Processor2 0x00000002
219 #define Processor3 0x00000004
220 #define Processor4 0x00000008
221 #define Processor5 0x00000010
222 #define Processor6 0x00000020
223 #define Processor7 0x00000040
224 #define Processor8 0x00000080
225 #define Processor9 0x00000100
226 #define Processor10 0x00000200
227 #define Processor11 0x00000400
228 #define Processor12 0x00000800
229 #define Processor13 0x00001000
230 #define Processor14 0x00002000
231 #define Processor15 0x00004000
232 #define Processor16 0x00008000
233 #define Processor17 0x00010000
234 #define Processor18 0x00020000
235 #define Processor19 0x00040000
236 #define Processor20 0x00080000
237 #define Processor21 0x00100000
238 #define Processor22 0x00200000
239 #define Processor23 0x00400000
240 #define Processor24 0x00800000
241 #define Processor25 0x01000000
242 #define Processor26 0x02000000
243 #define Processor27 0x04000000
244 #define Processor28 0x08000000
245 #define Processor29 0x10000000
246 #define Processor30 0x20000000
247 #define Processor31 0x40000000
248 #define Processor32 0x80000000
249 #define XAUDIO2_ANY_PROCESSOR 0xffffffff
250 #define XAUDIO2_DEFAULT_PROCESSOR Processor1
251 
252 // Returned by IXAudio2Voice::GetVoiceDetails
253 typedef struct XAUDIO2_VOICE_DETAILS
254 {
255  UINT32 CreationFlags; // Flags the voice was created with.
256  UINT32 ActiveFlags; // Flags currently active.
257  UINT32 InputChannels; // Channels in the voice's input audio.
258  UINT32 InputSampleRate; // Sample rate of the voice's input audio.
260 
261 // Used in XAUDIO2_VOICE_SENDS below
262 typedef struct XAUDIO2_SEND_DESCRIPTOR
263 {
264  UINT32 Flags; // Either 0 or XAUDIO2_SEND_USEFILTER.
265  IXAudio2Voice* pOutputVoice; // This send's destination voice.
266 } XAUDIO2_SEND_DESCRIPTOR;
267 
268 // Used in the voice creation functions and in IXAudio2Voice::SetOutputVoices
269 typedef struct XAUDIO2_VOICE_SENDS
270 {
271  UINT32 SendCount; // Number of sends from this voice.
272  XAUDIO2_SEND_DESCRIPTOR* pSends; // Array of SendCount send descriptors.
274 
275 // Used in XAUDIO2_EFFECT_CHAIN below
276 typedef struct XAUDIO2_EFFECT_DESCRIPTOR
277 {
278  IUnknown* pEffect; // Pointer to the effect object's IUnknown interface.
279  BOOL InitialState; // TRUE if the effect should begin in the enabled state.
280  UINT32 OutputChannels; // How many output channels the effect should produce.
282 
283 // Used in the voice creation functions and in IXAudio2Voice::SetEffectChain
284 typedef struct XAUDIO2_EFFECT_CHAIN
285 {
286  UINT32 EffectCount; // Number of effects in this voice's effect chain.
287  XAUDIO2_EFFECT_DESCRIPTOR* pEffectDescriptors; // Array of effect descriptors.
289 
290 // Used in XAUDIO2_FILTER_PARAMETERS below
291 typedef enum XAUDIO2_FILTER_TYPE
292 {
293  LowPassFilter, // Attenuates frequencies above the cutoff frequency (state-variable filter).
294  BandPassFilter, // Attenuates frequencies outside a given range (state-variable filter).
295  HighPassFilter, // Attenuates frequencies below the cutoff frequency (state-variable filter).
296  NotchFilter, // Attenuates frequencies inside a given range (state-variable filter).
297  LowPassOnePoleFilter, // Attenuates frequencies above the cutoff frequency (one-pole filter, XAUDIO2_FILTER_PARAMETERS.OneOverQ has no effect)
298  HighPassOnePoleFilter // Attenuates frequencies below the cutoff frequency (one-pole filter, XAUDIO2_FILTER_PARAMETERS.OneOverQ has no effect)
300 
301 // Used in IXAudio2Voice::Set/GetFilterParameters and Set/GetOutputFilterParameters
302 typedef struct XAUDIO2_FILTER_PARAMETERS
303 {
304  XAUDIO2_FILTER_TYPE Type; // Filter type.
305  float Frequency; // Filter coefficient.
306  // must be >= 0 and <= XAUDIO2_MAX_FILTER_FREQUENCY
307  // See XAudio2CutoffFrequencyToRadians() for state-variable filter types and
308  // XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types.
309  float OneOverQ; // Reciprocal of the filter's quality factor Q;
310  // must be > 0 and <= XAUDIO2_MAX_FILTER_ONEOVERQ.
311  // Has no effect for one-pole filters.
313 
314 // Used in IXAudio2SourceVoice::SubmitSourceBuffer
315 typedef struct XAUDIO2_BUFFER
316 {
317  UINT32 Flags; // Either 0 or XAUDIO2_END_OF_STREAM.
318  UINT32 AudioBytes; // Size of the audio data buffer in bytes.
319  const BYTE* pAudioData; // Pointer to the audio data buffer.
320  UINT32 PlayBegin; // First sample in this buffer to be played.
321  UINT32 PlayLength; // Length of the region to be played in samples,
322  // or 0 to play the whole buffer.
323  UINT32 LoopBegin; // First sample of the region to be looped.
324  UINT32 LoopLength; // Length of the desired loop region in samples,
325  // or 0 to loop the entire buffer.
326  UINT32 LoopCount; // Number of times to repeat the loop region,
327  // or XAUDIO2_LOOP_INFINITE to loop forever.
328  void* pContext; // Context value to be passed back in callbacks.
330 
331 // Used in IXAudio2SourceVoice::SubmitSourceBuffer when submitting XWMA data.
332 // NOTE: If an XWMA sound is submitted in more than one buffer, each buffer's
333 // pDecodedPacketCumulativeBytes[PacketCount-1] value must be subtracted from
334 // all the entries in the next buffer's pDecodedPacketCumulativeBytes array.
335 // And whether a sound is submitted in more than one buffer or not, the final
336 // buffer of the sound should use the XAUDIO2_END_OF_STREAM flag, or else the
337 // client must call IXAudio2SourceVoice::Discontinuity after submitting it.
338 typedef struct XAUDIO2_BUFFER_WMA
339 {
340  const UINT32* pDecodedPacketCumulativeBytes; // Decoded packet's cumulative size array.
341  // Each element is the number of bytes accumulated
342  // when the corresponding XWMA packet is decoded in
343  // order. The array must have PacketCount elements.
344  UINT32 PacketCount; // Number of XWMA packets submitted. Must be >= 1 and
345  // divide evenly into XAUDIO2_BUFFER.AudioBytes.
347 
348 // Returned by IXAudio2SourceVoice::GetState
349 typedef struct XAUDIO2_VOICE_STATE
350 {
351  void* pCurrentBufferContext; // The pContext value provided in the XAUDIO2_BUFFER
352  // that is currently being processed, or NULL if
353  // there are no buffers in the queue.
354  UINT32 BuffersQueued; // Number of buffers currently queued on the voice
355  // (including the one that is being processed).
356  UINT64 SamplesPlayed; // Total number of samples produced by the voice since
357  // it began processing the current audio stream.
358  // If XAUDIO2_VOICE_NOSAMPLESPLAYED is specified
359  // in the call to IXAudio2SourceVoice::GetState,
360  // this member will not be calculated, saving CPU.
362 
363 // Returned by IXAudio2::GetPerformanceData
364 typedef struct XAUDIO2_PERFORMANCE_DATA
365 {
366  // CPU usage information
367  UINT64 AudioCyclesSinceLastQuery; // CPU cycles spent on audio processing since the
368  // last call to StartEngine or GetPerformanceData.
369  UINT64 TotalCyclesSinceLastQuery; // Total CPU cycles elapsed since the last call
370  // (only counts the CPU XAudio2 is running on).
371  UINT32 MinimumCyclesPerQuantum; // Fewest CPU cycles spent processing any one
372  // audio quantum since the last call.
373  UINT32 MaximumCyclesPerQuantum; // Most CPU cycles spent processing any one
374  // audio quantum since the last call.
375 
376  // Memory usage information
377  UINT32 MemoryUsageInBytes; // Total heap space currently in use.
378 
379  // Audio latency and glitching information
380  UINT32 CurrentLatencyInSamples; // Minimum delay from when a sample is read from a
381  // source buffer to when it reaches the speakers.
382  UINT32 GlitchesSinceEngineStarted; // Audio dropouts since the engine was started.
383 
384  // Data about XAudio2's current workload
385  UINT32 ActiveSourceVoiceCount; // Source voices currently playing.
386  UINT32 TotalSourceVoiceCount; // Source voices currently existing.
387  UINT32 ActiveSubmixVoiceCount; // Submix voices currently playing/existing.
388 
389  UINT32 ActiveResamplerCount; // Resample xAPOs currently active.
390  UINT32 ActiveMatrixMixCount; // MatrixMix xAPOs currently active.
391 
392  // Usage of the hardware XMA decoder (Xbox 360 only)
393  UINT32 ActiveXmaSourceVoices; // Number of source voices decoding XMA data.
394  UINT32 ActiveXmaStreams; // A voice can use more than one XMA stream.
396 
397 // Used in IXAudio2::SetDebugConfiguration
398 typedef struct XAUDIO2_DEBUG_CONFIGURATION
399 {
400  UINT32 TraceMask; // Bitmap of enabled debug message types.
401  UINT32 BreakMask; // Message types that will break into the debugger.
402  BOOL LogThreadID; // Whether to log the thread ID with each message.
403  BOOL LogFileline; // Whether to log the source file and line number.
404  BOOL LogFunctionName; // Whether to log the function name.
405  BOOL LogTiming; // Whether to log message timestamps.
407 
408 // Values for the TraceMask and BreakMask bitmaps. Only ERRORS and WARNINGS
409 // are valid in BreakMask. WARNINGS implies ERRORS, DETAIL implies INFO, and
410 // FUNC_CALLS implies API_CALLS. By default, TraceMask is ERRORS and WARNINGS
411 // and all the other settings are zero.
412 #define XAUDIO2_LOG_ERRORS 0x0001 // For handled errors with serious effects.
413 #define XAUDIO2_LOG_WARNINGS 0x0002 // For handled errors that may be recoverable.
414 #define XAUDIO2_LOG_INFO 0x0004 // Informational chit-chat (e.g. state changes).
415 #define XAUDIO2_LOG_DETAIL 0x0008 // More detailed chit-chat.
416 #define XAUDIO2_LOG_API_CALLS 0x0010 // Public API function entries and exits.
417 #define XAUDIO2_LOG_FUNC_CALLS 0x0020 // Internal function entries and exits.
418 #define XAUDIO2_LOG_TIMING 0x0040 // Delays detected and other timing data.
419 #define XAUDIO2_LOG_LOCKS 0x0080 // Usage of critical sections and mutexes.
420 #define XAUDIO2_LOG_MEMORY 0x0100 // Memory heap usage information.
421 #define XAUDIO2_LOG_STREAMING 0x1000 // Audio streaming information.
422 
423 
424 /**************************************************************************
425  *
426  * IXAudio2: Top-level XAudio2 COM interface.
427  *
428  **************************************************************************/
429 
430  // Use default arguments if compiling as C++
431 #ifdef __cplusplus
432 #define X2DEFAULT(x) =x
433 #else
434 #define X2DEFAULT(x)
435 #endif
436 
437 #undef INTERFACE
438 #define INTERFACE IXAudio2
439 DECLARE_INTERFACE_(IXAudio2, IUnknown)
440 {
441  // NAME: IXAudio2::QueryInterface
442  // DESCRIPTION: Queries for a given COM interface on the XAudio2 object.
443  // Only IID_IUnknown and IID_IXAudio2 are supported.
444  //
445  // ARGUMENTS:
446  // riid - IID of the interface to be obtained.
447  // ppvInterface - Returns a pointer to the requested interface.
448  //
449  STDMETHOD(QueryInterface) (THIS_ REFIID riid, _Outptr_ void** ppvInterface) PURE;
450 
451  // NAME: IXAudio2::AddRef
452  // DESCRIPTION: Adds a reference to the XAudio2 object.
453  //
454  STDMETHOD_(ULONG, AddRef) (THIS) PURE;
455 
456  // NAME: IXAudio2::Release
457  // DESCRIPTION: Releases a reference to the XAudio2 object.
458  //
459  STDMETHOD_(ULONG, Release) (THIS) PURE;
460 
461  // NAME: IXAudio2::RegisterForCallbacks
462  // DESCRIPTION: Adds a new client to receive XAudio2's engine callbacks.
463  //
464  // ARGUMENTS:
465  // pCallback - Callback interface to be called during each processing pass.
466  //
467  STDMETHOD(RegisterForCallbacks) (_In_ IXAudio2EngineCallback* pCallback) PURE;
468 
469  // NAME: IXAudio2::UnregisterForCallbacks
470  // DESCRIPTION: Removes an existing receiver of XAudio2 engine callbacks.
471  //
472  // ARGUMENTS:
473  // pCallback - Previously registered callback interface to be removed.
474  //
475  STDMETHOD_(void, UnregisterForCallbacks) (_In_ IXAudio2EngineCallback* pCallback) PURE;
476 
477  // NAME: IXAudio2::CreateSourceVoice
478  // DESCRIPTION: Creates and configures a source voice.
479  //
480  // ARGUMENTS:
481  // ppSourceVoice - Returns the new object's IXAudio2SourceVoice interface.
482  // pSourceFormat - Format of the audio that will be fed to the voice.
483  // Flags - XAUDIO2_VOICE flags specifying the source voice's behavior.
484  // MaxFrequencyRatio - Maximum SetFrequencyRatio argument to be allowed.
485  // pCallback - Optional pointer to a client-provided callback interface.
486  // pSendList - Optional list of voices this voice should send audio to.
487  // pEffectChain - Optional list of effects to apply to the audio data.
488  //
489  STDMETHOD(CreateSourceVoice) (THIS_ _Outptr_ IXAudio2SourceVoice** ppSourceVoice,
490  _In_ const WAVEFORMATEX* pSourceFormat,
491  UINT32 Flags X2DEFAULT(0),
492  float MaxFrequencyRatio X2DEFAULT(XAUDIO2_DEFAULT_FREQ_RATIO),
493  _In_opt_ IXAudio2VoiceCallback* pCallback X2DEFAULT(NULL),
494  _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
495  _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
496 
497  // NAME: IXAudio2::CreateSubmixVoice
498  // DESCRIPTION: Creates and configures a submix voice.
499  //
500  // ARGUMENTS:
501  // ppSubmixVoice - Returns the new object's IXAudio2SubmixVoice interface.
502  // InputChannels - Number of channels in this voice's input audio data.
503  // InputSampleRate - Sample rate of this voice's input audio data.
504  // Flags - XAUDIO2_VOICE flags specifying the submix voice's behavior.
505  // ProcessingStage - Arbitrary number that determines the processing order.
506  // pSendList - Optional list of voices this voice should send audio to.
507  // pEffectChain - Optional list of effects to apply to the audio data.
508  //
509  STDMETHOD(CreateSubmixVoice) (THIS_ _Outptr_ IXAudio2SubmixVoice** ppSubmixVoice,
510  UINT32 InputChannels, UINT32 InputSampleRate,
511  UINT32 Flags X2DEFAULT(0), UINT32 ProcessingStage X2DEFAULT(0),
512  _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
513  _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
514 
515 
516  // NAME: IXAudio2::CreateMasteringVoice
517  // DESCRIPTION: Creates and configures a mastering voice.
518  //
519  // ARGUMENTS:
520  // ppMasteringVoice - Returns the new object's IXAudio2MasteringVoice interface.
521  // InputChannels - Number of channels in this voice's input audio data.
522  // InputSampleRate - Sample rate of this voice's input audio data.
523  // Flags - XAUDIO2_VOICE flags specifying the mastering voice's behavior.
524  // szDeviceId - Identifier of the device to receive the output audio.
525  // pEffectChain - Optional list of effects to apply to the audio data.
526  // StreamCategory - The audio stream category to use for this mastering voice
527  //
528  STDMETHOD(CreateMasteringVoice) (THIS_ _Outptr_ IXAudio2MasteringVoice** ppMasteringVoice,
531  UINT32 Flags X2DEFAULT(0), _In_opt_z_ LPCWSTR szDeviceId X2DEFAULT(NULL),
532  _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL),
533  _In_ AUDIO_STREAM_CATEGORY StreamCategory X2DEFAULT(AudioCategory_GameEffects)) PURE;
534 
535  // NAME: IXAudio2::StartEngine
536  // DESCRIPTION: Creates and starts the audio processing thread.
537  //
538  STDMETHOD(StartEngine) (THIS) PURE;
539 
540  // NAME: IXAudio2::StopEngine
541  // DESCRIPTION: Stops and destroys the audio processing thread.
542  //
543  STDMETHOD_(void, StopEngine) (THIS) PURE;
544 
545  // NAME: IXAudio2::CommitChanges
546  // DESCRIPTION: Atomically applies a set of operations previously tagged
547  // with a given identifier.
548  //
549  // ARGUMENTS:
550  // OperationSet - Identifier of the set of operations to be applied.
551  //
552  STDMETHOD(CommitChanges) (THIS_ UINT32 OperationSet) PURE;
553 
554  // NAME: IXAudio2::GetPerformanceData
555  // DESCRIPTION: Returns current resource usage details: memory, CPU, etc.
556  //
557  // ARGUMENTS:
558  // pPerfData - Returns the performance data structure.
559  //
560  STDMETHOD_(void, GetPerformanceData) (THIS_ _Out_ XAUDIO2_PERFORMANCE_DATA* pPerfData) PURE;
561 
562  // NAME: IXAudio2::SetDebugConfiguration
563  // DESCRIPTION: Configures XAudio2's debug output (in debug builds only).
564  //
565  // ARGUMENTS:
566  // pDebugConfiguration - Structure describing the debug output behavior.
567  // pReserved - Optional parameter; must be NULL.
568  //
569  STDMETHOD_(void, SetDebugConfiguration) (THIS_ _In_opt_ const XAUDIO2_DEBUG_CONFIGURATION* pDebugConfiguration,
570  _Reserved_ void* pReserved X2DEFAULT(NULL)) PURE;
571 };
572 
573 
574 /**************************************************************************
575  *
576  * IXAudio2Voice: Base voice management interface.
577  *
578  **************************************************************************/
579 
580 #undef INTERFACE
581 #define INTERFACE IXAudio2Voice
582 DECLARE_INTERFACE(IXAudio2Voice)
583 {
584  // These methods are declared in a macro so that the same declarations
585  // can be used in the derived voice types (IXAudio2SourceVoice, etc).
586 
587 #define Declare_IXAudio2Voice_Methods() \
588  \
589  /* NAME: IXAudio2Voice::GetVoiceDetails
590  // DESCRIPTION: Returns the basic characteristics of this voice.
591  //
592  // ARGUMENTS:
593  // pVoiceDetails - Returns the voice's details.
594  */\
595  STDMETHOD_(void, GetVoiceDetails) (THIS_ _Out_ XAUDIO2_VOICE_DETAILS* pVoiceDetails) PURE; \
596  \
597  /* NAME: IXAudio2Voice::SetOutputVoices
598  // DESCRIPTION: Replaces the set of submix/mastering voices that receive
599  // this voice's output.
600  //
601  // ARGUMENTS:
602  // pSendList - Optional list of voices this voice should send audio to.
603  */\
604  STDMETHOD(SetOutputVoices) (THIS_ _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList) PURE; \
605  \
606  /* NAME: IXAudio2Voice::SetEffectChain
607  // DESCRIPTION: Replaces this voice's current effect chain with a new one.
608  //
609  // ARGUMENTS:
610  // pEffectChain - Structure describing the new effect chain to be used.
611  */\
612  STDMETHOD(SetEffectChain) (THIS_ _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain) PURE; \
613  \
614  /* NAME: IXAudio2Voice::EnableEffect
615  // DESCRIPTION: Enables an effect in this voice's effect chain.
616  //
617  // ARGUMENTS:
618  // EffectIndex - Index of an effect within this voice's effect chain.
619  // OperationSet - Used to identify this call as part of a deferred batch.
620  */\
621  STDMETHOD(EnableEffect) (THIS_ UINT32 EffectIndex, \
622  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
623  \
624  /* NAME: IXAudio2Voice::DisableEffect
625  // DESCRIPTION: Disables an effect in this voice's effect chain.
626  //
627  // ARGUMENTS:
628  // EffectIndex - Index of an effect within this voice's effect chain.
629  // OperationSet - Used to identify this call as part of a deferred batch.
630  */\
631  STDMETHOD(DisableEffect) (THIS_ UINT32 EffectIndex, \
632  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
633  \
634  /* NAME: IXAudio2Voice::GetEffectState
635  // DESCRIPTION: Returns the running state of an effect.
636  //
637  // ARGUMENTS:
638  // EffectIndex - Index of an effect within this voice's effect chain.
639  // pEnabled - Returns the enabled/disabled state of the given effect.
640  */\
641  STDMETHOD_(void, GetEffectState) (THIS_ UINT32 EffectIndex, _Out_ BOOL* pEnabled) PURE; \
642  \
643  /* NAME: IXAudio2Voice::SetEffectParameters
644  // DESCRIPTION: Sets effect-specific parameters.
645  //
646  // REMARKS: Unlike IXAPOParameters::SetParameters, this method may
647  // be called from any thread. XAudio2 implements
648  // appropriate synchronization to copy the parameters to the
649  // realtime audio processing thread.
650  //
651  // ARGUMENTS:
652  // EffectIndex - Index of an effect within this voice's effect chain.
653  // pParameters - Pointer to an effect-specific parameters block.
654  // ParametersByteSize - Size of the pParameters array in bytes.
655  // OperationSet - Used to identify this call as part of a deferred batch.
656  */\
657  STDMETHOD(SetEffectParameters) (THIS_ UINT32 EffectIndex, \
658  _In_reads_bytes_(ParametersByteSize) const void* pParameters, \
659  UINT32 ParametersByteSize, \
660  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
661  \
662  /* NAME: IXAudio2Voice::GetEffectParameters
663  // DESCRIPTION: Obtains the current effect-specific parameters.
664  //
665  // ARGUMENTS:
666  // EffectIndex - Index of an effect within this voice's effect chain.
667  // pParameters - Returns the current values of the effect-specific parameters.
668  // ParametersByteSize - Size of the pParameters array in bytes.
669  */\
670  STDMETHOD(GetEffectParameters) (THIS_ UINT32 EffectIndex, \
671  _Out_writes_bytes_(ParametersByteSize) void* pParameters, \
672  UINT32 ParametersByteSize) PURE; \
673  \
674  /* NAME: IXAudio2Voice::SetFilterParameters
675  // DESCRIPTION: Sets this voice's filter parameters.
676  //
677  // ARGUMENTS:
678  // pParameters - Pointer to the filter's parameter structure.
679  // OperationSet - Used to identify this call as part of a deferred batch.
680  */\
681  STDMETHOD(SetFilterParameters) (THIS_ _In_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
682  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
683  \
684  /* NAME: IXAudio2Voice::GetFilterParameters
685  // DESCRIPTION: Returns this voice's current filter parameters.
686  //
687  // ARGUMENTS:
688  // pParameters - Returns the filter parameters.
689  */\
690  STDMETHOD_(void, GetFilterParameters) (THIS_ _Out_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
691  \
692  /* NAME: IXAudio2Voice::SetOutputFilterParameters
693  // DESCRIPTION: Sets the filter parameters on one of this voice's sends.
694  //
695  // ARGUMENTS:
696  // pDestinationVoice - Destination voice of the send whose filter parameters will be set.
697  // pParameters - Pointer to the filter's parameter structure.
698  // OperationSet - Used to identify this call as part of a deferred batch.
699  */\
700  STDMETHOD(SetOutputFilterParameters) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
701  _In_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
702  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
703  \
704  /* NAME: IXAudio2Voice::GetOutputFilterParameters
705  // DESCRIPTION: Returns the filter parameters from one of this voice's sends.
706  //
707  // ARGUMENTS:
708  // pDestinationVoice - Destination voice of the send whose filter parameters will be read.
709  // pParameters - Returns the filter parameters.
710  */\
711  STDMETHOD_(void, GetOutputFilterParameters) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
712  _Out_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
713  \
714  /* NAME: IXAudio2Voice::SetVolume
715  // DESCRIPTION: Sets this voice's overall volume level.
716  //
717  // ARGUMENTS:
718  // Volume - New overall volume level to be used, as an amplitude factor.
719  // OperationSet - Used to identify this call as part of a deferred batch.
720  */\
721  STDMETHOD(SetVolume) (THIS_ float Volume, \
722  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
723  \
724  /* NAME: IXAudio2Voice::GetVolume
725  // DESCRIPTION: Obtains this voice's current overall volume level.
726  //
727  // ARGUMENTS:
728  // pVolume: Returns the voice's current overall volume level.
729  */\
730  STDMETHOD_(void, GetVolume) (THIS_ _Out_ float* pVolume) PURE; \
731  \
732  /* NAME: IXAudio2Voice::SetChannelVolumes
733  // DESCRIPTION: Sets this voice's per-channel volume levels.
734  //
735  // ARGUMENTS:
736  // Channels - Used to confirm the voice's channel count.
737  // pVolumes - Array of per-channel volume levels to be used.
738  // OperationSet - Used to identify this call as part of a deferred batch.
739  */\
740  STDMETHOD(SetChannelVolumes) (THIS_ UINT32 Channels, _In_reads_(Channels) const float* pVolumes, \
741  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
742  \
743  /* NAME: IXAudio2Voice::GetChannelVolumes
744  // DESCRIPTION: Returns this voice's current per-channel volume levels.
745  //
746  // ARGUMENTS:
747  // Channels - Used to confirm the voice's channel count.
748  // pVolumes - Returns an array of the current per-channel volume levels.
749  */\
750  STDMETHOD_(void, GetChannelVolumes) (THIS_ UINT32 Channels, _Out_writes_(Channels) float* pVolumes) PURE; \
751  \
752  /* NAME: IXAudio2Voice::SetOutputMatrix
753  // DESCRIPTION: Sets the volume levels used to mix from each channel of this
754  // voice's output audio to each channel of a given destination
755  // voice's input audio.
756  //
757  // ARGUMENTS:
758  // pDestinationVoice - The destination voice whose mix matrix to change.
759  // SourceChannels - Used to confirm this voice's output channel count
760  // (the number of channels produced by the last effect in the chain).
761  // DestinationChannels - Confirms the destination voice's input channels.
762  // pLevelMatrix - Array of [SourceChannels * DestinationChannels] send
763  // levels. The level used to send from source channel S to destination
764  // channel D should be in pLevelMatrix[S + SourceChannels * D].
765  // OperationSet - Used to identify this call as part of a deferred batch.
766  */\
767  STDMETHOD(SetOutputMatrix) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
768  UINT32 SourceChannels, UINT32 DestinationChannels, \
769  _In_reads_(SourceChannels * DestinationChannels) const float* pLevelMatrix, \
770  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
771  \
772  /* NAME: IXAudio2Voice::GetOutputMatrix
773  // DESCRIPTION: Obtains the volume levels used to send each channel of this
774  // voice's output audio to each channel of a given destination
775  // voice's input audio.
776  //
777  // ARGUMENTS:
778  // pDestinationVoice - The destination voice whose mix matrix to obtain.
779  // SourceChannels - Used to confirm this voice's output channel count
780  // (the number of channels produced by the last effect in the chain).
781  // DestinationChannels - Confirms the destination voice's input channels.
782  // pLevelMatrix - Array of send levels, as above.
783  */\
784  STDMETHOD_(void, GetOutputMatrix) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
785  UINT32 SourceChannels, UINT32 DestinationChannels, \
786  _Out_writes_(SourceChannels * DestinationChannels) float* pLevelMatrix) PURE; \
787  \
788  /* NAME: IXAudio2Voice::DestroyVoice
789  // DESCRIPTION: Destroys this voice, stopping it if necessary and removing
790  // it from the XAudio2 graph.
791  */\
792  STDMETHOD_(void, DestroyVoice) (THIS) PURE
793 
795 };
796 
797 
798 /**************************************************************************
799  *
800  * IXAudio2SourceVoice: Source voice management interface.
801  *
802  **************************************************************************/
803 
804 #undef INTERFACE
805 #define INTERFACE IXAudio2SourceVoice
806 DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
807 {
808  // Methods from IXAudio2Voice base interface
810 
811  // NAME: IXAudio2SourceVoice::Start
812  // DESCRIPTION: Makes this voice start consuming and processing audio.
813  //
814  // ARGUMENTS:
815  // Flags - Flags controlling how the voice should be started.
816  // OperationSet - Used to identify this call as part of a deferred batch.
817  //
818  STDMETHOD(Start) (THIS_ UINT32 Flags X2DEFAULT(0), UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
819 
820  // NAME: IXAudio2SourceVoice::Stop
821  // DESCRIPTION: Makes this voice stop consuming audio.
822  //
823  // ARGUMENTS:
824  // Flags - Flags controlling how the voice should be stopped.
825  // OperationSet - Used to identify this call as part of a deferred batch.
826  //
827  STDMETHOD(Stop) (THIS_ UINT32 Flags X2DEFAULT(0), UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
828 
829  // NAME: IXAudio2SourceVoice::SubmitSourceBuffer
830  // DESCRIPTION: Adds a new audio buffer to this voice's input queue.
831  //
832  // ARGUMENTS:
833  // pBuffer - Pointer to the buffer structure to be queued.
834  // pBufferWMA - Additional structure used only when submitting XWMA data.
835  //
836  STDMETHOD(SubmitSourceBuffer) (THIS_ _In_ const XAUDIO2_BUFFER* pBuffer, _In_opt_ const XAUDIO2_BUFFER_WMA* pBufferWMA X2DEFAULT(NULL)) PURE;
837 
838  // NAME: IXAudio2SourceVoice::FlushSourceBuffers
839  // DESCRIPTION: Removes all pending audio buffers from this voice's queue.
840  //
841  STDMETHOD(FlushSourceBuffers) (THIS) PURE;
842 
843  // NAME: IXAudio2SourceVoice::Discontinuity
844  // DESCRIPTION: Notifies the voice of an intentional break in the stream of
845  // audio buffers (e.g. the end of a sound), to prevent XAudio2
846  // from interpreting an empty buffer queue as a glitch.
847  //
848  STDMETHOD(Discontinuity) (THIS) PURE;
849 
850  // NAME: IXAudio2SourceVoice::ExitLoop
851  // DESCRIPTION: Breaks out of the current loop when its end is reached.
852  //
853  // ARGUMENTS:
854  // OperationSet - Used to identify this call as part of a deferred batch.
855  //
856  STDMETHOD(ExitLoop) (THIS_ UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
857 
858  // NAME: IXAudio2SourceVoice::GetState
859  // DESCRIPTION: Returns the number of buffers currently queued on this voice,
860  // the pContext value associated with the currently processing
861  // buffer (if any), and other voice state information.
862  //
863  // ARGUMENTS:
864  // pVoiceState - Returns the state information.
865  // Flags - Flags controlling what voice state is returned.
866  //
867  STDMETHOD_(void, GetState) (THIS_ _Out_ XAUDIO2_VOICE_STATE* pVoiceState, UINT32 Flags X2DEFAULT(0)) PURE;
868 
869  // NAME: IXAudio2SourceVoice::SetFrequencyRatio
870  // DESCRIPTION: Sets this voice's frequency adjustment, i.e. its pitch.
871  //
872  // ARGUMENTS:
873  // Ratio - Frequency change, expressed as source frequency / target frequency.
874  // OperationSet - Used to identify this call as part of a deferred batch.
875  //
876  STDMETHOD(SetFrequencyRatio) (THIS_ float Ratio,
877  UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
878 
879  // NAME: IXAudio2SourceVoice::GetFrequencyRatio
880  // DESCRIPTION: Returns this voice's current frequency adjustment ratio.
881  //
882  // ARGUMENTS:
883  // pRatio - Returns the frequency adjustment.
884  //
885  STDMETHOD_(void, GetFrequencyRatio) (THIS_ _Out_ float* pRatio) PURE;
886 
887  // NAME: IXAudio2SourceVoice::SetSourceSampleRate
888  // DESCRIPTION: Reconfigures this voice to treat its source data as being
889  // at a different sample rate than the original one specified
890  // in CreateSourceVoice's pSourceFormat argument.
891  //
892  // ARGUMENTS:
893  // UINT32 - The intended sample rate of further submitted source data.
894  //
895  STDMETHOD(SetSourceSampleRate) (THIS_ UINT32 NewSourceSampleRate) PURE;
896 };
897 
898 
899 /**************************************************************************
900  *
901  * IXAudio2SubmixVoice: Submixing voice management interface.
902  *
903  **************************************************************************/
904 
905 #undef INTERFACE
906 #define INTERFACE IXAudio2SubmixVoice
908 {
909  // Methods from IXAudio2Voice base interface
911 
912  // There are currently no methods specific to submix voices.
913 };
914 
915 
916 /**************************************************************************
917  *
918  * IXAudio2MasteringVoice: Mastering voice management interface.
919  *
920  **************************************************************************/
921 
922 #undef INTERFACE
923 #define INTERFACE IXAudio2MasteringVoice
924 DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
925 {
926  // Methods from IXAudio2Voice base interface
928 
929  // NAME: IXAudio2MasteringVoice::GetChannelMask
930  // DESCRIPTION: Returns the channel mask for this voice
931  //
932  // ARGUMENTS:
933  // pChannelMask - returns the channel mask for this voice. This corresponds
934  // to the dwChannelMask member of WAVEFORMATEXTENSIBLE.
935  //
936  STDMETHOD(GetChannelMask) (THIS_ _Out_ DWORD* pChannelmask) PURE;
937 };
938 
939 
940 /**************************************************************************
941  *
942  * IXAudio2EngineCallback: Client notification interface for engine events.
943  *
944  * REMARKS: Contains methods to notify the client when certain events happen
945  * in the XAudio2 engine. This interface should be implemented by
946  * the client. XAudio2 will call these methods via the interface
947  * pointer provided by the client when it calls
948  * IXAudio2::RegisterForCallbacks.
949  *
950  **************************************************************************/
951 
952 #undef INTERFACE
953 #define INTERFACE IXAudio2EngineCallback
955 {
956  // Called by XAudio2 just before an audio processing pass begins.
957  STDMETHOD_(void, OnProcessingPassStart) (THIS) PURE;
958 
959  // Called just after an audio processing pass ends.
960  STDMETHOD_(void, OnProcessingPassEnd) (THIS) PURE;
961 
962  // Called in the event of a critical system error which requires XAudio2
963  // to be closed down and restarted. The error code is given in Error.
964  STDMETHOD_(void, OnCriticalError) (THIS_ HRESULT Error) PURE;
965 };
966 
967 
968 /**************************************************************************
969  *
970  * IXAudio2VoiceCallback: Client notification interface for voice events.
971  *
972  * REMARKS: Contains methods to notify the client when certain events happen
973  * in an XAudio2 voice. This interface should be implemented by the
974  * client. XAudio2 will call these methods via an interface pointer
975  * provided by the client in the IXAudio2::CreateSourceVoice call.
976  *
977  **************************************************************************/
978 
979 #undef INTERFACE
980 #define INTERFACE IXAudio2VoiceCallback
981 DECLARE_INTERFACE(IXAudio2VoiceCallback)
982 {
983  // Called just before this voice's processing pass begins.
984  STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE;
985 
986  // Called just after this voice's processing pass ends.
987  STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) PURE;
988 
989  // Called when this voice has just finished playing a buffer stream
990  // (as marked with the XAUDIO2_END_OF_STREAM flag on the last buffer).
991  STDMETHOD_(void, OnStreamEnd) (THIS) PURE;
992 
993  // Called when this voice is about to start processing a new buffer.
994  STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext) PURE;
995 
996  // Called when this voice has just finished processing a buffer.
997  // The buffer can now be reused or destroyed.
998  STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext) PURE;
999 
1000  // Called when this voice has just reached the end position of a loop.
1001  STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext) PURE;
1002 
1003  // Called in the event of a critical error during voice processing,
1004  // such as a failing xAPO or an error from the hardware XMA decoder.
1005  // The voice may have to be destroyed and re-created to recover from
1006  // the error. The callback arguments report which buffer was being
1007  // processed when the error occurred, and its HRESULT code.
1008  STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) PURE;
1009 };
1010 
1011 
1012 /**************************************************************************
1013  *
1014  * Macros to make it easier to use the XAudio2 COM interfaces in C code.
1015  *
1016  **************************************************************************/
1017 
1018 #ifndef __cplusplus
1019 
1020  // IXAudio2
1021 #define IXAudio2_QueryInterface(This,riid,ppvInterface) ((This)->lpVtbl->QueryInterface(This,riid,ppvInterface))
1022 #define IXAudio2_AddRef(This) ((This)->lpVtbl->AddRef(This))
1023 #define IXAudio2_Release(This) ((This)->lpVtbl->Release(This))
1024 #define IXAudio2_CreateSourceVoice(This,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) ((This)->lpVtbl->CreateSourceVoice(This,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain))
1025 #define IXAudio2_CreateSubmixVoice(This,ppSubmixVoice,InputChannels,InputSampleRate,Flags,ProcessingStage,pSendList,pEffectChain) ((This)->lpVtbl->CreateSubmixVoice(This,ppSubmixVoice,InputChannels,InputSampleRate,Flags,ProcessingStage,pSendList,pEffectChain))
1026 #define IXAudio2_CreateMasteringVoice(This,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceId,pEffectChain,StreamCategory) ((This)->lpVtbl->CreateMasteringVoice(This,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceId,pEffectChain,StreamCategory))
1027 #define IXAudio2_StartEngine(This) ((This)->lpVtbl->StartEngine(This))
1028 #define IXAudio2_StopEngine(This) ((This)->lpVtbl->StopEngine(This))
1029 #define IXAudio2_CommitChanges(This,OperationSet) ((This)->lpVtbl->CommitChanges(This,OperationSet))
1030 #define IXAudio2_GetPerformanceData(This,pPerfData) ((This)->lpVtbl->GetPerformanceData(This,pPerfData))
1031 #define IXAudio2_SetDebugConfiguration(This,pDebugConfiguration,pReserved) ((This)->lpVtbl->SetDebugConfiguration(This,pDebugConfiguration,pReserved))
1032 
1033 // IXAudio2Voice
1034 #define IXAudio2Voice_GetVoiceDetails(This,pVoiceDetails) ((This)->lpVtbl->GetVoiceDetails(This,pVoiceDetails))
1035 #define IXAudio2Voice_SetOutputVoices(This,pSendList) ((This)->lpVtbl->SetOutputVoices(This,pSendList))
1036 #define IXAudio2Voice_SetEffectChain(This,pEffectChain) ((This)->lpVtbl->SetEffectChain(This,pEffectChain))
1037 #define IXAudio2Voice_EnableEffect(This,EffectIndex,OperationSet) ((This)->lpVtbl->EnableEffect(This,EffectIndex,OperationSet))
1038 #define IXAudio2Voice_DisableEffect(This,EffectIndex,OperationSet) ((This)->lpVtbl->DisableEffect(This,EffectIndex,OperationSet))
1039 #define IXAudio2Voice_GetEffectState(This,EffectIndex,pEnabled) ((This)->lpVtbl->GetEffectState(This,EffectIndex,pEnabled))
1040 #define IXAudio2Voice_SetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize, OperationSet) ((This)->lpVtbl->SetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize,OperationSet))
1041 #define IXAudio2Voice_GetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize) ((This)->lpVtbl->GetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize))
1042 #define IXAudio2Voice_SetFilterParameters(This,pParameters,OperationSet) ((This)->lpVtbl->SetFilterParameters(This,pParameters,OperationSet))
1043 #define IXAudio2Voice_GetFilterParameters(This,pParameters) ((This)->lpVtbl->GetFilterParameters(This,pParameters))
1044 #define IXAudio2Voice_SetOutputFilterParameters(This,pDestinationVoice,pParameters,OperationSet) ((This)->lpVtbl->SetOutputFilterParameters(This,pDestinationVoice,pParameters,OperationSet))
1045 #define IXAudio2Voice_GetOutputFilterParameters(This,pDestinationVoice,pParameters) ((This)->lpVtbl->GetOutputFilterParameters(This,pDestinationVoice,pParameters))
1046 #define IXAudio2Voice_SetVolume(This,Volume,OperationSet) ((This)->lpVtbl->SetVolume(This,Volume,OperationSet))
1047 #define IXAudio2Voice_GetVolume(This,pVolume) ((This)->lpVtbl->GetVolume(This,pVolume))
1048 #define IXAudio2Voice_SetChannelVolumes(This,Channels,pVolumes,OperationSet) ((This)->lpVtbl->SetChannelVolumes(This,Channels,pVolumes,OperationSet))
1049 #define IXAudio2Voice_GetChannelVolumes(This,Channels,pVolumes) ((This)->lpVtbl->GetChannelVolumes(This,Channels,pVolumes))
1050 #define IXAudio2Voice_SetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix,OperationSet) ((This)->lpVtbl->SetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix,OperationSet))
1051 #define IXAudio2Voice_GetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix) ((This)->lpVtbl->GetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix))
1052 #define IXAudio2Voice_DestroyVoice(This) ((This)->lpVtbl->DestroyVoice(This))
1053 
1054 // IXAudio2SourceVoice
1055 #define IXAudio2SourceVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
1056 #define IXAudio2SourceVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
1057 #define IXAudio2SourceVoice_SetEffectChain IXAudio2Voice_SetEffectChain
1058 #define IXAudio2SourceVoice_EnableEffect IXAudio2Voice_EnableEffect
1059 #define IXAudio2SourceVoice_DisableEffect IXAudio2Voice_DisableEffect
1060 #define IXAudio2SourceVoice_GetEffectState IXAudio2Voice_GetEffectState
1061 #define IXAudio2SourceVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
1062 #define IXAudio2SourceVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
1063 #define IXAudio2SourceVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
1064 #define IXAudio2SourceVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
1065 #define IXAudio2SourceVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
1066 #define IXAudio2SourceVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
1067 #define IXAudio2SourceVoice_SetVolume IXAudio2Voice_SetVolume
1068 #define IXAudio2SourceVoice_GetVolume IXAudio2Voice_GetVolume
1069 #define IXAudio2SourceVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
1070 #define IXAudio2SourceVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
1071 #define IXAudio2SourceVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
1072 #define IXAudio2SourceVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
1073 #define IXAudio2SourceVoice_DestroyVoice IXAudio2Voice_DestroyVoice
1074 #define IXAudio2SourceVoice_Start(This,Flags,OperationSet) ((This)->lpVtbl->Start(This,Flags,OperationSet))
1075 #define IXAudio2SourceVoice_Stop(This,Flags,OperationSet) ((This)->lpVtbl->Stop(This,Flags,OperationSet))
1076 #define IXAudio2SourceVoice_SubmitSourceBuffer(This,pBuffer,pBufferWMA) ((This)->lpVtbl->SubmitSourceBuffer(This,pBuffer,pBufferWMA))
1077 #define IXAudio2SourceVoice_FlushSourceBuffers(This) ((This)->lpVtbl->FlushSourceBuffers(This))
1078 #define IXAudio2SourceVoice_Discontinuity(This) ((This)->lpVtbl->Discontinuity(This))
1079 #define IXAudio2SourceVoice_ExitLoop(This,OperationSet) ((This)->lpVtbl->ExitLoop(This,OperationSet))
1080 #define IXAudio2SourceVoice_GetState(This,pVoiceState,Flags) ((This)->lpVtbl->GetState(This,pVoiceState,Flags))
1081 #define IXAudio2SourceVoice_SetFrequencyRatio(This,Ratio,OperationSet) ((This)->lpVtbl->SetFrequencyRatio(This,Ratio,OperationSet))
1082 #define IXAudio2SourceVoice_GetFrequencyRatio(This,pRatio) ((This)->lpVtbl->GetFrequencyRatio(This,pRatio))
1083 #define IXAudio2SourceVoice_SetSourceSampleRate(This,NewSourceSampleRate) ((This)->lpVtbl->SetSourceSampleRate(This,NewSourceSampleRate))
1084 
1085 // IXAudio2SubmixVoice
1086 #define IXAudio2SubmixVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
1087 #define IXAudio2SubmixVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
1088 #define IXAudio2SubmixVoice_SetEffectChain IXAudio2Voice_SetEffectChain
1089 #define IXAudio2SubmixVoice_EnableEffect IXAudio2Voice_EnableEffect
1090 #define IXAudio2SubmixVoice_DisableEffect IXAudio2Voice_DisableEffect
1091 #define IXAudio2SubmixVoice_GetEffectState IXAudio2Voice_GetEffectState
1092 #define IXAudio2SubmixVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
1093 #define IXAudio2SubmixVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
1094 #define IXAudio2SubmixVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
1095 #define IXAudio2SubmixVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
1096 #define IXAudio2SubmixVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
1097 #define IXAudio2SubmixVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
1098 #define IXAudio2SubmixVoice_SetVolume IXAudio2Voice_SetVolume
1099 #define IXAudio2SubmixVoice_GetVolume IXAudio2Voice_GetVolume
1100 #define IXAudio2SubmixVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
1101 #define IXAudio2SubmixVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
1102 #define IXAudio2SubmixVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
1103 #define IXAudio2SubmixVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
1104 #define IXAudio2SubmixVoice_DestroyVoice IXAudio2Voice_DestroyVoice
1105 
1106 /* IXAudio2MasteringVoice */
1107 #define IXAudio2MasteringVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
1108 #define IXAudio2MasteringVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
1109 #define IXAudio2MasteringVoice_SetEffectChain IXAudio2Voice_SetEffectChain
1110 #define IXAudio2MasteringVoice_EnableEffect IXAudio2Voice_EnableEffect
1111 #define IXAudio2MasteringVoice_DisableEffect IXAudio2Voice_DisableEffect
1112 #define IXAudio2MasteringVoice_GetEffectState IXAudio2Voice_GetEffectState
1113 #define IXAudio2MasteringVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
1114 #define IXAudio2MasteringVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
1115 #define IXAudio2MasteringVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
1116 #define IXAudio2MasteringVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
1117 #define IXAudio2MasteringVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
1118 #define IXAudio2MasteringVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
1119 #define IXAudio2MasteringVoice_SetVolume IXAudio2Voice_SetVolume
1120 #define IXAudio2MasteringVoice_GetVolume IXAudio2Voice_GetVolume
1121 #define IXAudio2MasteringVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
1122 #define IXAudio2MasteringVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
1123 #define IXAudio2MasteringVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
1124 #define IXAudio2MasteringVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
1125 #define IXAudio2MasteringVoice_DestroyVoice IXAudio2Voice_DestroyVoice
1126 #define IXAudio2MasteringVoice_GetChannelMask(This,pChannelMask) ((This)->lpVtbl->GetChannelMask(This,pChannelMask))
1127 
1128 #endif /* #ifndef __cplusplus */
1129 
1130 
1131 /**************************************************************************
1132  *
1133  * Utility functions used to convert from pitch in semitones and volume
1134  * in decibels to the frequency and amplitude ratio units used by XAudio2.
1135  * These are only defined if the client #defines XAUDIO2_HELPER_FUNCTIONS
1136  * prior to #including xaudio2.h.
1137  *
1138  **************************************************************************/
1139 
1140 #ifdef XAUDIO2_HELPER_FUNCTIONS
1141 
1142 #define _USE_MATH_DEFINES /* Make math.h define M_PI */
1143 #include <math.h> /* For powf, log10f, sinf and asinf */
1144 
1145 /* Calculate the argument to SetVolume from a decibel value */
1146 static INLINE float XAudio2DecibelsToAmplitudeRatio(float Decibels)
1147 {
1148  return powf(10.0f, Decibels / 20.0f);
1149 }
1150 
1151 /* Recover a volume in decibels from an amplitude factor */
1152 static INLINE float XAudio2AmplitudeRatioToDecibels(float Volume)
1153 {
1154  if (Volume == 0)
1155  return -3.402823466e+38f; /* Smallest float value (-FLT_MAX) */
1156  return 20.0f * log10f(Volume);
1157 }
1158 
1159 /* Calculate the argument to SetFrequencyRatio from a semitone value */
1160 static INLINE float XAudio2SemitonesToFrequencyRatio(float Semitones)
1161 {
1162  /* FrequencyRatio = 2 ^ Octaves
1163  * = 2 ^ (Semitones / 12)
1164  */
1165  return powf(2.0f, Semitones / 12.0f);
1166 }
1167 
1168 /* Recover a pitch in semitones from a frequency ratio */
1169 static INLINE float XAudio2FrequencyRatioToSemitones(float FrequencyRatio)
1170 {
1171  /* Semitones = 12 * log2(FrequencyRatio)
1172  * = 12 * log2(10) * log10(FrequencyRatio)
1173  */
1174  return 39.86313713864835f * log10f(FrequencyRatio);
1175 }
1176 
1177 /* Convert from filter cutoff frequencies expressed in Hertz to the radian
1178  * frequency values used in XAUDIO2_FILTER_PARAMETERS.Frequency, state-variable
1179  * filter types only. Use XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types.
1180  * Note that the highest CutoffFrequency supported is SampleRate/6.
1181  * Higher values of CutoffFrequency will return XAUDIO2_MAX_FILTER_FREQUENCY.
1182  */
1183 static INLINE float XAudio2CutoffFrequencyToRadians(float CutoffFrequency, UINT32 SampleRate)
1184 {
1185  if ((UINT32)(CutoffFrequency * 6.0f) >= SampleRate)
1186  return XAUDIO2_MAX_FILTER_FREQUENCY;
1187  return 2.0f * sinf((float)M_PI * CutoffFrequency / SampleRate);
1188 }
1189 
1190 /* Convert from radian frequencies back to absolute frequencies in Hertz */
1191 static INLINE float XAudio2RadiansToCutoffFrequency(float Radians, float SampleRate)
1192 {
1193  return SampleRate * asinf(Radians / 2.0f) / (float)M_PI;
1194 }
1195 
1196 /* Convert from filter cutoff frequencies expressed in Hertz to the filter
1197  * coefficients used with XAUDIO2_FILTER_PARAMETERS.Frequency,
1198  * LowPassOnePoleFilter and HighPassOnePoleFilter filter types only.
1199  * Use XAudio2CutoffFrequencyToRadians() for state-variable filter types.
1200  */
1201 static INLINE float XAudio2CutoffFrequencyToOnePoleCoefficient(float CutoffFrequency, UINT32 SampleRate)
1202 {
1203  if ((UINT32)CutoffFrequency >= SampleRate)
1204  return XAUDIO2_MAX_FILTER_FREQUENCY;
1205  return (1.0f - powf(1.0f - 2.0f * CutoffFrequency / SampleRate, 2.0f));
1206 }
1207 
1208 
1209 #endif // #ifdef XAUDIO2_HELPER_FUNCTIONS
1210 
1211 
1212 /**************************************************************************
1213  *
1214  * XAudio2Create: Top-level function that creates an XAudio2 instance.
1215  *
1216  * ARGUMENTS:
1217  *
1218  * Flags - Flags specifying the XAudio2 object's behavior.
1219  *
1220  * XAudio2Processor - An XAUDIO2_PROCESSOR value that specifies the
1221  * hardware threads (Xbox) or processors (Windows) that XAudio2
1222  * will use. Note that XAudio2 supports concurrent processing on
1223  * multiple threads, using any combination of XAUDIO2_PROCESSOR
1224  * flags. The values are platform-specific; platform-independent
1225  * code can use XAUDIO2_DEFAULT_PROCESSOR to use the default on
1226  * each platform.
1227  *
1228  **************************************************************************/
1229 
1230 #ifdef __cplusplus__
1231 
1232 #if (defined XAUDIO2_EXPORT)
1233  /* We're building xaudio2.dll */
1234 #define XAUDIO2_STDAPI extern "C" __declspec(dllexport) HRESULT __stdcall
1235 #else
1236  /* We're an xaudio2 client */
1237 #define XAUDIO2_STDAPI extern "C" __declspec(dllimport) HRESULT __stdcall
1238 #endif
1239 
1240 #else
1241 
1242  /* Modified for C support */
1243 
1244 #if (defined XAUDIO2_EXPORT)
1245  /* We're building xaudio2.dll */
1246 #define XAUDIO2_STDAPI __declspec(dllexport) HRESULT __stdcall
1247 #else
1248  /* We're an xaudio2 client */
1249 #define XAUDIO2_STDAPI __declspec(dllimport) HRESULT __stdcall
1250 #endif
1251 
1252 #endif
1253 
1254 #if (NTDDI_VERSION >= NTDDI_WIN10_RS5) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
1255 XAUDIO2_STDAPI XAudio2CreateWithVersionInfo(_Outptr_ IXAudio2** ppXAudio2,
1256  UINT32 Flags X2DEFAULT(0),
1258  DWORD ntddiVersion X2DEFAULT(NTDDI_VERSION));
1259 
1260 static INLINE HRESULT XAudio2Create(_Outptr_ IXAudio2** ppXAudio2,
1261  UINT32 Flags X2DEFAULT(0),
1263 {
1264  /* When compiled for RS5 or later, try to invoke XAudio2CreateWithVersionInfo.
1265  * Need to use LoadLibrary in case the app is running on an older OS. */
1266  typedef HRESULT(__stdcall *XAudio2CreateWithVersionInfoFunc)(_Outptr_ IXAudio2**, UINT32, XAUDIO2_PROCESSOR, DWORD);
1267  typedef HRESULT(__stdcall *XAudio2CreateInfoFunc)(_Outptr_ IXAudio2**, UINT32, XAUDIO2_PROCESSOR);
1268 
1269  static HMODULE s_dllInstance = NULL;
1270  static XAudio2CreateWithVersionInfoFunc s_pfnAudio2CreateWithVersion = NULL;
1271  static XAudio2CreateInfoFunc s_pfnAudio2Create = NULL;
1272 
1273  if (s_dllInstance == NULL)
1274  {
1275  s_dllInstance = LoadLibraryEx(XAUDIO2_DLL, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
1276  if (s_dllInstance == NULL)
1277  return HRESULT_FROM_WIN32(GetLastError());
1278 
1279  s_pfnAudio2CreateWithVersion = (XAudio2CreateWithVersionInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2CreateWithVersionInfo");
1280  if (s_pfnAudio2CreateWithVersion == NULL)
1281  {
1282  s_pfnAudio2Create = (XAudio2CreateInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2Create");
1283  if (s_pfnAudio2Create == NULL)
1284  return HRESULT_FROM_WIN32(GetLastError());
1285  }
1286  }
1287 
1288  if (s_pfnAudio2CreateWithVersion != NULL)
1289  return (*s_pfnAudio2CreateWithVersion)(ppXAudio2, Flags, XAudio2Processor, NTDDI_VERSION);
1290  return (*s_pfnAudio2Create)(ppXAudio2, Flags, XAudio2Processor);
1291 }
1292 #else
1293 /* RS4 or older, or not a desktop app */
1294 XAUDIO2_STDAPI XAudio2Create(_Outptr_ IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0),
1296 #endif
1297 
1298 /* Undo the #pragma pack(push, 1) directive at the top of this file */
1299 #pragma pack(pop)
1300 
1301 #endif /* #ifndef GUID_DEFS_ONLY */
1302 
1303 #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE) */
1304 #pragma endregion
1305 
1306 #endif /* #ifndef __XAUDIO2_INCLUDED__ */
UINT32 PlayBegin
Definition: xaudio27.h:178
XAUDIO2_FILTER_TYPE
Definition: xaudio27.h:131
#define Declare_IXAudio2Voice_Methods()
byte Error
Definition: jsonsax_full.c:107
enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER XAUDIO2_PROCESSOR
#define INLINE
Definition: retro_inline.h:35
UINT32 AudioBytes
Definition: xaudio27.h:176
struct XAUDIO2_BUFFER XAUDIO2_BUFFER
Definition: xaudio27.h:127
Ιστορικό Εικόνα Πληροφορίες Όλοι Οι Χρήστες Χειρίζονται Το Μενού Αριστερό Αναλογικό Αριστερό Αναλογικό Αριστερό Αναλογικό Y Αριστερό Αναλογικό Δεξί Αναλογικό X Δεξί Αναλογικό Δεξί Αναλογικό Y Δεξί Αναλογικό Σκανδάλη Όπλου Όπλο Aux A Όπλο Aux C Όπλο Select Όπλο D pad Κάτω Όπλο D pad Δεξιά Νεκρή Ζώνη Αναλογικού Σύνδεση Όλων Λήξη Χρόνου Σύνδεσης Hide Unbound Core Input Descriptors Κατάλογος Συσκευών Κατάλογος Ποντικιού Duty Cycle Keyboard Gamepad Mapping Enable Κουμπί B(κάτω)" ) MSG_HASH( MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN
interface __declspec(uuid("A410B984-9839-4819-A0BE-2856AE6B3ADB")) IXAPO
OPAQUE XAUDIO2_VOICE_STATE XAUDIO2_VOICE_STATE
Definition: xaudio27.h:165
uint64_t UINT64
Definition: coretypes.h:8
OPAQUE XAUDIO2_EFFECT_DESCRIPTOR XAUDIO2_EFFECT_DESCRIPTOR
Definition: xaudio27.h:161
GLfloat f
Definition: glext.h:8207
OPAQUE XAUDIO2_FILTER_PARAMETERS XAUDIO2_FILTER_PARAMETERS
Definition: xaudio27.h:163
void * pContext
Definition: xaudio27.h:183
OPAQUE XAUDIO2_VOICE_DETAILS XAUDIO2_VOICE_DETAILS
Definition: xaudio27.h:159
typedef HRESULT(WINAPI *PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)(_In_ const D3D12_ROOT_SIGNATURE_DESC *pRootSignature
#define M_PI
Definition: compat.h:190
_Outptr_ IUnknown ** pEffect
Definition: xapofx.h:175
OPAQUE IXAudio2EngineCallback IXAudio2EngineCallback
Definition: xaudio27.h:168
DECLARE_INTERFACE(IXAudio2VoiceCallback)
Definition: xaudio27.h:189
#define NULL
Pointer to 0.
Definition: gctypes.h:65
OPAQUE XAUDIO2_BUFFER_WMA XAUDIO2_BUFFER_WMA
Definition: xaudio27.h:164
static INLINE HRESULT XAudio2Create(IXAudio2 **ppXAudio2, UINT32 flags, XAUDIO2_PROCESSOR proc)
Definition: xaudio27.h:339
#define X2DEFAULT(x)
Definition: xaudio27.h:32
OPAQUE IXAudio2SubmixVoice IXAudio2SubmixVoice
Definition: xaudio27.h:169
Definition: xaudio27.h:133
OPAQUE XAUDIO2_DEBUG_CONFIGURATION XAUDIO2_DEBUG_CONFIGURATION
Definition: xaudio27.h:167
#define A(i)
Definition: ecp_curves.c:884
OPAQUE XAUDIO2_PERFORMANCE_DATA XAUDIO2_PERFORMANCE_DATA
Definition: xaudio27.h:166
UINT32 LoopCount
Definition: xaudio27.h:182
UINT32 LoopLength
Definition: xaudio27.h:181
UINT32 LoopBegin
Definition: xaudio27.h:180
static INLINE ULONG Release(void *object)
Definition: dxgi_common.h:253
UINT32 Flags
Definition: xaudio27.h:175
unsigned int BOOL
Definition: gctypes.h:51
uint32_t UINT32
Definition: coretypes.h:10
const BYTE * pAudioData
Definition: xaudio27.h:177
OPAQUE XAUDIO2_VOICE_SENDS XAUDIO2_VOICE_SENDS
Definition: xaudio27.h:160
#define XAUDIO2_DEFAULT_CHANNELS
Definition: xaudio27.h:90
DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
Definition: xaudio27.h:247
Definition: audiodefs.h:40
OPAQUE XAUDIO2_EFFECT_CHAIN XAUDIO2_EFFECT_CHAIN
Definition: xaudio27.h:162
#define XAUDIO2_COMMIT_NOW
Definition: xaudio27.h:89
Type
Type of JSON value.
Definition: rapidjson.h:603
DEFINE_IID_X(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb)
UINT32 PlayLength
Definition: xaudio27.h:179
Definition: xaudio27.h:173
#define XAUDIO2_DEFAULT_SAMPLERATE
Definition: xaudio27.h:91
#define F(x, y, z)
Definition: xaudio27.h:132
#define XAUDIO2_DEFAULT_FREQ_RATIO
Definition: xaudio27.h:86
Definition: xaudio27.h:134