From: Ramakrishnan Muthukrishnan Date: Sat, 4 Nov 2023 10:54:32 +0000 (+0530) Subject: toggle audio output via a rigctl command X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/file/frontends//%22%3C?a=commitdiff_plain;h=39562bdc3f95d2fb25d1706334d56f6db242b63a;p=pihpsdr.git toggle audio output via a rigctl command This would enable a frontpanel switch to select the audio output by sending a command to rigctl. --- diff --git a/rigctl.c b/rigctl.c index 14f09d3..9143ee0 100644 --- 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; diff --git a/rx_menu.c b/rx_menu.c index ad1e7aa..2708bb2 100644 --- 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 diff --git a/rx_menu.h b/rx_menu.h index b3d06c5..1342234 100644 --- 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);