From c4cc9d6d8cb531bbc40d5fb5190b4d986460a2d8 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Sat, 9 Nov 2019 00:03:17 +0000 Subject: [PATCH] Changed audio device naming --- audio.c | 37 +++++++++++++++++++++---------------- rx_menu.c | 4 ++-- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/audio.c b/audio.c index a942201..17c524a 100644 --- 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_devicesaudio_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); } } -- 2.45.2