1
0
Fork 0

Stop the sound when paused. We really need a separate control for

muting, but that will have to wait until someone has time.
This commit is contained in:
david 2002-04-19 04:00:02 +00:00
parent 4656e3adca
commit eea531fbf5
3 changed files with 55 additions and 1 deletions

View 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
////////////////////////////////////////////////////////////////////////
@ -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);

View 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 ) {

View 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(); }