UINT32MinInputBufferCount;// minimum number of input buffers required for processing, can be 0
UINT32MaxInputBufferCount;// maximum number of input buffers supported for processing, must be >= MinInputBufferCount
UINT32MinOutputBufferCount;// minimum number of output buffers required for processing, can be 0, must match MinInputBufferCount when XAPO_FLAG_BUFFERCOUNT_MUST_MATCH used
UINT32MaxOutputBufferCount;// maximum number of output buffers supported for processing, must be >= MinOutputBufferCount, must match MaxInputBufferCount when XAPO_FLAG_BUFFERCOUNT_MUST_MATCH used
}XAPO_REGISTRATION_PROPERTIES;
// LockForProcess buffer parameters:
// Defines buffer parameters that remain constant while an XAPO is locked.
// Used with IXAPO::LockForProcess.
//
// For CBR XAPOs, MaxFrameCount is the only number of frames
// IXAPO::Process would have to handle for the respective buffer.
UINT32MaxFrameCount;// maximum number of frames in respective buffer that IXAPO::Process would have to handle, irrespective of dynamic variable settings, can be 0
}XAPO_LOCKFORPROCESS_PARAMETERS;
// Buffer flags:
// Describes assumed content of the respective buffer.
// Used with XAPO_PROCESS_BUFFER_PARAMETERS.BufferFlags.
//
// This meta-data can be used by an XAPO to implement
// optimizations that require knowledge of a buffer's content.
//
// For example, XAPOs that always produce silent output from silent input
// can check the flag on the input buffer to determine if any signal
// processing is necessary. If silent, the XAPO may simply set the flag
// on the output buffer to silent and return, optimizing out the work of
// processing silent data: XAPOs that generate silence for any reason may
// set the buffer's flag accordingly rather than writing out silent
// frames to the buffer itself.
//
// The flags represent what should be assumed is in the respective buffer.
// The flags may not reflect what is actually stored in memory.
typedefenumXAPO_BUFFER_FLAGS{
XAPO_BUFFER_SILENT,// silent data should be assumed, respective memory may be uninitialized
XAPO_BUFFER_VALID,// arbitrary data should be assumed (may or may not be silent frames), respective memory initialized
}XAPO_BUFFER_FLAGS;
// Process buffer parameters:
// Defines buffer parameters that may change from one
// processing pass to the next. Used with IXAPO::Process.
//
// Note the byte size of the respective buffer must be at least:
// Although the audio format and maximum size of the respective
// buffer is locked (defined by XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS),
// the actual memory address of the buffer given is permitted to change
// from one processing pass to the next.
//
// For CBR XAPOs, ValidFrameCount is constant while locked and equals
// the respective XAPO_LOCKFORPROCESS_BUFFER_PARAMETERS.MaxFrameCount.
typedefstructXAPO_PROCESS_BUFFER_PARAMETERS{
void*pBuffer;// audio data buffer, must be non-NULL
XAPO_BUFFER_FLAGSBufferFlags;// describes assumed content of pBuffer, does not affect ValidFrameCount
UINT32ValidFrameCount;// 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
// Queries if an input/output configuration is supported.
//
// REMARKS:
// This method allows XAPOs to express dependency of input format
// with respect to output format.
//
// If the input/output format pair configuration is unsupported,
// this method also determines the nearest input format supported.
// Nearest meaning closest bit depth, framerate, and channel count,
// in that order of importance.
//
// The behaviour of this method should remain constant after the
// XAPO has been initialized.
//
// PARAMETERS:
// pOutputFormat - [in] output format known to be supported
// pRequestedInputFormat - [in] input format to examine
// 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
//
// RETURN VALUE:
// COM error code, including:
// S_OK - input/output configuration supported, ppSupportedInputFormat left untouched
// XAPO_E_FORMAT_UNSUPPORTED - input/output configuration unsupported, ppSupportedInputFormat receives pointer to nearest input format supported if not NULL
// E_INVALIDARG - either audio format invalid, ppSupportedInputFormat left untouched
// Queries if an input/output configuration is supported.
//
// REMARKS:
// This method allows XAPOs to express dependency of output format
// with respect to input format.
//
// If the input/output format pair configuration is unsupported,
// this method also determines the nearest output format supported.
// Nearest meaning closest bit depth, framerate, and channel count,
// in that order of importance.
//
// The behaviour of this method should remain constant after the
// XAPO has been initialized.
//
// PARAMETERS:
// pInputFormat - [in] input format known to be supported
// pRequestedOutputFormat - [in] output format to examine
// 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
//
// RETURN VALUE:
// COM error code, including:
// S_OK - input/output configuration supported, ppSupportedOutputFormat left untouched
// XAPO_E_FORMAT_UNSUPPORTED - input/output configuration unsupported, ppSupportedOutputFormat receives pointer to nearest output format supported if not NULL
// E_INVALIDARG - either audio format invalid, ppSupportedOutputFormat left untouched
// All other variables remain unchanged, including variables set by
// IXAPOParameters::SetParameters.
//
// For example, an effect with delay should zero out its delay line
// during this method, but should not reallocate anything as the
// XAPO remains locked with a constant input/output configuration.
//
// XAudio2 calls this method only if the XAPO is locked.
// This method should not block as it is called from the
// realtime thread.
//
// PARAMETERS:
// void
//
// RETURN VALUE:
// void
////
STDMETHOD_(void,Reset)(THIS)PURE;
////
// DESCRIPTION:
// Locks the XAPO to a specific input/output configuration,
// allowing it to do any final initialization before Process
// is called on the realtime thread.
//
// REMARKS:
// Once locked, the input/output configuration and any other locked
// variables remain constant until UnlockForProcess is called.
//
// XAPOs should assert the input/output configuration is supported
// and that any required effect-specific initialization is complete.
// IsInputFormatSupported, IsOutputFormatSupported, and Initialize
// should be called as necessary before this method is called.
//
// All internal memory buffers required for Process should be
// allocated by the time this method returns successfully
// as Process is non-blocking and should not allocate memory.
//
// Once locked, an XAPO cannot be locked again until
// UnLockForProcess is called.
//
// PARAMETERS:
// InputLockedParameterCount - [in] number of input buffers, must be within [XAPO_REGISTRATION_PROPERTIES.MinInputBufferCount, XAPO_REGISTRATION_PROPERTIES.MaxInputBufferCount]
// pInputLockedParameters - [in] array of input locked buffer parameter structures, may be NULL if InputLockedParameterCount == 0, otherwise must have InputLockedParameterCount elements
// 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
// pOutputLockedParameters - [in] array of output locked buffer parameter structures, may be NULL if OutputLockedParameterCount == 0, otherwise must have OutputLockedParameterCount elements
// Opposite of LockForProcess. Variables allocated during
// LockForProcess should be deallocated by this method.
//
// REMARKS:
// Unlocking an XAPO allows an XAPO instance to be reused with
// different input/output configurations.
//
// PARAMETERS:
// void
//
// RETURN VALUE:
// void
////
STDMETHOD_(void,UnlockForProcess)(THIS)PURE;
////
// DESCRIPTION:
// Runs the XAPO's DSP code on the given input/output buffers.
//
// REMARKS:
// In addition to writing to the output buffers as appropriate,
// an XAPO must set the BufferFlags and ValidFrameCount members
// of all elements in pOutputProcessParameters accordingly.
//
// ppInputProcessParameters will not necessarily be the same as
// ppOutputProcessParameters for in-place processing, rather
// the pBuffer members of each will point to the same memory.
//
// Multiple input/output buffers may be used with in-place XAPOs,
// though the input buffer count must equal the output buffer count.
// When multiple input/output buffers are used with in-place XAPOs,
// the XAPO may assume input buffer [N] equals output buffer [N].
//
// When IsEnabled is FALSE, the XAPO should process thru.
// Thru processing means an XAPO should not apply its normal
// processing to the given input/output buffers during Process.
// It should instead pass data from input to output with as little
// modification possible. Effects that perform format conversion
// should continue to do so. The effect must ensure transitions
// between normal and thru processing do not introduce
// discontinuities into the signal.
//
// XAudio2 calls this method only if the XAPO is locked.
// This method should not block as it is called from the
// realtime thread.
//
// PARAMETERS:
// InputProcessParameterCount - [in] number of input buffers, matches respective InputLockedParameterCount parameter given to LockForProcess
// pInputProcessParameters - [in] array of input process buffer parameter structures, may be NULL if InputProcessParameterCount == 0, otherwise must have InputProcessParameterCount elements
// OutputProcessParameterCount - [in] number of output buffers, matches respective OutputLockedParameterCount parameter given to LockForProcess
// pOutputProcessParameters - [in/out] array of output process buffer parameter structures, may be NULL if OutputProcessParameterCount == 0, otherwise must have OutputProcessParameterCount elements
// IsEnabled - [in] TRUE to process normally, FALSE to process thru
// Returns the number of input frames required to generate the
// requested number of output frames.
//
// REMARKS:
// XAudio2 may call this method to determine how many input frames
// an XAPO requires. This is constant for locked CBR XAPOs;
// this method need only be called once while an XAPO is locked.
//
// XAudio2 calls this method only if the XAPO is locked.
// This method should not block as it is called from the
// realtime thread.
//
// PARAMETERS:
// 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
// Returns the number of output frames generated for the
// requested number of input frames.
//
// REMARKS:
// XAudio2 may call this method to determine how many output frames
// an XAPO will generate. This is constant for locked CBR XAPOs;
// this method need only be called once while an XAPO is locked.
//
// XAudio2 calls this method only if the XAPO is locked.
// This method should not block as it is called from the
// realtime thread.
//
// PARAMETERS:
// 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