From 97fcf48caa61c629bcae0118ffc3e793508fa56f Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sun, 4 Dec 2011 21:25:42 +0100 Subject: [PATCH] fix sound buffer resource leak Openal doesn't remove buffers unless they were disconnected form their source. --- simgear/sound/sample_group.cxx | 2 ++ simgear/sound/sample_group.hxx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/simgear/sound/sample_group.cxx b/simgear/sound/sample_group.cxx index ac04d99e..cc594c2f 100644 --- a/simgear/sound/sample_group.cxx +++ b/simgear/sound/sample_group.cxx @@ -113,6 +113,8 @@ void SGSampleGroup::update( double dt ) { sample->stop(); if ( !sample->is_queue() ) { ALuint buffer = sample->get_buffer(); + // disconnect buffer from its source - otherwise it cannot be deleted + alSourceUnqueueBuffers(sample->get_source(), 1, &buffer); alDeleteBuffers( 1, &buffer ); testForALError("buffer remove"); } diff --git a/simgear/sound/sample_group.hxx b/simgear/sound/sample_group.hxx index ccf1e85d..56f1bd45 100644 --- a/simgear/sound/sample_group.hxx +++ b/simgear/sound/sample_group.hxx @@ -180,7 +180,7 @@ public: /** * Request to stop playing the refered audio sample. * @param refname Reference name of the audio sample to stop - * @return true if the audio sample exsists and is scheduled to stop + * @return true if the audio sample exists and is scheduled to stop */ bool stop( const string& refname ); -- 2.39.5