1
0
Fork 0

Postpone initialization of the avionics soundgroup until avionics are enabled. This prevents AI classes from creating new and unnecessary avionics sample groups.

This commit is contained in:
Erik Hofman 2011-11-20 15:31:58 +01:00
parent 544bad86c7
commit 04395fa9a5
2 changed files with 19 additions and 8 deletions

View file

@ -314,7 +314,7 @@ bool FGAIBase::init(bool search_in_AI_path) {
// Get the sound-path tag from the configuration file and store it
// in the property tree.
string fxpath = props->getStringValue("/sim/sound/path");
string fxpath = props->getStringValue("sim/sound/path");
if ( !fxpath.empty() )
{
props->setStringValue("sim/sound/path", fxpath.c_str());

View file

@ -54,8 +54,12 @@ FGFX::FGFX ( SGSoundMgr *smgr, const string &refname, SGPropertyNode *props ) :
SGSampleGroup::_smgr = smgr;
SGSampleGroup::_refname = refname;
SGSampleGroup::_smgr->add(this, refname);
_avionics = _smgr->find("avionics", true);
_avionics->tie_to_listener();
if (_avionics_enabled->getBoolValue())
{
_avionics = _smgr->find("avionics", true);
_avionics->tie_to_listener();
}
}
@ -128,11 +132,18 @@ FGFX::update (double dt)
bool active = _avionics_ext->getBoolValue() ||
_internal->getBoolValue();
if ( active && _avionics_enabled->getBoolValue() ) {
_avionics->resume(); // no-op if already in resumed state
} else
_avionics->suspend();
_avionics->set_volume( _avionics_volume->getFloatValue() );
if (_avionics_enabled->getBoolValue()) {
if (!_avionics) {
_avionics = _smgr->find("avionics", true);
_avionics->tie_to_listener();
}
if ( active )
_avionics->resume(); // no-op if already in resumed state
else
_avionics->suspend();
_avionics->set_volume( _avionics_volume->getFloatValue() );
}
if ( _enabled->getBoolValue() ) {
set_volume( _volume->getDoubleValue() );