IXAudio2SourceVoice::GetState method (xaudio2.h)

Returns the voice's current cursor position data.


void GetState(
             XAUDIO2_VOICE_STATE *pVoiceState,
  [optional] UINT32              Flags



Pointer to an XAUDIO2_VOICE_STATE structure containing the state of the voice.

[optional] Flags

Flags controlling which voice state data should be returned. Valid values are 0 or XAUDIO2_VOICE_NOSAMPLESPLAYED. The default value is 0. If you specify XAUDIO2_VOICE_NOSAMPLESPLAYED, GetState returns only the buffer state, not the sampler state. GetState takes roughly one-third as much time to complete when you specify XAUDIO2_VOICE_NOSAMPLESPLAYED.

Return value



If a client needs to get the correlated positions of several voices (for example, to know exactly which sample of a given voice is playing when a given sample of another voice is playing), it must make GetState calls in an XAudio2 engine callback. This ensures that none of the voices advance while the calls are being made. See the XAudio2 Callbacks overview for information about using XAudio2 callbacks.

Note that the DirectX SDK versions of XAUDIO2 do not take the Flags parameter for GetState.

Platform Requirements

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


Target Platform Windows
Header xaudio2.h

See also

How to: Stream a Sound from Disk