diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index 8376ecfa..83eb541e 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -1876,6 +1876,7 @@ static void S_AL_MusicSourceFree( void ) { // Release the output musicSource S_AL_SrcUnlock(musicSourceHandle); + S_AL_SrcKill(musicSourceHandle); musicSource = 0; musicSourceHandle = -1; } @@ -1908,17 +1909,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();