1
0
Fork 0

Don't crash on start-up when avionics sound is disabled.

FGFX::init/soundfx::init use "_avionics" unconditionally, so it has to be
valid, even when avionics sound is disabled. Also allow to properly
enable/disable avioncis sound at run-time.
This commit is contained in:
ThorstenB 2012-03-22 23:36:39 +01:00
parent 22c20a2f09
commit 7d37f6af58

View file

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