From 8504b200e78fa363b92ac07597422ce3ec8f7175 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Sat, 4 Nov 2023 22:29:14 +0530
Subject: [PATCH] try to invoke it without being able to bring up the menu

---
 rx_menu.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/rx_menu.c b/rx_menu.c
index 2708bb2..a41ed8c 100644
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -140,18 +140,6 @@ 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
@@ -189,6 +177,20 @@ static void local_output_changed_cb(GtkWidget *widget, gpointer data) {
             active_receiver->id, active_receiver->local_audio);
 }
 
+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);
+
+    local_output_changed_cb(GTK_COMBO_BOX(output), NULL);
+}
+
 static void audio_channel_cb(GtkWidget *widget, gpointer data) {
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
         active_receiver->audio_channel = GPOINTER_TO_INT(data);
-- 
2.45.2