1
0
Fork 0

Allow for multiple named chatter queue's

This commit is contained in:
Erik Hofman 2018-05-29 09:31:01 +02:00
parent e7cb004690
commit dcec806337
3 changed files with 10 additions and 8 deletions

View file

@ -39,8 +39,8 @@
FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
last_enabled( true ),
last_volume( 0.0 ),
_enabled( fgGetNode("/sim/sound/chatter/enabled", true) ),
_volume( fgGetNode("/sim/sound/chatter/volume", true) )
_enabled( fgGetNode("/sim/sound/"+refname+"/enabled", true) ),
_volume( fgGetNode("/sim/sound/"+refname+"/volume", true) )
{
SGSampleGroup::_smgr = smgr;
SGSampleGroup::_smgr->add(this, refname);

View file

@ -97,7 +97,7 @@ void FGSoundManager::shutdown()
stop();
_chatterQueue.clear();
_queue.clear();
globals->get_commands()->removeCommand("play-audio-sample");
@ -210,19 +210,21 @@ void FGSoundManager::update(double dt)
*/
bool FGSoundManager::playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root)
{
const char *qname = arg->getStringValue("queue");
string name = qname ? qname : "chatter";
string path = arg->getStringValue("path");
string file = arg->getStringValue("file");
float volume = arg->getFloatValue("volume");
// cout << "playing " << path << " / " << file << endl;
try {
if ( !_chatterQueue ) {
_chatterQueue = new FGSampleQueue(this, "chatter");
_chatterQueue->tie_to_listener();
if ( !_queue[name] ) {
_queue[name] = new FGSampleQueue(this, name);
_queue[name]->tie_to_listener();
}
SGSoundSample *msg = new SGSoundSample(file.c_str(), path);
msg->set_volume( volume );
_chatterQueue->add( msg );
_queue[name]->add( msg );
return true;

View file

@ -55,7 +55,7 @@ private:
bool playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root);
SGSharedPtr<FGSampleQueue> _chatterQueue;
std::map<std::string,SGSharedPtr<FGSampleQueue>> _queue;
double _active_dt;
bool _is_initialized, _enabled;