diff options
author | Zack Middleton <zturtleman@gmail.com> | 2013-08-16 15:29:12 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:33 +0100 |
commit | 773cdd867e519700c0a67ab58abe441810d891d0 (patch) | |
tree | cf78ccb764a9c5b80047d448ea5ae72eb4b5a4ae /src | |
parent | f3770e9d864fa94cf4af73b1898b2a796ff38a91 (diff) |
Fix OpenAL music stop issues using stream stop code
S_AL_StopBackgroundTrack would sometimes generate AL errors.
S_AL_MusicSourceFree needs to kill source or next track may have short looping buffer.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/snd_openal.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c index e26375c2..23a6a67d 100644 --- a/src/client/snd_openal.c +++ b/src/client/snd_openal.c @@ -1895,6 +1895,7 @@ static void S_AL_MusicSourceFree( void ) { // Release the output musicSource S_AL_SrcUnlock(musicSourceHandle); + S_AL_SrcKill(musicSourceHandle); musicSource = 0; musicSourceHandle = -1; } @@ -1927,17 +1928,22 @@ S_AL_StopBackgroundTrack static void S_AL_StopBackgroundTrack( void ) { + int numBuffers; + if(!musicPlaying) return; // Stop playing qalSourceStop(musicSource); - // De-queue the musicBuffers - qalSourceUnqueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers); - - // Destroy the musicBuffers - qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers); + // Un-queue any buffers, and delete them + qalGetSourcei( musicSource, AL_BUFFERS_PROCESSED, &numBuffers ); + while( numBuffers-- ) + { + ALuint buffer; + qalSourceUnqueueBuffers(musicSource, 1, &buffer); + qalDeleteBuffers(1, &buffer); + } // Free the musicSource S_AL_MusicSourceFree(); |