]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Changed audio device naming
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Sat, 9 Nov 2019 00:03:17 +0000 (00:03 +0000)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Sat, 9 Nov 2019 00:03:17 +0000 (00:03 +0000)
audio.c
rx_menu.c

diff --git a/audio.c b/audio.c
index a942201ff46ae7e8178ee513bcf3857557dd7280..17c524a10fd5457b415eb7b33cbb573362e86e03 100644 (file)
--- a/audio.c
+++ b/audio.c
@@ -96,15 +96,16 @@ fprintf(stderr,"audio_open_output: rx=%d %s\n",rx->id,rx->audio_name);
   int i;
   char hw[128];
  
-fprintf(stderr,"audio_open_output: selected=%s\n",rx->audio_name);
 
   i=0;
-  while(rx->audio_name[i]!=' ') {
+  while(i<128 && rx->audio_name[i]!=' ') {
     hw[i]=rx->audio_name[i];
     i++;
   }
   hw[i]='\0';
   
+fprintf(stderr,"audio_open_output: hw=%s\n",hw);
+
   if ((err = snd_pcm_open (&rx->playback_handle, hw, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
     fprintf (stderr, "audio_open_output: cannot open audio device %s (%s)\n", 
             hw,
@@ -520,8 +521,8 @@ fprintf(stderr,"audio_get_cards\n");
           strcpy(input_devices[n_input_devices].description,device_id);
           input_devices[n_input_devices].index=i;
           n_input_devices++;
-        }
 fprintf(stderr,"input_device: %s\n",device_id);
+        }
       }
 
       // ouput devices
@@ -536,8 +537,8 @@ fprintf(stderr,"input_device: %s\n",device_id);
           strcpy(output_devices[n_output_devices].description,device_id);
           input_devices[n_output_devices].index=i;
           n_output_devices++;
-        }
 fprintf(stderr,"output_device: %s\n",device_id);
+        }
       }
     }
     snd_ctl_close(handle);
@@ -555,20 +556,24 @@ fprintf(stderr,"output_device: %s\n",device_id);
     descr = snd_device_name_get_hint(*n, "DESC");
     io = snd_device_name_get_hint(*n, "IOID");
 
-    if(strncmp("dmix:", name, 5)==0/* || strncmp("pulse", name, 5)==0*/) {
-      fprintf(stderr,"name=%s descr=%s io=%s\n",name, descr, io);
-      device_id=malloc(128);
-
-      snprintf(device_id, 128, "%s", name);
+    if(strncmp("dmix:", name, 5)==0) {
       if(n_output_devices<MAX_AUDIO_DEVICES) {
-        output_devices[n_output_devices].name=g_new0(char,strlen(device_id)+1);
-        strcpy(output_devices[n_output_devices].name,device_id);
-        output_devices[n_output_devices].description=g_new0(char,strlen(device_id)+1);
-        strcpy(output_devices[n_output_devices].description,device_id);
-        input_devices[n_output_devices].index=i;
-        n_output_devices++;
+        if(strncmp("dmix:CARD=ALSA",name,14)!=0) {
+          output_devices[n_output_devices].name=g_new0(char,strlen(name)+1);
+          strcpy(output_devices[n_output_devices].name,name);
+          output_devices[n_output_devices].description=g_new0(char,strlen(descr)+1);
+          //strcpy(output_devices[n_output_devices].description,descr);
+          i=0;
+          while(i<strlen(descr) && descr[i]!='\n') {
+            output_devices[n_output_devices].description[i]=descr[i];
+            i++;
+          }
+          output_devices[n_output_devices].description[i]='\0';
+          input_devices[n_output_devices].index=i;
+          n_output_devices++;
+fprintf(stderr,"output_device: name=%s descr=%s\n",name,descr);
+        }
       }
-fprintf(stderr,"output_device: %s\n",device_id);
     }
 
     if (name != NULL)
index f02f344ff7075b5f118ba7b75860db2bd2050e53..871e8ae13e9f9f6c9d2bf9eb2cac4f6599900148 100644 (file)
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -341,9 +341,9 @@ void rx_menu(GtkWidget *parent) {
 
     output=NULL;
     for(i=0;i<n_output_devices;i++) {
-      output=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(output),output_devices[i].description);
+      output=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(output),output_devices[i].name);
       if(active_receiver->audio_name!=NULL) {
-        if(strcmp(active_receiver->audio_name,output_devices[i].description)==0) {
+        if(strcmp(active_receiver->audio_name,output_devices[i].name)==0) {
           gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(output),i);
         }
       }