// splash screen up and running right away.
int idle_state = 0;
-
-void fgInitSoundManager();
-void fgSetNewSoundDevice(const char *);
-
// The atexit() function handler should know when the graphical subsystem
// is initialized.
extern int _bootstrap_OSInit;
-// What should we do when we have nothing else to do? Let's get ready
-// for the next move and update the display?
-static void fgMainLoop( void )
+
+void fgInitSoundManager()
{
- static SGPropertyNode_ptr frame_signal
- = fgGetNode("/sim/signals/frame", true);
+ SGSoundMgr *smgr = globals->get_soundmgr();
- frame_signal->fireValueChanged();
-
- SG_LOG( SG_GENERAL, SG_DEBUG, "Running Main Loop");
- SG_LOG( SG_GENERAL, SG_DEBUG, "======= ==== ====");
-
-
- // update "time"
- double sim_dt, real_dt;
- TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time");
- // compute simulated time (allowing for pause, warp, etc) and
- // real elapsed time
- timeMgr->computeTimeDeltas(sim_dt, real_dt);
+ smgr->bind();
+ smgr->init(fgGetString("/sim/sound/device-name", NULL));
- // update magvar model
- globals->get_mag()->update( globals->get_aircraft_position(),
- globals->get_time_params()->getJD() );
+ vector <const char*>devices = smgr->get_available_devices();
+ for (unsigned int i=0; i<devices.size(); i++) {
+ SGPropertyNode *p = fgGetNode("/sim/sound/devices/device", i, true);
+ p->setStringValue(devices[i]);
+ }
+ devices.clear();
+}
- globals->get_subsystem_mgr()->update(sim_dt);
+void fgSetNewSoundDevice(const char *device)
+{
+ SGSoundMgr *smgr = globals->get_soundmgr();
+ smgr->suspend();
+ smgr->stop();
+ smgr->init(device);
+ smgr->resume();
+}
- // Update the sound manager last so it can use the CPU while the GPU
- // is processing the scenery (doubled the frame-rate for me) -EMH-
+// Update sound manager state (init/suspend/resume) and propagate property values,
+// since the sound manager doesn't read any properties itself.
+// Actual sound update is triggered by the subsystem manager.
+static void fgUpdateSound(double dt)
+{
#ifdef ENABLE_AUDIO_SUPPORT
static bool smgr_init = true;
static SGPropertyNode *sound_working = fgGetNode("/sim/sound/working");
static SGSoundMgr *smgr = globals->get_soundmgr();
static bool smgr_enabled = true;
- if (sound_working->getBoolValue() == false) { // request to reinit
+ if (sound_working->getBoolValue() == false) { // request to reinit
smgr->reinit();
smgr->resume();
sound_working->setBoolValue(true);
if (smgr_enabled == true) {
static SGPropertyNode *volume = fgGetNode("/sim/sound/volume");
smgr->set_volume(volume->getFloatValue());
- smgr->update(sim_dt);
}
}
#endif
+}
- // END Tile Manager updates
- bool scenery_loaded = fgGetBool("sim/sceneryloaded");
- if (!scenery_loaded)
+static void fgLoadInitialScenery()
+{
+ static SGPropertyNode_ptr scenery_loaded
+ = fgGetNode("sim/sceneryloaded", true);
+
+ if (!scenery_loaded->getBoolValue())
{
if (globals->get_tile_mgr()->isSceneryLoaded()
&& fgGetBool("sim/fdm-initialized")) {
SGTimeStamp::sleepForMSec(500);
}
}
-
- simgear::AtomicChangeListener::fireChangeListeners();
-
- SG_LOG( SG_GENERAL, SG_DEBUG, "" );
}
-void fgInitSoundManager()
+// What should we do when we have nothing else to do? Let's get ready
+// for the next move and update the display?
+static void fgMainLoop( void )
{
- SGSoundMgr *smgr = globals->get_soundmgr();
+ static SGPropertyNode_ptr frame_signal
+ = fgGetNode("/sim/signals/frame", true);
- smgr->bind();
- smgr->init(fgGetString("/sim/sound/device-name", NULL));
+ frame_signal->fireValueChanged();
- vector <const char*>devices = smgr->get_available_devices();
- for (unsigned int i=0; i<devices.size(); i++) {
- SGPropertyNode *p = fgGetNode("/sim/sound/devices/device", i, true);
- p->setStringValue(devices[i]);
- }
- devices.clear();
-}
+ SG_LOG( SG_GENERAL, SG_DEBUG, "Running Main Loop");
+ SG_LOG( SG_GENERAL, SG_DEBUG, "======= ==== ====");
-void fgSetNewSoundDevice(const char *device)
-{
- globals->get_soundmgr()->suspend();
- globals->get_soundmgr()->stop();
- globals->get_soundmgr()->init(device);
- globals->get_soundmgr()->resume();
+ // compute simulated time (allowing for pause, warp, etc) and
+ // real elapsed time
+ double sim_dt, real_dt;
+ TimeManager* timeMgr = (TimeManager*) globals->get_subsystem("time");
+ timeMgr->computeTimeDeltas(sim_dt, real_dt);
+
+ // update magvar model
+ globals->get_mag()->update( globals->get_aircraft_position(),
+ globals->get_time_params()->getJD() );
+
+ // Propagate sound manager properties (note: actual update is triggered
+ // by the subsystem manager).
+ fgUpdateSound(sim_dt);
+
+ // update all subsystems
+ globals->get_subsystem_mgr()->update(sim_dt);
+
+ // END Tile Manager updates
+ fgLoadInitialScenery();
+
+ simgear::AtomicChangeListener::fireChangeListeners();
+
+ SG_LOG( SG_GENERAL, SG_DEBUG, "" );
}
// Operation for querying OpenGL parameters. This must be done in a