From eea531fbf5941a09dfcbb1f5a2b8305401e75fed Mon Sep 17 00:00:00 2001 From: david Date: Fri, 19 Apr 2002 04:00:02 +0000 Subject: [PATCH] Stop the sound when paused. We really need a separate control for muting, but that will have to wait until someone has time. --- src/Main/fg_props.cxx | 30 +++++++++++++++++++++++++++++- src/Sound/soundmgr.cxx | 14 ++++++++++++++ src/Sound/soundmgr.hxx | 12 ++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 3da3334ed..33f9e2028 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -42,6 +42,7 @@ #include #include +#include #include "globals.hxx" #include "fgfs.hxx" @@ -62,6 +63,8 @@ static bool winding_ccw = true; // FIXME: temporary static bool fdm_data_logging = false; // FIXME: temporary +static bool frozen = false; // FIXME: temporary + //////////////////////////////////////////////////////////////////////// @@ -213,6 +216,31 @@ setLoggingPriority (const char * p) } +/** + * Return the current frozen state. + */ +static bool +getFreeze () +{ + return frozen; +} + + +/** + * Set the current frozen state. + */ +static void +setFreeze (bool f) +{ + frozen = f; + // Stop sound on a pause + if (f) + globals->get_soundmgr()->pause(); + else + globals->get_soundmgr()->resume(); +} + + /** * Return the current aircraft directory (UIUC) as a string. */ @@ -549,7 +577,7 @@ fgInitProps () // Simulation fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority); fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses); - // fgTie("/sim/freeze", getFreeze, setFreeze); + fgTie("/sim/freeze/master", getFreeze, setFreeze); fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir); fgTie("/sim/time/elapsed-ms", getElapsedTime_ms); diff --git a/src/Sound/soundmgr.cxx b/src/Sound/soundmgr.cxx index eb2f41fd7..41947bb0f 100644 --- a/src/Sound/soundmgr.cxx +++ b/src/Sound/soundmgr.cxx @@ -230,6 +230,20 @@ void FGSoundMgr::update(int dt) { } +void +FGSoundMgr::pause () +{ + audio_sched->pauseSample(0, 0); +} + + +void +FGSoundMgr::resume () +{ + audio_sched->resumeSample(0, 0); +} + + // add a sound effect, return true if successful bool FGSoundMgr::add( FGSimpleSound *sound, const string& refname ) { diff --git a/src/Sound/soundmgr.hxx b/src/Sound/soundmgr.hxx index 7503a1719..fbab39fc4 100644 --- a/src/Sound/soundmgr.hxx +++ b/src/Sound/soundmgr.hxx @@ -148,6 +148,18 @@ public: void update(int dt); + /** + * Pause all sounds. + */ + void pause (); + + + /** + * Resume all sounds. + */ + void resume (); + + // is audio working? inline bool is_working() const { return !audio_sched->notWorking(); } -- 2.39.5