1
0
Fork 0

New Property layout:

/sim/sound/enabled		enable/disable the use of OpenAL
/sin/sound/pause		master mute, effects all SampleGroups
/sim/sound/volume		master volume
/sim/sound/effects/enabled	enable/disable (mute) sound fx
/sim/sound/effects/volume	effects volume
/sim/sound/chatter/enabled	enable/disable (mute) atc chatter
/sim/sound/chatter/volume	chatter (sample queue) volume
This commit is contained in:
ehofman 2009-11-29 10:24:47 +00:00 committed by Tim Moore
parent 3abb7afa45
commit 3a4892cede
5 changed files with 49 additions and 33 deletions

View file

@ -480,7 +480,23 @@ static void fgMainLoop( void ) {
// Update the sound manager last so it can use the CPU while the GPU
// is processing the scenery (doubled the frame-rate for me) -EMH-
#ifdef ENABLE_AUDIO_SUPPORT
globals->get_soundmgr()->update(delta_time_sec);
static SGPropertyNode *sound_pause = fgGetNode("/sim/sound/pause");
static SGSoundMgr *smgr = globals->get_soundmgr();
static bool smgr_suspend = false;
if (smgr_suspend != sound_pause->getBoolValue()) {
if (smgr_suspend == false) { // request to suspend
smgr->suspend();
} else {
smgr->resume();
}
smgr_suspend = sound_pause->getBoolValue();
}
if (smgr_suspend == false) {
static SGPropertyNode *volume = fgGetNode("/sim/sound/volume");
smgr->set_volume(volume->getFloatValue());
smgr->update(delta_time_sec);
}
#endif
// END Tile Manager udpates
@ -488,15 +504,11 @@ static void fgMainLoop( void ) {
if (!scenery_loaded && globals->get_tile_mgr()->isSceneryLoaded()
&& cur_fdm_state->get_inited()) {
fgSetBool("sim/sceneryloaded",true);
#ifdef ENABLE_AUDIO_SUPPORT
if (fgGetBool("/sim/sound/enabled") == true) {
float volume = fgGetFloat("/sim/sound/volume");
globals->get_soundmgr()->set_volume(volume);
globals->get_soundmgr()->activate();
if (fgGetBool("/sim/sound/enabled")) {
smgr->activate();
} else {
smgr->stop();
}
else
globals->get_soundmgr()->stop();
#endif
}
fgRequestRedraw();

View file

@ -39,16 +39,18 @@
#include <simgear/sound/xmlsound.hxx>
FGFX::FGFX ( SGSoundMgr *smgr, const string &refname ) :
last_pause( false ),
last_enabled( true ),
last_volume( 0.0 ),
_pause( fgGetNode("/sim/sound/pause") ),
_volume( fgGetNode("/sim/sound/volume") )
_enabled( fgGetNode("/sim/sound/effects/enabled", true) ),
_volume( fgGetNode("/sim/sound/effects/volume", true) )
{
SGSampleGroup::_smgr = smgr;
SGSampleGroup::_refname = refname;
SGSampleGroup::_smgr->add(this, refname);
_avionics = _smgr->find("avionics", true);
_avionics->tie_to_listener();
_enabled->setBoolValue(true);
_volume->setFloatValue(1.0);
}
@ -116,17 +118,17 @@ FGFX::reinit()
void
FGFX::update (double dt)
{
bool new_pause = _pause->getBoolValue();
if ( new_pause != last_pause ) {
if ( new_pause ) {
suspend();
} else {
bool new_enabled = _enabled->getBoolValue();
if ( new_enabled != last_enabled ) {
if ( new_enabled ) {
resume();
} else {
suspend();
}
last_pause = new_pause;
last_enabled = new_enabled;
}
if ( !new_pause ) {
if ( new_enabled ) {
double volume = _volume->getDoubleValue();
if ( volume != last_volume ) {
set_volume( volume );

View file

@ -60,10 +60,10 @@ private:
SGSharedPtr<SGSampleGroup> _avionics;
std::vector<SGXmlSound *> _sound;
bool last_pause;
bool last_enabled;
double last_volume;
SGPropertyNode_ptr _pause;
SGPropertyNode_ptr _enabled;
SGPropertyNode_ptr _volume;
};

View file

@ -37,14 +37,16 @@
#include <simgear/sound/sample_openal.hxx>
FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const string &refname ) :
last_pause( false ),
last_enabled( true ),
last_volume( 0.0 ),
_pause( fgGetNode("/sim/sound/pause") ),
_volume( fgGetNode("/sim/sound/volume") )
_enabled( fgGetNode("/sim/sound/chatter/enabled", true) ),
_volume( fgGetNode("/sim/sound/chatter/volume", true) )
{
SGSampleGroup::_smgr = smgr;
SGSampleGroup::_smgr->add(this, refname);
SGSampleGroup::_refname = refname;
_enabled->setBoolValue(true);
_volume->setFloatValue(1.0);
}
@ -61,17 +63,17 @@ void
FGSampleQueue::update (double dt)
{
// command sound manger
bool new_pause = _pause->getBoolValue();
if ( new_pause != last_pause ) {
if ( new_pause ) {
suspend();
} else {
bool new_enabled = _enabled->getBoolValue();
if ( new_enabled != last_enabled ) {
if ( new_enabled ) {
resume();
} else {
suspend();
}
last_pause = new_pause;
last_enabled = new_enabled;
}
if ( !new_pause ) {
if ( new_enabled ) {
double volume = _volume->getDoubleValue();
if ( volume != last_volume ) {
set_volume( volume );

View file

@ -57,10 +57,10 @@ private:
std::queue< SGSharedPtr<SGSoundSample> > _messages;
bool last_pause;
bool last_enabled;
double last_volume;
SGPropertyNode_ptr _pause;
SGPropertyNode_ptr _enabled;
SGPropertyNode_ptr _volume;
};