]> git.mxchange.org Git - flightgear.git/commitdiff
Stop the sound when paused. We really need a separate control for
authordavid <david>
Fri, 19 Apr 2002 04:00:02 +0000 (04:00 +0000)
committerdavid <david>
Fri, 19 Apr 2002 04:00:02 +0000 (04:00 +0000)
muting, but that will have to wait until someone has time.

src/Main/fg_props.cxx
src/Sound/soundmgr.cxx
src/Sound/soundmgr.hxx

index 3da3334eda518fda571e68a903e7b277bacb45c5..33f9e2028fb49fc911a787055a28091c770a7704 100644 (file)
@@ -42,6 +42,7 @@
 #include <Objects/matlib.hxx>
 
 #include <GUI/gui.h>
+#include <Sound/soundmgr.hxx>
 
 #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
+
 
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -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);
index eb2f41fd7461f10386f3b176de39d0bf2951e521..41947bb0f8703172e8f7f129dcaf25fe4433bf0e 100644 (file)
@@ -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 ) {
 
index 7503a1719f8d2bd4113ef84c5ca0c4f95361c3f3..fbab39fc469ad74194eb000ee7a0d497c8173c5e 100644 (file)
@@ -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(); }