diff --git a/src/ATCDCL/AIPlane.cxx b/src/ATCDCL/AIPlane.cxx index 1db5820ec..f672676eb 100644 --- a/src/ATCDCL/AIPlane.cxx +++ b/src/ATCDCL/AIPlane.cxx @@ -29,6 +29,8 @@ using std::string; #include "AIPlane.hxx" +SGSampleGroup *FGAIPlane::_sgr = 0; + FGAIPlane::FGAIPlane() { leg = LEG_UNKNOWN; tuned_station = NULL; @@ -47,18 +49,18 @@ FGAIPlane::FGAIPlane() { _trackSet = false; _tgtRoll = 0.0; _rollSuspended = false; - _sgr = 0; + + if ( !_sgr ) { + SGSoundMgr *smgr; + smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr"); + _sgr = smgr->find("atc", true); + } } FGAIPlane::~FGAIPlane() { } void FGAIPlane::Update(double dt) { - if (!_sgr) { - SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr"); - if (smgr) _sgr = smgr->find("atc", true); - } - if(_pending) { if(tuned_station) { if(tuned_station->GetFreqClear()) { diff --git a/src/ATCDCL/AIPlane.hxx b/src/ATCDCL/AIPlane.hxx index aba6e7b7e..e099cdfac 100644 --- a/src/ATCDCL/AIPlane.hxx +++ b/src/ATCDCL/AIPlane.hxx @@ -160,7 +160,7 @@ private: double _tgtRoll; bool _rollSuspended; // Set true when a derived class has suspended AIPlane's roll control - SGSampleGroup *_sgr; + static SGSampleGroup *_sgr; }; #endif // _FG_AI_PLANE_HXX diff --git a/src/ATCDCL/ATC.cxx b/src/ATCDCL/ATC.cxx index ed62bad03..92568edc5 100644 --- a/src/ATCDCL/ATC.cxx +++ b/src/ATCDCL/ATC.cxx @@ -56,6 +56,9 @@ FGATC::FGATC() : _counter(0.0), _max_count(5.0) { + SGSoundMgr *smgr; + smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr"); + _sgr = smgr->find("atc", true); } FGATC::~FGATC() { @@ -238,11 +241,6 @@ void FGATC::Render(string& msg, const float volume, new SGSoundSample((unsigned char*) buf.c_str(), buf.length(), 8000); // TODO - at the moment the volume can't be changed // after the transmission has started. - if (!_sgr) { - SGSoundMgr *smgr; - smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr"); - _sgr = smgr->find("atc", true); - } simple->set_volume(volume); _sgr->add(simple, refname); _sgr->play(refname, repeating); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 10bded7bb..92d32a1ca 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -57,6 +57,7 @@ #include #include #include +#include #include #include @@ -103,9 +104,6 @@ #include #include #include -#include -#include -#include #include #include #include