RetroArch
xapo.h
Go to the documentation of this file.
1 /*-========================================================================-_
2  | - XAPO - |
3  | Copyright (c) Microsoft Corporation. All rights reserved. |
4  |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
5  |PROJECT: XAPO MODEL: Unmanaged User-mode |
6  |VERSION: 1.0 EXCEPT: No Exceptions |
7  |CLASS: N / A MINREQ: WinXP, Xbox360 |
8  |BASE: N / A DIALECT: MSC++ 14.00 |
9  |>------------------------------------------------------------------------<|
10  | DUTY: Cross-platform Audio Processing Object interfaces |
11  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
12  NOTES:
13  1. Definition of terms:
14  DSP: Digital Signal Processing.
15 
16  CBR: Constant BitRate -- DSP that consumes a constant number of
17  input samples to produce an output sample.
18  For example, a 22kHz to 44kHz resampler is CBR DSP.
19  Even though the number of input to output samples differ,
20  the ratio between input to output rate remains constant.
21  All user-defined XAPOs are assumed to be CBR as
22  XAudio2 only allows CBR DSP to be added to an effect chain.
23 
24  XAPO: Cross-platform Audio Processing Object --
25  a thin wrapper that manages DSP code, allowing it
26  to be easily plugged into an XAudio2 effect chain.
27 
28  Frame: A block of samples, one per channel,
29  to be played simultaneously.
30  E.g. a mono stream has one sample per frame.
31 
32  In-Place: Processing such that the input buffer equals the
33  output buffer (i.e. input data modified directly).
34  This form of processing is generally more efficient
35  than using separate memory for input and output.
36  However, an XAPO may not perform format conversion
37  when processing in-place.
38 
39  2. XAPO member variables are divided into three classifications:
40  Immutable: Set once via IXAPO::Initialize and remain
41  constant during the lifespan of the XAPO.
42 
43  Locked: May change before the XAPO is locked via
44  IXAPO::LockForProcess but remain constant
45  until IXAPO::UnlockForProcess is called.
46 
47  Dynamic: May change from one processing pass to the next,
48  usually via IXAPOParameters::SetParameters.
49  XAPOs should assign reasonable defaults to their dynamic
50  variables during IXAPO::Initialize/LockForProcess so
51  that calling IXAPOParameters::SetParameters is not
52  required before processing begins.
53 
54  When implementing an XAPO, determine the type of each variable and
55  initialize them in the appropriate method. Immutable variables are
56  generally preferable over locked which are preferable over dynamic.
57  That is, one should strive to minimize XAPO state changes for
58  best performance, maintainability, and ease of use.
59 
60  3. To minimize glitches, the realtime audio processing thread must
61  not block. XAPO methods called by the realtime thread are commented
62  as non-blocking and therefore should not use blocking synchronization,
63  allocate memory, access the disk, etc. The XAPO interfaces were
64  designed to allow an effect implementer to move such operations
65  into other methods called on an application controlled thread.
66 
67  4. Extending functionality is accomplished through the addition of new
68  COM interfaces. For example, if a new member is added to a parameter
69  structure, a new interface using the new structure should be added,
70  leaving the original interface unchanged.
71  This ensures consistent communication between future versions of
72  XAudio2 and various versions of XAPOs that may exist in an application.
73 
74  5. All audio data is interleaved in XAudio2.
75  The default audio format for an effect chain is WAVE_FORMAT_IEEE_FLOAT.
76 
77  6. User-defined XAPOs should assume all input and output buffers are
78  16-byte aligned.
79 
80  7. See XAPOBase.h for an XAPO base class which provides a default
81  implementation for most of the interface methods defined below. */
82 
83 #ifdef _MSC_VER
84 #pragma once
85 #endif
86 
87 #include <sdkddkver.h>
88 
89 #if(_WIN32_WINNT < _WIN32_WINNT_WIN8)
90 #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."
91 #endif // (_WIN32_WINNT < _WIN32_WINNT_WIN8)
92 
93 /*#include <winapifamily.h>*/
94 
95 /*#pragma region Application Family*/
96 /*#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE)*/
97 
98 //--------------<D-E-F-I-N-I-T-I-O-N-S>-------------------------------------//
99 
100 #include <basetyps.h>
101 
102 // XAPO interface IDs
103 interface __declspec(uuid("A410B984-9839-4819-A0BE-2856AE6B3ADB")) IXAPO;
104 interface __declspec(uuid("26D95C66-80F2-499A-AD54-5AE7F01C6D98")) IXAPOParameters;
105 
106 
107 #if !defined(GUID_DEFS_ONLY) // ignore rest if only GUID definitions requested
108  #include <windows.h>
109  #include <objbase.h>
110  #include <mmreg.h> // for WAVEFORMATEX etc.
111 
112  // XAPO error codes
113  #define FACILITY_XAPO 0x897
114  #define XAPO_E_FORMAT_UNSUPPORTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_XAPO, 0x01) // requested audio format unsupported
115 
116  // supported number of channels (samples per frame) range
117  #define XAPO_MIN_CHANNELS 1
118  #define XAPO_MAX_CHANNELS 64
119 
120  // supported framerate range
121  #define XAPO_MIN_FRAMERATE 1000
122  #define XAPO_MAX_FRAMERATE 200000
123 
124  // unicode string length, including terminator, used with XAPO_REGISTRATION_PROPERTIES
125  #define XAPO_REGISTRATION_STRING_LENGTH 256
126 
127 
128  // XAPO property flags, used with XAPO_REGISTRATION_PROPERTIES.Flags:
129  // Number of channels of input and output buffers must match,
130  // applies to XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.pFormat.
131  #define XAPO_FLAG_CHANNELS_MUST_MATCH 0x00000001
132 
133  // Framerate of input and output buffers must match,
134  // applies to XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.pFormat.
135  #define XAPO_FLAG_FRAMERATE_MUST_MATCH 0x00000002
136 
137  // Bit depth of input and output buffers must match,
138  // applies to XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.pFormat.
139  // Container size of input and output buffers must also match if
140  // XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.pFormat is WAVEFORMATEXTENSIBLE.
141  #define XAPO_FLAG_BITSPERSAMPLE_MUST_MATCH 0x00000004
142 
143  // Number of input and output buffers must match,
144  // applies to XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.
145  //
146  // Also, XAPO_REGISTRATION_PROPERTIES.MinInputBufferCount must
147  // equal XAPO_REGISTRATION_PROPERTIES.MinOutputBufferCount and
148  // XAPO_REGISTRATION_PROPERTIES.MaxInputBufferCount must equal
149  // XAPO_REGISTRATION_PROPERTIES.MaxOutputBufferCount when used.
150  #define XAPO_FLAG_BUFFERCOUNT_MUST_MATCH 0x00000008
151 
152  // XAPO must be run in-place. Use this flag only if your DSP
153  // implementation cannot process separate input and output buffers.
154  // If set, the following flags must also be set:
155  // XAPO_FLAG_CHANNELS_MUST_MATCH
156  // XAPO_FLAG_FRAMERATE_MUST_MATCH
157  // XAPO_FLAG_BITSPERSAMPLE_MUST_MATCH
158  // XAPO_FLAG_BUFFERCOUNT_MUST_MATCH
159  // XAPO_FLAG_INPLACE_SUPPORTED
160  //
161  // Multiple input and output buffers may be used with in-place XAPOs,
162  // though the input buffer count must equal the output buffer count.
163  // When multiple input/output buffers are used, the XAPO may assume
164  // input buffer [N] equals output buffer [N] for in-place processing.
165  #define XAPO_FLAG_INPLACE_REQUIRED 0x00000020
166 
167  // XAPO may be run in-place. If the XAPO is used in a chain
168  // such that the requirements for XAPO_FLAG_INPLACE_REQUIRED are met,
169  // XAudio2 will ensure the XAPO is run in-place. If not met, XAudio2
170  // will still run the XAPO albeit with separate input and output buffers.
171  //
172  // For example, consider an effect which may be ran in stereo->5.1 mode or
173  // mono->mono mode. When set to stereo->5.1, it will be run with separate
174  // input and output buffers as format conversion is not permitted in-place.
175  // However, if configured to run mono->mono, the same XAPO can be run
176  // in-place. Thus the same implementation may be conveniently reused
177  // for various input/output configurations, while taking advantage of
178  // in-place processing when possible.
179  #define XAPO_FLAG_INPLACE_SUPPORTED 0x00000010
180 
181 
182 //--------------<D-A-T-A---T-Y-P-E-S>---------------------------------------//
183  #pragma pack(push, 1) // set packing alignment to ensure consistency across arbitrary build environments
184 
185 
186  // XAPO registration properties, describes general XAPO characteristics, used with IXAPO::GetRegistrationProperties
188  CLSID clsid; // COM class ID, used with CoCreate
189  WCHAR FriendlyName[XAPO_REGISTRATION_STRING_LENGTH]; // friendly name unicode string
190  WCHAR CopyrightInfo[XAPO_REGISTRATION_STRING_LENGTH]; // copyright information unicode string
191  UINT32 MajorVersion; // major version
192  UINT32 MinorVersion; // minor version
193  UINT32 Flags; // XAPO property flags, describes supported input/output configuration
194  UINT32 MinInputBufferCount; // minimum number of input buffers required for processing, can be 0
195  UINT32 MaxInputBufferCount; // maximum number of input buffers supported for processing, must be >= MinInputBufferCount
196  UINT32 MinOutputBufferCount; // minimum number of output buffers required for processing, can be 0, must match MinInputBufferCount when XAPO_FLAG_BUFFERCOUNT_MUST_MATCH used
197  UINT32 MaxOutputBufferCount; // maximum number of output buffers supported for processing, must be >= MinOutputBufferCount, must match MaxInputBufferCount when XAPO_FLAG_BUFFERCOUNT_MUST_MATCH used
199 
200 
201  // LockForProcess buffer parameters:
202  // Defines buffer parameters that remain constant while an XAPO is locked.
203  // Used with IXAPO::LockForProcess.
204  //
205  // For CBR XAPOs, MaxFrameCount is the only number of frames
206  // IXAPO::Process would have to handle for the respective buffer.
208  const WAVEFORMATEX* pFormat; // buffer audio format
209  UINT32 MaxFrameCount; // maximum number of frames in respective buffer that IXAPO::Process would have to handle, irrespective of dynamic variable settings, can be 0
211 
212  // Buffer flags:
213  // Describes assumed content of the respective buffer.
214  // Used with XAPO_PROCESS_BUFFER_PARAMETERS.BufferFlags.
215  //
216  // This meta-data can be used by an XAPO to implement
217  // optimizations that require knowledge of a buffer's content.
218  //
219  // For example, XAPOs that always produce silent output from silent input
220  // can check the flag on the input buffer to determine if any signal
221  // processing is necessary. If silent, the XAPO may simply set the flag
222  // on the output buffer to silent and return, optimizing out the work of
223  // processing silent data: XAPOs that generate silence for any reason may
224  // set the buffer's flag accordingly rather than writing out silent
225  // frames to the buffer itself.
226  //
227  // The flags represent what should be assumed is in the respective buffer.
228  // The flags may not reflect what is actually stored in memory.
229  typedef enum XAPO_BUFFER_FLAGS {
230  XAPO_BUFFER_SILENT, // silent data should be assumed, respective memory may be uninitialized
231  XAPO_BUFFER_VALID, // arbitrary data should be assumed (may or may not be silent frames), respective memory initialized
233 
234  // Process buffer parameters:
235  // Defines buffer parameters that may change from one
236  // processing pass to the next. Used with IXAPO::Process.
237  //
238  // Note the byte size of the respective buffer must be at least:
239  // XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount * XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.pFormat->nBlockAlign
240  //
241  // Although the audio format and maximum size of the respective
242  // buffer is locked (defined by XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS),
243  // the actual memory address of the buffer given is permitted to change
244  // from one processing pass to the next.
245  //
246  // For CBR XAPOs, ValidFrameCount is constant while locked and equals
247  // the respective XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount.
249  void* pBuffer; // audio data buffer, must be non-NULL
250  XAPO_BUFFER_FLAGS BufferFlags; // describes assumed content of pBuffer, does not affect ValidFrameCount
251  UINT32 ValidFrameCount; // number of frames of valid data, must be within respective [0, XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount], always XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount for CBR/user-defined XAPOs, does not affect BufferFlags
253 
254 
255 //--------------<M-A-C-R-O-S>-----------------------------------------------//
256  // Memory allocation macros that allow one module to allocate memory and
257  // another to free it, by guaranteeing that the same heap manager is used
258  // regardless of differences between build environments of the two modules.
259  //
260  // Used by IXAPO methods that must allocate arbitrary sized structures
261  // such as WAVEFORMATEX that are subsequently returned to the application.
262  #define XAPOAlloc(size) CoTaskMemAlloc(size)
263  #define XAPOFree(p) CoTaskMemFree(p)
264 
265 
266 //--------------<I-N-T-E-R-F-A-C-E-S>---------------------------------------//
267  // IXAPO:
268  // The only mandatory XAPO COM interface -- a thin wrapper that manages
269  // DSP code, allowing it to be easily plugged into an XAudio2 effect chain.
270  #undef INTERFACE
271  #define INTERFACE IXAPO
272  DECLARE_INTERFACE_(IXAPO, IUnknown) {
274  // DESCRIPTION:
275  // Allocates a copy of the registration properties of the XAPO.
276  //
277  // PARAMETERS:
278  // ppRegistrationProperties - [out] receives pointer to copy of registration properties, use XAPOFree to free structure, left untouched on failure
279  //
280  // RETURN VALUE:
281  // COM error code
283  STDMETHOD(GetRegistrationProperties) (THIS_ _Outptr_ XAPO_REGISTRATION_PROPERTIES** ppRegistrationProperties) PURE;
284 
286  // DESCRIPTION:
287  // Queries if an input/output configuration is supported.
288  //
289  // REMARKS:
290  // This method allows XAPOs to express dependency of input format
291  // with respect to output format.
292  //
293  // If the input/output format pair configuration is unsupported,
294  // this method also determines the nearest input format supported.
295  // Nearest meaning closest bit depth, framerate, and channel count,
296  // in that order of importance.
297  //
298  // The behaviour of this method should remain constant after the
299  // XAPO has been initialized.
300  //
301  // PARAMETERS:
302  // pOutputFormat - [in] output format known to be supported
303  // pRequestedInputFormat - [in] input format to examine
304  // ppSupportedInputFormat - [out] receives pointer to nearest input format supported if not NULL and input/output configuration unsupported, use XAPOFree to free structure, left untouched on any failure except XAPO_E_FORMAT_UNSUPPORTED
305  //
306  // RETURN VALUE:
307  // COM error code, including:
308  // S_OK - input/output configuration supported, ppSupportedInputFormat left untouched
309  // XAPO_E_FORMAT_UNSUPPORTED - input/output configuration unsupported, ppSupportedInputFormat receives pointer to nearest input format supported if not NULL
310  // E_INVALIDARG - either audio format invalid, ppSupportedInputFormat left untouched
312  STDMETHOD(IsInputFormatSupported) (THIS_ const WAVEFORMATEX* pOutputFormat, const WAVEFORMATEX* pRequestedInputFormat, _Outptr_opt_ WAVEFORMATEX** ppSupportedInputFormat) PURE;
313 
315  // DESCRIPTION:
316  // Queries if an input/output configuration is supported.
317  //
318  // REMARKS:
319  // This method allows XAPOs to express dependency of output format
320  // with respect to input format.
321  //
322  // If the input/output format pair configuration is unsupported,
323  // this method also determines the nearest output format supported.
324  // Nearest meaning closest bit depth, framerate, and channel count,
325  // in that order of importance.
326  //
327  // The behaviour of this method should remain constant after the
328  // XAPO has been initialized.
329  //
330  // PARAMETERS:
331  // pInputFormat - [in] input format known to be supported
332  // pRequestedOutputFormat - [in] output format to examine
333  // ppSupportedOutputFormat - [out] receives pointer to nearest output format supported if not NULL and input/output configuration unsupported, use XAPOFree to free structure, left untouched on any failure except XAPO_E_FORMAT_UNSUPPORTED
334  //
335  // RETURN VALUE:
336  // COM error code, including:
337  // S_OK - input/output configuration supported, ppSupportedOutputFormat left untouched
338  // XAPO_E_FORMAT_UNSUPPORTED - input/output configuration unsupported, ppSupportedOutputFormat receives pointer to nearest output format supported if not NULL
339  // E_INVALIDARG - either audio format invalid, ppSupportedOutputFormat left untouched
341  STDMETHOD(IsOutputFormatSupported) (THIS_ const WAVEFORMATEX* pInputFormat, const WAVEFORMATEX* pRequestedOutputFormat, _Outptr_opt_ WAVEFORMATEX** ppSupportedOutputFormat) PURE;
342 
344  // DESCRIPTION:
345  // Performs any effect-specific initialization if required.
346  //
347  // REMARKS:
348  // The contents of pData are defined by the XAPO.
349  // Immutable variables (constant during the lifespan of the XAPO)
350  // should be set once via this method.
351  // Once initialized, an XAPO cannot be initialized again.
352  //
353  // An XAPO should be initialized before passing it to XAudio2
354  // as part of an effect chain. XAudio2 will not call this method;
355  // it exists for future content-driven initialization.
356  //
357  // PARAMETERS:
358  // pData - [in] effect-specific initialization parameters, may be NULL if DataByteSize == 0
359  // DataByteSize - [in] size of pData in bytes, may be 0 if pData is NULL
360  //
361  // RETURN VALUE:
362  // COM error code
364  STDMETHOD(Initialize) (THIS_ _In_reads_bytes_opt_(DataByteSize) const void* pData, UINT32 DataByteSize) PURE;
365 
367  // DESCRIPTION:
368  // Resets variables dependent on frame history.
369  //
370  // REMARKS:
371  // All other variables remain unchanged, including variables set by
372  // IXAPOParameters::SetParameters.
373  //
374  // For example, an effect with delay should zero out its delay line
375  // during this method, but should not reallocate anything as the
376  // XAPO remains locked with a constant input/output configuration.
377  //
378  // XAudio2 calls this method only if the XAPO is locked.
379  // This method should not block as it is called from the
380  // realtime thread.
381  //
382  // PARAMETERS:
383  // void
384  //
385  // RETURN VALUE:
386  // void
388  STDMETHOD_(void, Reset) (THIS) PURE;
389 
391  // DESCRIPTION:
392  // Locks the XAPO to a specific input/output configuration,
393  // allowing it to do any final initialization before Process
394  // is called on the realtime thread.
395  //
396  // REMARKS:
397  // Once locked, the input/output configuration and any other locked
398  // variables remain constant until UnlockForProcess is called.
399  //
400  // XAPOs should assert the input/output configuration is supported
401  // and that any required effect-specific initialization is complete.
402  // IsInputFormatSupported, IsOutputFormatSupported, and Initialize
403  // should be called as necessary before this method is called.
404  //
405  // All internal memory buffers required for Process should be
406  // allocated by the time this method returns successfully
407  // as Process is non-blocking and should not allocate memory.
408  //
409  // Once locked, an XAPO cannot be locked again until
410  // UnLockForProcess is called.
411  //
412  // PARAMETERS:
413  // InputLockedParameterCount - [in] number of input buffers, must be within [XAPO_REGISTRATION_PROPERTIES.MinInputBufferCount, XAPO_REGISTRATION_PROPERTIES.MaxInputBufferCount]
414  // pInputLockedParameters - [in] array of input locked buffer parameter structures, may be NULL if InputLockedParameterCount == 0, otherwise must have InputLockedParameterCount elements
415  // OutputLockedParameterCount - [in] number of output buffers, must be within [XAPO_REGISTRATION_PROPERTIES.MinOutputBufferCount, XAPO_REGISTRATION_PROPERTIES.MaxOutputBufferCount], must match InputLockedParameterCount when XAPO_FLAG_BUFFERCOUNT_MUST_MATCH used
416  // pOutputLockedParameters - [in] array of output locked buffer parameter structures, may be NULL if OutputLockedParameterCount == 0, otherwise must have OutputLockedParameterCount elements
417  //
418  // RETURN VALUE:
419  // COM error code
421  STDMETHOD(LockForProcess) (THIS_ UINT32 InputLockedParameterCount, _In_reads_opt_(InputLockedParameterCount) const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS* pInputLockedParameters, UINT32 OutputLockedParameterCount, _In_reads_opt_(OutputLockedParameterCount) const XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS* pOutputLockedParameters) PURE;
422 
424  // DESCRIPTION:
425  // Opposite of LockForProcess. Variables allocated during
426  // LockForProcess should be deallocated by this method.
427  //
428  // REMARKS:
429  // Unlocking an XAPO allows an XAPO instance to be reused with
430  // different input/output configurations.
431  //
432  // PARAMETERS:
433  // void
434  //
435  // RETURN VALUE:
436  // void
438  STDMETHOD_(void, UnlockForProcess) (THIS) PURE;
439 
441  // DESCRIPTION:
442  // Runs the XAPO's DSP code on the given input/output buffers.
443  //
444  // REMARKS:
445  // In addition to writing to the output buffers as appropriate,
446  // an XAPO must set the BufferFlags and ValidFrameCount members
447  // of all elements in pOutputProcessParameters accordingly.
448  //
449  // ppInputProcessParameters will not necessarily be the same as
450  // ppOutputProcessParameters for in-place processing, rather
451  // the pBuffer members of each will point to the same memory.
452  //
453  // Multiple input/output buffers may be used with in-place XAPOs,
454  // though the input buffer count must equal the output buffer count.
455  // When multiple input/output buffers are used with in-place XAPOs,
456  // the XAPO may assume input buffer [N] equals output buffer [N].
457  //
458  // When IsEnabled is FALSE, the XAPO should process thru.
459  // Thru processing means an XAPO should not apply its normal
460  // processing to the given input/output buffers during Process.
461  // It should instead pass data from input to output with as little
462  // modification possible. Effects that perform format conversion
463  // should continue to do so. The effect must ensure transitions
464  // between normal and thru processing do not introduce
465  // discontinuities into the signal.
466  //
467  // XAudio2 calls this method only if the XAPO is locked.
468  // This method should not block as it is called from the
469  // realtime thread.
470  //
471  // PARAMETERS:
472  // InputProcessParameterCount - [in] number of input buffers, matches respective InputLockedParameterCount parameter given to LockForProcess
473  // pInputProcessParameters - [in] array of input process buffer parameter structures, may be NULL if InputProcessParameterCount == 0, otherwise must have InputProcessParameterCount elements
474  // OutputProcessParameterCount - [in] number of output buffers, matches respective OutputLockedParameterCount parameter given to LockForProcess
475  // pOutputProcessParameters - [in/out] array of output process buffer parameter structures, may be NULL if OutputProcessParameterCount == 0, otherwise must have OutputProcessParameterCount elements
476  // IsEnabled - [in] TRUE to process normally, FALSE to process thru
477  //
478  // RETURN VALUE:
479  // void
481  STDMETHOD_(void, Process) (THIS_ UINT32 InputProcessParameterCount, _In_reads_opt_(InputProcessParameterCount) const XAPO_PROCESS_BUFFER_PARAMETERS* pInputProcessParameters, UINT32 OutputProcessParameterCount, _Inout_updates_opt_(OutputProcessParameterCount) XAPO_PROCESS_BUFFER_PARAMETERS* pOutputProcessParameters, BOOL IsEnabled) PURE;
482 
484  // DESCRIPTION:
485  // Returns the number of input frames required to generate the
486  // requested number of output frames.
487  //
488  // REMARKS:
489  // XAudio2 may call this method to determine how many input frames
490  // an XAPO requires. This is constant for locked CBR XAPOs;
491  // this method need only be called once while an XAPO is locked.
492  //
493  // XAudio2 calls this method only if the XAPO is locked.
494  // This method should not block as it is called from the
495  // realtime thread.
496  //
497  // PARAMETERS:
498  // OutputFrameCount - [in] requested number of output frames, must be within respective [0, XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount], always XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount for CBR/user-defined XAPOs
499  //
500  // RETURN VALUE:
501  // number of input frames required
503  STDMETHOD_(UINT32, CalcInputFrames) (THIS_ UINT32 OutputFrameCount) PURE;
504 
506  // DESCRIPTION:
507  // Returns the number of output frames generated for the
508  // requested number of input frames.
509  //
510  // REMARKS:
511  // XAudio2 may call this method to determine how many output frames
512  // an XAPO will generate. This is constant for locked CBR XAPOs;
513  // this method need only be called once while an XAPO is locked.
514  //
515  // XAudio2 calls this method only if the XAPO is locked.
516  // This method should not block as it is called from the
517  // realtime thread.
518  //
519  // PARAMETERS:
520  // InputFrameCount - [in] requested number of input frames, must be within respective [0, XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount], always XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount for CBR/user-defined XAPOs
521  //
522  // RETURN VALUE:
523  // number of output frames generated
525  STDMETHOD_(UINT32, CalcOutputFrames) (THIS_ UINT32 InputFrameCount) PURE;
526  };
527 
528 
529 
530  // IXAPOParameters:
531  // Optional XAPO COM interface that allows an XAPO to use
532  // effect-specific parameters.
533  #undef INTERFACE
534  #define INTERFACE IXAPOParameters
535  DECLARE_INTERFACE_(IXAPOParameters, IUnknown) {
537  // DESCRIPTION:
538  // Sets effect-specific parameters.
539  //
540  // REMARKS:
541  // This method may only be called on the realtime thread;
542  // no synchronization between it and IXAPO::Process is necessary.
543  //
544  // This method should not block as it is called from the
545  // realtime thread.
546  //
547  // PARAMETERS:
548  // pParameters - [in] effect-specific parameter block, must be != NULL
549  // ParameterByteSize - [in] size of pParameters in bytes, must be > 0
550  //
551  // RETURN VALUE:
552  // void
554  STDMETHOD_(void, SetParameters) (THIS_ _In_reads_bytes_(ParameterByteSize) const void* pParameters, UINT32 ParameterByteSize) PURE;
555 
557  // DESCRIPTION:
558  // Gets effect-specific parameters.
559  //
560  // REMARKS:
561  // Unlike SetParameters, XAudio2 does not call this method on the
562  // realtime thread. Thus, the XAPO must protect variables shared
563  // with SetParameters/Process using appropriate synchronization.
564  //
565  // PARAMETERS:
566  // pParameters - [out] receives effect-specific parameter block, must be != NULL
567  // ParameterByteSize - [in] size of pParameters in bytes, must be > 0
568  //
569  // RETURN VALUE:
570  // void
572  STDMETHOD_(void, GetParameters) (THIS_ _Out_writes_bytes_(ParameterByteSize) void* pParameters, UINT32 ParameterByteSize) PURE;
573  };
574 
575 
576 //--------------<M-A-C-R-O-S>-----------------------------------------------//
577  // macros to allow XAPO interfaces to be used in C code
578  #if !defined(__cplusplus)
579  // IXAPO
580  #define IXAPO_QueryInterface(This, riid, ppInterface) \
581  ( (This)->lpVtbl->QueryInterface(This, riid, ppInterface) )
582 
583  #define IXAPO_AddRef(This) \
584  ( (This)->lpVtbl->AddRef(This) )
585 
586  #define IXAPO_Release(This) \
587  ( (This)->lpVtbl->Release(This) )
588 
589  #define IXAPO_GetRegistrationProperties(This, ppRegistrationProperties) \
590  ( (This)->lpVtbl->GetRegistrationProperties(This, ppRegistrationProperties) )
591 
592  #define IXAPO_IsInputFormatSupported(This, pOutputFormat, pRequestedInputFormat, ppSupportedInputFormat) \
593  ( (This)->lpVtbl->IsInputFormatSupported(This, pOutputFormat, pRequestedInputFormat, ppSupportedInputFormat) )
594 
595  #define IXAPO_IsOutputFormatSupported(This, pInputFormat, pRequestedOutputFormat, ppSupportedOutputFormat) \
596  ( (This)->lpVtbl->IsOutputFormatSupported(This, pInputFormat, pRequestedOutputFormat, ppSupportedOutputFormat) )
597 
598  #define IXAPO_Initialize(This, pData, DataByteSize) \
599  ( (This)->lpVtbl->Initialize(This, pData, DataByteSize) )
600 
601  #define IXAPO_Reset(This) \
602  ( (This)->lpVtbl->Reset(This) )
603 
604  #define IXAPO_LockForProcess(This, InputLockedParameterCount, pInputLockedParameters, OutputLockedParameterCount, pOutputLockedParameters) \
605  ( (This)->lpVtbl->LockForProcess(This, InputLockedParameterCount, pInputLockedParameters, OutputLockedParameterCount, pOutputLockedParameters) )
606 
607  #define IXAPO_UnlockForProcess(This) \
608  ( (This)->lpVtbl->UnlockForProcess(This) )
609 
610  #define IXAPO_Process(This, InputProcessParameterCount, pInputProcessParameters, OutputProcessParameterCount, pOutputProcessParameters, IsEnabled) \
611  ( (This)->lpVtbl->Process(This, InputProcessParameterCount, pInputProcessParameters, OutputProcessParameterCount, pOutputProcessParameters, IsEnabled) )
612 
613  #define IXAPO_CalcInputFrames(This, OutputFrameCount) \
614  ( (This)->lpVtbl->CalcInputFrames(This, OutputFrameCount) )
615 
616  #define IXAPO_CalcOutputFrames(This, InputFrameCount) \
617  ( (This)->lpVtbl->CalcOutputFrames(This, InputFrameCount) )
618 
619 
620  // IXAPOParameters
621  #define IXAPOParameters_QueryInterface(This, riid, ppInterface) \
622  ( (This)->lpVtbl->QueryInterface(This, riid, ppInterface) )
623 
624  #define IXAPOParameters_AddRef(This) \
625  ( (This)->lpVtbl->AddRef(This) )
626 
627  #define IXAPOParameters_Release(This) \
628  ( (This)->lpVtbl->Release(This) )
629 
630  #define IXAPOParameters_SetParameters(This, pParameters, ParameterByteSize) \
631  ( (This)->lpVtbl->SetParameters(This, pParameters, ParameterByteSize) )
632 
633  #define IXAPOParameters_GetParameters(This, pParameters, ParameterByteSize) \
634  ( (This)->lpVtbl->GetParameters(This, pParameters, ParameterByteSize) )
635  #endif // !defined(__cplusplus)
636 
637 
638  #pragma pack(pop) // revert packing alignment
639 #endif // !defined(GUID_DEFS_ONLY)
640 
641 /*#endif*/ /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE) */
642 /*#pragma endregion*/
643 //---------------------------------<-EOF->----------------------------------//
CLSID clsid
Definition: xapo.h:188
UINT32 MajorVersion
Definition: xapo.h:191
#define F2(x, y, z)
Definition: md5.c:41
UINT32 Flags
Definition: xapo.h:193
interface __declspec(uuid("A410B984-9839-4819-A0BE-2856AE6B3ADB")) IXAPO
void * pBuffer
Definition: xapo.h:249
UINT32 MinorVersion
Definition: xapo.h:192
XAPO_BUFFER_FLAGS
Definition: xapo.h:229
UINT32 MaxFrameCount
Definition: xapo.h:209
WCHAR CopyrightInfo[XAPO_REGISTRATION_STRING_LENGTH]
Definition: xapo.h:190
UINT32 MaxOutputBufferCount
Definition: xapo.h:197
_Outptr_ IUnknown _In_reads_bytes_opt_(InitDataByteSize) const void *pInitData
UINT32 MinOutputBufferCount
Definition: xapo.h:196
Definition: xapo.h:248
UINT32 ValidFrameCount
Definition: xapo.h:251
UINT32 MinInputBufferCount
Definition: xapo.h:194
XAPO_BUFFER_FLAGS BufferFlags
Definition: xapo.h:250
#define A(i)
Definition: ecp_curves.c:884
#define XAPO_REGISTRATION_STRING_LENGTH
Definition: xapo.h:125
struct XAPO_PROCESS_BUFFER_PARAMETERS XAPO_PROCESS_BUFFER_PARAMETERS
struct XAPO_REGISTRATION_PROPERTIES XAPO_REGISTRATION_PROPERTIES
unsigned int BOOL
Definition: gctypes.h:51
Definition: xapo.h:230
uint32_t UINT32
Definition: coretypes.h:10
struct XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS XAPO_LOCKFORPROCESS_PARAMETERS
DECLARE_INTERFACE_(IXAPO, IUnknown)
Definition: xapo.h:272
Definition: audiodefs.h:40
const WAVEFORMATEX * pFormat
Definition: xapo.h:208
UINT32 MaxInputBufferCount
Definition: xapo.h:195
WCHAR FriendlyName[XAPO_REGISTRATION_STRING_LENGTH]
Definition: xapo.h:189
Definition: xapo.h:187
Definition: xapo.h:231