static void fgMainLoop( void ) {
// Update the elapsed time.
+ static bool first_time = true;
+ if ( first_time ) {
+ last_time_stamp.stamp();
+ first_time = false;
+ }
current_time_stamp.stamp();
delta_time_sec = double(current_time_stamp - last_time_stamp) / 1000000.0;
last_time_stamp = current_time_stamp;
#ifdef ENABLE_AUDIO_SUPPORT
if ( fgGetBool("/sim/sound/audible")
&& globals->get_soundmgr()->is_working() ) {
- globals->get_fx()->update(1); // FIXME: use dt
- globals->get_soundmgr()->update(1); // FIXME: use dt
+ static double dt = 0.0;
+ static double sound_update_rate = 0.05;
+
+ dt += delta_time_sec;
+
+ // Updating four times a second should be enough
+ if ( dt >= sound_update_rate ) {
+ globals->get_fx()->update( dt );
+ globals->get_soundmgr()->update( dt );
+ dt = 0.0;
+ }
}
#endif
volume.intern = &_dt_play;
else if (!strcmp(intern_str, "dt_stop"))
volume.intern = &_dt_stop;
- else if (!strcmp(intern_str, "random"))
- volume.intern = &_random;
if ((volume.factor = kids[i]->getDoubleValue("factor", 1.0)) != 0.0)
if (volume.factor < 0.0) {
)
{
- _active = false;
- _dt_stop += dt;
- _dt_play = 0.0;
-
if (_sample->is_playing()) {
SG_LOG(SG_GENERAL, SG_INFO, "Stopping audio after " << _dt_play
<< " sec: " << _name );
_sample->stop( _mgr->get_scheduler() );
}
+ _active = false;
+ _dt_stop += dt;
+ _dt_play = 0.0;
+
return;
}
}
//
- // Update playtime, cache the current value and feed the random number
+ // Update playing time and cache the current value.
//
_dt_play += dt;
_prev_value = curr_value;