From 1604c9bae2f6d20b42e8ee3c42e19861c3a99dbb Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 30 Sep 2002 18:45:09 +0000 Subject: [PATCH] Erik Hofman: This is a small patch which resets the delay counter if the sound doesn't need to be stopped. Also the code is reorganiozed a bit to fix sume "bugs". --- src/Sound/fg_sound.cxx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Sound/fg_sound.cxx b/src/Sound/fg_sound.cxx index bcd95d824..b11ba1590 100644 --- a/src/Sound/fg_sound.cxx +++ b/src/Sound/fg_sound.cxx @@ -270,22 +270,22 @@ FGSound::update (double dt) ) { - if (_sample->is_playing()) { - - if ((_mode != FGSound::IN_TRANSIT) || (_stopping < MAX_TRANSIT_TIME)) { - - _active = false; - _sample->stop( _mgr->get_scheduler() ); + if ((_mode != FGSound::IN_TRANSIT) || (_stopping < MAX_TRANSIT_TIME)) { + if (_sample->is_playing()) { SG_LOG(SG_GENERAL, SG_INFO, "Stopping audio after " << _dt_play << " sec: " << _name ); - } else - _stopping += dt; - } + _sample->stop( _mgr->get_scheduler() ); + } - _dt_stop += dt; - _dt_play = 0.0; + _active = false; + _dt_stop += dt; + _dt_play = 0.0; + + + } else + _stopping += dt; return; @@ -308,10 +308,12 @@ FGSound::update (double dt) } // - // Update playing time and cache the current value. + // Update the playing time, cache the current value and + // clear the delay timer. // - _dt_play += dt; + _dt_play += dt; _prev_value = curr_value; + _stopping = 0.0; // // Update the volume