Sign in to follow this  
Stefan Fischlschweiger

XAudio2 - Problem with loops

Recommended Posts

So I've added some sound to my game. Single sounds play like they should, but loops give me headaches.

No matter what I try, they just won't stop playing.


Neither SourceVoice.Stop() nor SourceVoice.ExitLoop() or SourceVoice.FlushSourceBuffers() will stop the loop from playing, which is kind of annoying when the menu theme keeps playing on the gameplay screen.


Any ideas on that?

Share this post

Link to post
Share on other sites

Hey can you not set it to play once in the XAUDIO2_BUFFER structure;



Number of times to loop through the loop region. This value can be between 0 and XAUDIO2_MAX_LOOP_COUNT. If LoopCount is zero no looping is performed and LoopBegin and LoopLength must be 0. To loop forever, set LoopCount to XAUDIO2_LOOP_INFINITE.

Maybe set it to 1.


or IXAudio2MasteringVoice::DestroyVoice method may do it.


You need to read this Stop(0);//with 0

Edited by ankhd

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this