Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

645 lines
34 KiB

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