]> git.mxchange.org Git - flightgear.git/commitdiff
Add a do_play_audio_message() function which is tied to the
authorcurt <curt>
Mon, 9 Jan 2006 02:23:02 +0000 (02:23 +0000)
committercurt <curt>
Mon, 9 Jan 2006 02:23:02 +0000 (02:23 +0000)
"play-audio-function" command.  This function can be called from internal
code, from nasal scripts, or from external scripts to play a single one-off
wav file.  File/audio data is loaded and unloaded on the fly automatically.

src/Main/fg_commands.cxx

index 97f017f22137bcf2557929194b6242c27637039f..2c2e90df30b8a7fa2cc15648069a26c63f74b2dc 100644 (file)
@@ -28,6 +28,7 @@
 #  include <Scripting/scriptmgr.hxx>
 #endif
 #include <Scripting/NasalSys.hxx>
+#include <Sound/fg_fx.hxx>
 #include <Time/sunsolver.hxx>
 #include <Time/tmp.hxx>
 
@@ -1143,6 +1144,24 @@ do_gui_redraw (const SGPropertyNode * arg)
     return true;
 }
 
+/**
+ * Built-in command: play an audio message (i.e. a wav file) This is
+ * fire and forget.  Call this once per message and it will get dumped
+ * into a queue.  Messages are played sequentially so they do not
+ * overlap.
+ */
+static bool
+do_play_audio_message (const SGPropertyNode * arg)
+{
+    FGFX *fx = (FGFX *)globals->get_subsystem("fx");
+    string path = arg->getStringValue("path");
+    string file = arg->getStringValue("file");
+    cout << "playing " << path << " / " << file << endl;
+    fx->play_message( path, file );
+
+    return true;
+}
+
 /**
  * Built-in command: commit presets (read from in /sim/presets/)
  */
@@ -1383,6 +1402,7 @@ static struct {
     { "dialog-update", do_dialog_update },
     { "dialog-apply", do_dialog_apply },
     { "gui-redraw", do_gui_redraw },
+    { "play-audio-message", do_play_audio_message },
     { "presets-commit", do_presets_commit },
     { "log-level", do_log_level },
     { "replay", do_replay },