From e8db3a514a3b24bb7b5e8d1395ce078c768981ab Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 8 Sep 2009 13:51:24 +0000 Subject: [PATCH] Dont execute code in case the soundmanager isn't properly initialized --- src/Sound/beacon.cxx | 4 ++++ src/Sound/fg_fx.cxx | 11 +++++------ src/Sound/morse.cxx | 5 +++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Sound/beacon.cxx b/src/Sound/beacon.cxx index 1f9d6b306..ad938c0c6 100644 --- a/src/Sound/beacon.cxx +++ b/src/Sound/beacon.cxx @@ -41,6 +41,10 @@ bool FGBeacon::init() { int len; unsigned char *ptr; + if (globals->get_soundmgr()->is_working() == false) { + return false; + } + unsigned char inner_buf[ INNER_SIZE ] ; unsigned char middle_buf[ MIDDLE_SIZE ] ; unsigned char outer_buf[ OUTER_SIZE ] ; diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index cb78616e8..caff002e2 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -202,13 +202,12 @@ FGFX::play_message( SGSoundSample *_sample ) void FGFX::play_message( const string path, const string fname, double volume ) { - if (globals->get_soundmgr()->is_working() == false) { - return; + if (globals->get_soundmgr()->is_working() == true) { + SGSoundSample *sample; + sample = new SGSoundSample( path.c_str(), fname.c_str() ); + sample->set_volume( volume ); + play_message( sample ); } - SGSoundSample *sample; - sample = new SGSoundSample( path.c_str(), fname.c_str() ); - sample->set_volume( volume ); - play_message( sample ); } void diff --git a/src/Sound/morse.cxx b/src/Sound/morse.cxx index 674fa991a..92b671bca 100644 --- a/src/Sound/morse.cxx +++ b/src/Sound/morse.cxx @@ -167,6 +167,11 @@ bool FGMorse::cust_init(const int freq ) { // make a SGSoundSample morse code transmission for the specified string SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) { + + if (globals->get_soundmgr()->is_working() == false) { + return 0; + } + char *idptr = (char *)id.c_str(); int length = 0;