From 2c9d64dcc66892b51610df61b1c083aeeab59ff7 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Fri, 13 Mar 2020 11:13:30 +0100 Subject: [PATCH] Fix broken sound mute function Fixes #2146 --- src/Main/fg_props.cxx | 10 ---------- src/Sound/soundmanager.cxx | 6 ++++-- src/Sound/soundmanager.hxx | 1 + 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 2058f0db1..eee6d0006 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -230,16 +230,6 @@ setFreeze (bool f) { frozen = f; - // Stop sound on a pause - SGSoundMgr *smgr = globals->get_subsystem(); - if ( smgr != NULL ) { - if ( f ) { - smgr->suspend(); - } else if (fgGetBool("/sim/sound/working")) { - smgr->resume(); - } - } - // Pause the particle system simgear::Particles::setFrozen(f); } diff --git a/src/Sound/soundmanager.cxx b/src/Sound/soundmanager.cxx index bf6b72a23..a78a79514 100644 --- a/src/Sound/soundmanager.cxx +++ b/src/Sound/soundmanager.cxx @@ -76,6 +76,8 @@ void FGSoundManager::init() _velocityEastFPS = fgGetNode("velocities/speed-east-fps", true); _velocityDownFPS = fgGetNode("velocities/speed-down-fps", true); + _frozen = fgGetNode("sim/freeze/master"); + SGPropertyNode_ptr scenery_loaded = fgGetNode("sim/sceneryloaded", true); scenery_loaded->addChangeListener(_listener.get()); @@ -159,9 +161,9 @@ bool FGSoundManager::stationaryView() const // Actual sound update is triggered by the subsystem manager. void FGSoundManager::update(double dt) { - if (is_active() && _is_initialized && _sound_working->getBoolValue()) + if (is_working() && _is_initialized && _sound_working->getBoolValue()) { - bool enabled = _sound_enabled->getBoolValue(); + bool enabled = _sound_enabled->getBoolValue() && !_frozen->getBoolValue(); if (enabled != _enabled) { if (enabled) diff --git a/src/Sound/soundmanager.hxx b/src/Sound/soundmanager.hxx index 94810a6be..b4387a6b6 100644 --- a/src/Sound/soundmanager.hxx +++ b/src/Sound/soundmanager.hxx @@ -63,6 +63,7 @@ private: bool _is_initialized, _enabled; SGPropertyNode_ptr _sound_working, _sound_enabled, _volume, _device_name; SGPropertyNode_ptr _velocityNorthFPS, _velocityEastFPS, _velocityDownFPS; + SGPropertyNode_ptr _frozen; std::unique_ptr _listener; std::map _synthesizers;