]> git.mxchange.org Git - simgear.git/commitdiff
brehmt:
authorErik Hofman <erik@ehofman.com>
Mon, 28 Jun 2010 06:12:23 +0000 (08:12 +0200)
committerErik Hofman <erik@ehofman.com>
Mon, 28 Jun 2010 06:12:23 +0000 (08:12 +0200)
When a sample's state constantly is "changed" (because sth. keeps updating the
sample in each update loop), then SGSampleGroup::update never ever checked if
the sample had already stopped playing by itself.
The attached patch reorders the last two conditions. It now first checks if a
sample has already stopped playing, before checking if there's sth to update.

simgear/sound/sample_group.cxx

index e2a2b2c73188894f89daeca7316ebd5946ff5910..bc7605ac4966667c72303e1ca014ce82fd613c6f 100644 (file)
@@ -103,6 +103,7 @@ void SGSampleGroup::update( double dt ) {
         }
 
         if ( result == AL_STOPPED ) {
+            sample->stop();
             ALuint buffer = sample->get_buffer();
             alDeleteBuffers( 1, &buffer );
             testForALError("buffer remove");
@@ -157,17 +158,6 @@ void SGSampleGroup::update( double dt ) {
                 // sadly, no free source available at this time
             }
 
-        } else if ( sample->is_valid_source() && sample->has_changed() ) {
-            if ( !sample->is_playing() ) {
-                // a request to stop playing the sound has been filed.
-
-                sample->stop();
-                sample->no_valid_source();
-                _smgr->release_source( sample->get_source() );
-            } else if ( _smgr->has_changed() ) {
-                update_sample_config( sample );
-            }
-
         } else if ( sample->is_valid_source() ) {
             // check if the sound has stopped by itself
 
@@ -183,6 +173,18 @@ void SGSampleGroup::update( double dt ) {
                 _smgr->release_buffer( sample );
                 remove( sample->get_sample_name() );
             }
+            else
+            if ( sample->has_changed() ) {
+                if ( !sample->is_playing() ) {
+                    // a request to stop playing the sound has been filed.
+                    sample->stop();
+                    sample->no_valid_source();
+                    _smgr->release_source( sample->get_source() );
+                } else if ( _smgr->has_changed() ) {
+                    update_sample_config( sample );
+                }
+            }
+
         }
         testForALError("update");
     }
@@ -258,6 +260,7 @@ SGSampleGroup::stop ()
             if ( sample->is_playing() ) {
                 alSourceStop( source );
                 alSourcei( source, AL_BUFFER, 0 );
+                sample->stop();
             }
             _smgr->release_source( source );
             sample->no_valid_source();