XAudio2 - Problem with loops

Started by
1 comment, last by Stefan Fischlschweiger 8 years, 6 months ago

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?

Advertisement

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

LoopCount

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

Yea, that did it =)

I actually tried that out before and it didn't work. Turns out I had other functions set up incorrectly so the Stop method wasn't called when it was supposed to be

This topic is closed to new replies.

Advertisement