From 2b83ed9cbe6d8ce02880197668e4928e6d0e4b95 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sat, 10 Apr 2010 09:37:22 +0000 Subject: [PATCH 1/2] allow reinitializing the sound system by setting /sim/sound/working to false at runtime. --- src/Main/main.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 8ac54aa56..210434a7b 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -485,8 +485,8 @@ static void fgMainLoop( void ) { // 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) { - static SGPropertyNode *sound_working = fgGetNode("/sim/sound/working"); if (sound_working->getBoolValue() == true) { fgInitSoundManager(); smgr_init = false; @@ -496,6 +496,11 @@ static void fgMainLoop( void ) { static SGSoundMgr *smgr = globals->get_soundmgr(); static bool smgr_enabled = true; + if (sound_working->getBoolValue() == false) { // request to reinit + smgr->reinit(); + sound_working->setBoolValue(true); + } + if (smgr_enabled != sound_enabled->getBoolValue()) { if (smgr_enabled == true) { // request to suspend smgr->suspend(); From 5d0d6998d2e1e5322920aec7cda7b65f37e2e039 Mon Sep 17 00:00:00 2001 From: ehofman Date: Sat, 10 Apr 2010 09:46:27 +0000 Subject: [PATCH 2/2] Don't forget to resume the sound system after reinit --- src/Main/main.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 210434a7b..e1a50d6c3 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -498,6 +498,7 @@ static void fgMainLoop( void ) { if (sound_working->getBoolValue() == false) { // request to reinit smgr->reinit(); + smgr->resume(); sound_working->setBoolValue(true); }