IXAudio2VoiceCallback::OnBufferStart method (xaudio2.h)

Called when the voice is about to start processing a new audio buffer.

Syntax

void OnBufferStart(
  void *pBufferContext
);

Parameters

pBufferContext

Context pointer that was assigned to the pContext member of the XAUDIO2_BUFFER structure when the buffer was submitted.

Return value

None

Remarks

pBufferContext is the context pointer originally provided by the pContext member of the XAUDIO2_BUFFER structure, which may be NULL.

OnBufferStart is guaranteed to be called just before the first byte of the current buffer is consumed. It is appropriate to use this callback for changes to the voice state such as the following.

  • Submitting a new buffer to the voice
  • Adjusting the volume, pitch, and effect parameters of the voice
  • Enabling or disabling an effect in the voice's effect chain
All the actions listed above are synchronous when performed in an XAudio2 callback, so the changes will take effect immediately, affecting the buffer that is about to start.

It is also safe to use this callback to write audio data to the buffer directly, which can be useful for low-latency streaming scenarios. However, as with all XAudio2 callbacks, no work should be done that uses a significant amount of processor time or could block execution, including synchronous disk or network reads.

For information about the IXAudio2VoiceCallback interface methods, see the XAudio2 Callbacks section.

Platform Requirements

Windows 10 (XAudio2.9); Windows 8, Windows Phone 8 (XAudio 2.8); DirectX SDK (XAudio 2.7)

Requirements

Requirement Value
Target Platform Windows
Header xaudio2.h

See also

How to: Use Source Voice Callbacks

IXAudio2VoiceCallback

XAudio2 Callbacks