如何从 XAudio2 源语音中检索当前样本播放位置?
How do I retrieve the current sample play position from an XAudio2 source voice?
我有一个 IXAudio2SourceVoice
正在播放提交的 XAUDIO2_BUFFER
。我如何从这些样本中检索当前播放缓冲区中的播放位置?
感谢您的帮助!
只需使用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 use XAUDIO2_VOICE_NOSAMPLESPLAYED
to save the overhead of filling out the current SamplesPlayed
value.
我有一个 IXAudio2SourceVoice
正在播放提交的 XAUDIO2_BUFFER
。我如何从这些样本中检索当前播放缓冲区中的播放位置?
感谢您的帮助!
只需使用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.