]> git.mxchange.org Git - simgear.git/commitdiff
fix sound buffer resource leak
authorThorstenB <brehmt@gmail.com>
Sun, 4 Dec 2011 20:25:42 +0000 (21:25 +0100)
committerThorstenB <brehmt@gmail.com>
Sun, 4 Dec 2011 20:25:42 +0000 (21:25 +0100)
Openal doesn't remove buffers unless they were disconnected form
their source.

simgear/sound/sample_group.cxx
simgear/sound/sample_group.hxx

index ac04d99e8f8aa56f8d314c5fa06ecd426645160d..cc594c2f9053886664540f73eddc201ab6342f9e 100644 (file)
@@ -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");
             }
index ccf1e85db1f4ede870f4d48ef6b553f63cd9b9c9..56f1bd450c69eb65bb383662054fe5d61c292c0f 100644 (file)
@@ -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 );