X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fsound%2Fxmlsound.cxx;h=7a39d234259e0c98557f32e8e7b73d3b102376ba;hb=f4f5ab2392dff18572d78b33043d486d72b38414;hp=078dffd76bfa92ea28c6631ac902ad628acdcaa6;hpb=5cb04946b0c0b883fc01a981ee9648eb1fb7e36e;p=simgear.git diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index 078dffd7..7a39d234 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -47,7 +47,7 @@ static double _snd_log(double v) { return log(fabs(v)); } // static double _snd_pow3(double v) { return v*v*v; } static const struct { - char *name; + const char *name; double (*fn)(double); } __sound_fn[] = { // {"lin", _snd_lin}, @@ -70,6 +70,7 @@ SGXmlSound::SGXmlSound() _prev_value(0), _dt_play(0.0), _dt_stop(0.0), + _delay(0.0), _stopping(0.0) { } @@ -120,6 +121,8 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr, SG_LOG(SG_GENERAL, SG_WARN, " Neither a condition nor a property specified"); + _delay = node->getDoubleValue("delay-sec", 0.0); + // // set volume properties // @@ -272,7 +275,8 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSoundMgr *sndmgr, // "alSource". The semantics of what is going on here seems // confused and needs to be thought through more carefully. _sample = new SGSoundSample( path.c_str(), - node->getStringValue("path", "") ); + node->getStringValue("path", ""), + false ); _mgr->add( _sample, _name ); } @@ -325,8 +329,7 @@ SGXmlSound::update (double dt) } // - // If the mode is ONCE and the sound is still playing, - // we have nothing to do anymore. + // mode is ONCE and the sound is still playing? // if (_active && (_mode == SGXmlSound::ONCE)) { @@ -337,16 +340,19 @@ SGXmlSound::update (double dt) _dt_play += dt; } - return; + } else { + + // + // Update the playing time, cache the current value and + // clear the delay timer. + // + _dt_play += dt; + _prev_value = curr_value; + _stopping = 0.0; } - // - // Update the playing time, cache the current value and - // clear the delay timer. - // - _dt_play += dt; - _prev_value = curr_value; - _stopping = 0.0; + if (_dt_play < _delay) + return; // // Update the volume