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.
This commit is contained in:
Erik Hofman
2010-06-28 08:12:23 +02:00
parent de35658096
commit 7086f2dc89

View 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();