I have an IXAudio2SourceVoice
that is playing a submitted XAUDIO2_BUFFER
. How do I retrieve from these the play position within the currently-playing buffer, in samples?
Thanks for your help!
Just use IXAudio2SourceVoice::GetState
:
XAUDIO2_VOICE_STATE xstate;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
voice->GetState( &xstate, 0 );
#else
voice->GetState( &xstate );
#endif
if ( xstate.BuffersQueued > 0 )
{
// xstate.SamplesPlayed
}
The reason
GetState
takes a flag in XAudio 2.8 or later is specifically so you can useXAUDIO2_VOICE_NOSAMPLESPLAYED
to save the overhead of filling out the currentSamplesPlayed
value.