]> git.mxchange.org Git - simgear.git/commitdiff
Slightly rearrange the buffer removing code. This should make sure the source is...
authorErik Hofman <erik@ehofman.com>
Wed, 23 Nov 2011 08:41:13 +0000 (09:41 +0100)
committerErik Hofman <erik@ehofman.com>
Wed, 23 Nov 2011 08:41:13 +0000 (09:41 +0100)
simgear/sound/sample_group.cxx

index 1610d088fbfabb3871d290ad5670866ee36e81fa..1af1f268dd0e1997b5c41e118477ad967b008929 100644 (file)
@@ -94,12 +94,19 @@ void SGSampleGroup::update( double dt ) {
         ALint result = AL_STOPPED;
 
         if ( sample->is_valid_source() ) {
+            int source = sample->get_source();
+
+            alGetSourcei( source, AL_SOURCE_STATE, &result );
             if ( sample->is_looping() ) {
-                sample->no_valid_source();
-                _smgr->release_source( sample->get_source() );
+                if ( result != AL_STOPPED ) {
+                    alSourceStop( source );
+                    alGetSourcei( source, AL_SOURCE_STATE, &result );
+                }
+                if ( result == AL_STOPPED ) {
+                    sample->no_valid_source();
+                    _smgr->release_source( sample->get_source() );
+                }
             }
-            else
-                alGetSourcei( sample->get_source(), AL_SOURCE_STATE, &result );
         }
 
         if ( result == AL_STOPPED ) {