From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Wed, 27 Nov 2019 20:50:14 +0000 (+0000)
Subject: fix bug changing audio output device name when local audio active.
X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/simplejson/module-simplejson.tests.html?a=commitdiff_plain;h=38030da42721f3baf8f5699370226e794848b254;p=pihpsdr.git

fix bug changing audio output device name when local audio active.
---

diff --git a/rx_menu.c b/rx_menu.c
index 79b4c00..1dbe469 100644
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -97,11 +97,15 @@ static void adc_cb(GtkWidget *widget, gpointer data) {
 static void local_audio_cb(GtkWidget *widget, gpointer data) {
 fprintf(stderr,"local_audio_cb: rx=%d\n",active_receiver->id);
 
-  if(active_receiver->audio_name==NULL) {
-    int i=gtk_combo_box_get_active(GTK_COMBO_BOX(output));
-    active_receiver->audio_name=g_new(gchar,strlen(output_devices[i].name)+1);
-    strcpy(active_receiver->audio_name,output_devices[i].name);
+  if(active_receiver->audio_name!=NULL) {
+    g_free(active_receiver->audio_name);
+    active_receiver->audio_name=NULL;
   }
+
+  int i=gtk_combo_box_get_active(GTK_COMBO_BOX(output));
+  active_receiver->audio_name=g_new(gchar,strlen(output_devices[i].name)+1);
+  strcpy(active_receiver->audio_name,output_devices[i].name);
+
   if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
     if(audio_open_output(active_receiver)==0) {
       active_receiver->local_audio=1;