From 5acf2e26d085b7553b2387b9753e9253e8b4bff4 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Mon, 12 Sep 2022 09:52:31 +0200 Subject: [PATCH] Add a special queue-name 'instant' which does not put samples into a sample queue but plays them instantly. --- src/Sound/soundmanager.cxx | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Sound/soundmanager.cxx b/src/Sound/soundmanager.cxx index e527b1a89..b8a9fe7b4 100644 --- a/src/Sound/soundmanager.cxx +++ b/src/Sound/soundmanager.cxx @@ -224,14 +224,25 @@ bool FGSoundManager::playAudioSampleCommand(const SGPropertyNode * arg, SGProper // SG_LOG(SG_GENERAL, SG_ALERT, "Playing '" << foundPath.utf8Str() << "'"); try { - if ( !_queue[name] ) { - _queue[name] = new FGSampleQueue(this, name); - _queue[name]->tie_to_listener(); - } - SGSoundSample *msg = new SGSoundSample(foundPath); msg->set_volume( volume ); - _queue[name]->add( msg ); + + if (name == "instant") + { + // Add a special queue-name 'instant' which does not put samples + // into a sample queue but plays them instantly. + SGSampleGroup* sgr = find("NASAL instant queue", true); + sgr->add(msg, foundPath.str()); + sgr->play_once(foundPath.str()); + } + else + { + if ( !_queue[name] ) { + _queue[name] = new FGSampleQueue(this, name); + _queue[name]->tie_to_listener(); + } + _queue[name]->add( msg ); + } return true;