[SlimDX] How to tell if an XAudio2 voice is started?

Started by
2 comments, last by AlexandreMutel 12 years, 6 months ago
What is the best way to tell whether a SlimDX.XAudio2.SourceVoice is currently started or stopped? I didn't see any members that obviously contained this information.

Thanks!
Advertisement
Unfortunately I don't think that Xaudio2 allows you to poll a voice for its playing state. It is possible that you can use the GetState call on a source voice to tell if there are any queued buffers, but that is not really the same thing. If you are using it to play a large buffer and you may be able to use the StreamEnd event, but I believe that this will only fire if you have set the EndOfStream flag on the AudioBuffer (and maybe if you call Discontinuity) .

Hope this helps.
Thanks for the confirmation. Unfortunately, I am looping everything, so the queue count is always 1. I'll try to avoid requiring the information, and if I do need it, I'll get State.SamplesPlayed, sleep for a few milliseconds, and check again to see if it increased.
You will probably need to register to BufferStart/BufferEnd events on the SourceVoice (Have a look at PlaySound sample from SharpDX).

This topic is closed to new replies.

Advertisement