]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
toggle audio output via a rigctl command
authorRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 4 Nov 2023 10:54:32 +0000 (16:24 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Sat, 4 Nov 2023 10:54:32 +0000 (16:24 +0530)
This would enable a frontpanel switch to select the audio output by
sending a command to rigctl.

rigctl.c
rx_menu.c
rx_menu.h

index 14f09d3be9e8618435c3eacbd83b6f8b99e10d30..9143ee04456203d1a1de4ca9947521ce190e7c6b 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
@@ -44,6 +44,7 @@
 #include "receiver.h"
 #include "rigctl.h"
 #include "rigctl_menu.h"
+#include "rx_menu.h"
 #include "sliders.h"
 #include "store.h"
 #include "toolbar.h"
@@ -958,6 +959,11 @@ gboolean parse_extended_cmd(char *command, CLIENT *client) {
     case 'I': // ZZAI
       implemented = FALSE;
       break;
+    case 'O': // ZZAO
+       if (command[4] == ';') {
+           toggle_audio_output_device();
+       }
+       break;
     case 'P': // ZZAP
       implemented = FALSE;
       break;
index ad1e7aa94db22ebfa8dd0e4e4c77896945025981..2708bb26bb0b40ec5e4fddba206def37c4da89d2 100644 (file)
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -140,6 +140,18 @@ static void mute_radio_cb(GtkWidget *widget, gpointer data) {
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 }
 
+void toggle_audio_output_device(void) {
+    // n_output_devices holds the number of output devices (global -
+    // aargh!!)
+    int out_index = gtk_combo_box_get_active(GTK_COMBO_BOX(output));
+
+    // toggle
+    out_index = (out_index + 1) % n_output_devices;
+
+    // set the other device as active
+    gtk_combo_box_set_active(GTK_COMBO_BOX(output), out_index);
+}
+
 //
 // possible the device has been changed:
 // call audo_close_output with old device, audio_open_output with new one
index b3d06c5672076d1cdac325c9aebd433c09aa020a..1342234f62dce8ffc833f0724f2770005b0608a8 100644 (file)
--- a/rx_menu.h
+++ b/rx_menu.h
@@ -18,3 +18,4 @@
  */
 
 extern void rx_menu(GtkWidget *parent);
+extern void toggle_audio_output_device(void);