- // 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-
-#ifdef ENABLE_AUDIO_SUPPORT
- static bool smgr_init = true;
- static SGPropertyNode *sound_working = fgGetNode("/sim/sound/working");
- if (smgr_init == true) {
- if (sound_working->getBoolValue() == true) {
- fgInitSoundManager();
- smgr_init = false;
- }
- } else {
- static SGPropertyNode *sound_enabled = fgGetNode("/sim/sound/enabled");
- static SGSoundMgr *smgr = globals->get_soundmgr();
- static bool smgr_enabled = true;
-
- if (sound_working->getBoolValue() == false) { // request to reinit
- smgr->reinit();
- smgr->resume();
- sound_working->setBoolValue(true);
- }
-
- if (smgr_enabled != sound_enabled->getBoolValue()) {
- if (smgr_enabled == true) { // request to suspend
- smgr->suspend();
- smgr_enabled = false;
- } else {
- smgr->resume();
- smgr_enabled = 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)
- {
- if (globals->get_tile_mgr()->isSceneryLoaded()
- && fgGetBool("sim/fdm-initialized")) {
- fgSetBool("sim/sceneryloaded",true);
- fgSplashProgress("");
- if (fgGetBool("/sim/sound/working")) {
- globals->get_soundmgr()->activate();
- }
- globals->get_props()->tie("/sim/sound/devices/name",
- SGRawValueFunctions<const char *>(0, fgSetNewSoundDevice), false);
- }
- else
- {
- fgSplashProgress("loading scenery");
- // be nice to loader threads while waiting for initial scenery, reduce to 2fps
- simgear::sleepForMSec(500);
- }
- }
-
- // print timing statistics
- static bool _lastStatisticsFlag = false;
- if (_lastStatisticsFlag != _statisticsFlag->getBoolValue())
- {
- // flag has changed, update subsystem manager
- _lastStatisticsFlag = _statisticsFlag->getBoolValue();
- globals->get_subsystem_mgr()->collectDebugTiming(_lastStatisticsFlag);
- }
- if (_lastStatisticsFlag)
- {
- static double elapsed = 0;
- elapsed += real_dt;
- if (elapsed >= _statisticsInterval->getDoubleValue())
- {
- // print and reset timing statistics
- globals->get_subsystem_mgr()->printTimingStatistics(_statiticsMinTime->getDoubleValue(),
- _statiticsMinJitter->getDoubleValue());
- elapsed = 0;
- }
- }
-