Allow for multiple named chatter queue's
This commit is contained in:
parent
e7cb004690
commit
dcec806337
3 changed files with 10 additions and 8 deletions
|
@ -39,8 +39,8 @@
|
||||||
FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
|
FGSampleQueue::FGSampleQueue ( SGSoundMgr *smgr, const std::string &refname ) :
|
||||||
last_enabled( true ),
|
last_enabled( true ),
|
||||||
last_volume( 0.0 ),
|
last_volume( 0.0 ),
|
||||||
_enabled( fgGetNode("/sim/sound/chatter/enabled", true) ),
|
_enabled( fgGetNode("/sim/sound/"+refname+"/enabled", true) ),
|
||||||
_volume( fgGetNode("/sim/sound/chatter/volume", true) )
|
_volume( fgGetNode("/sim/sound/"+refname+"/volume", true) )
|
||||||
{
|
{
|
||||||
SGSampleGroup::_smgr = smgr;
|
SGSampleGroup::_smgr = smgr;
|
||||||
SGSampleGroup::_smgr->add(this, refname);
|
SGSampleGroup::_smgr->add(this, refname);
|
||||||
|
|
|
@ -97,7 +97,7 @@ void FGSoundManager::shutdown()
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
_chatterQueue.clear();
|
_queue.clear();
|
||||||
globals->get_commands()->removeCommand("play-audio-sample");
|
globals->get_commands()->removeCommand("play-audio-sample");
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,19 +210,21 @@ void FGSoundManager::update(double dt)
|
||||||
*/
|
*/
|
||||||
bool FGSoundManager::playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root)
|
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 path = arg->getStringValue("path");
|
||||||
string file = arg->getStringValue("file");
|
string file = arg->getStringValue("file");
|
||||||
float volume = arg->getFloatValue("volume");
|
float volume = arg->getFloatValue("volume");
|
||||||
// cout << "playing " << path << " / " << file << endl;
|
// cout << "playing " << path << " / " << file << endl;
|
||||||
try {
|
try {
|
||||||
if ( !_chatterQueue ) {
|
if ( !_queue[name] ) {
|
||||||
_chatterQueue = new FGSampleQueue(this, "chatter");
|
_queue[name] = new FGSampleQueue(this, name);
|
||||||
_chatterQueue->tie_to_listener();
|
_queue[name]->tie_to_listener();
|
||||||
}
|
}
|
||||||
|
|
||||||
SGSoundSample *msg = new SGSoundSample(file.c_str(), path);
|
SGSoundSample *msg = new SGSoundSample(file.c_str(), path);
|
||||||
msg->set_volume( volume );
|
msg->set_volume( volume );
|
||||||
_chatterQueue->add( msg );
|
_queue[name]->add( msg );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
|
|
||||||
bool playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root);
|
bool playAudioSampleCommand(const SGPropertyNode * arg, SGPropertyNode * root);
|
||||||
|
|
||||||
SGSharedPtr<FGSampleQueue> _chatterQueue;
|
std::map<std::string,SGSharedPtr<FGSampleQueue>> _queue;
|
||||||
|
|
||||||
double _active_dt;
|
double _active_dt;
|
||||||
bool _is_initialized, _enabled;
|
bool _is_initialized, _enabled;
|
||||||
|
|
Loading…
Reference in a new issue