Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #109

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
50 changes: 10 additions & 40 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,37 +764,6 @@ g_print("audio_close_input: free mic buffer\n");
}
}

/* Unused function
int audio_write_buffer(RECEIVER *rx) {
int rc;
int err;
switch(radio->which_audio) {
case USE_SOUNDIO:
g_mutex_lock(&rx->local_audio_mutex);
char *buf = soundio_ring_buffer_write_ptr(rx->ring_buffer);
int fill_count = rx->output_samples*sizeof(float)*2;
memcpy(buf, rx->local_audio_buffer, fill_count);
soundio_ring_buffer_advance_write_ptr(rx->ring_buffer, fill_count);
g_mutex_unlock(&rx->local_audio_mutex);
break;
#ifndef __APPLE__
case USE_PULSEAUDIO:
g_mutex_lock(&rx->local_audio_mutex);
rc=pa_simple_write(rx->playstream,
rx->local_audio_buffer,
rx->output_samples*sizeof(float)*2,
&err);
if(rc!=0) {
fprintf(stderr,"audio_write buffer=%p length=%d returned %d err=%d\n",rx->local_audio_buffer,rx->output_samples,rc,err);
}
g_mutex_unlock(&rx->local_audio_mutex);
break;
#endif
}
return rc;
}
*/

void audio_start_output(RECEIVER *rx) {
int err;
switch(radio->which_audio) {
Expand Down Expand Up @@ -1035,7 +1004,7 @@ fprintf(stderr,"mic_read_thread: ALSA: mic_buffer_size=%d\n",radio->local_microp
//g_print("mic_read_thread: -EPIPE: snd_pcm_prepare\n");
if ((rc = snd_pcm_prepare (r->record_handle)) < 0) {
g_print("mic_read_thread: ALSA: cannot prepare audio interface for use %d (%s)\n", rc, snd_strerror (rc));
return rc;
//return rc;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dubious change. This changes the flow, this function should abort on error. Correct would be a plain return;

}
} else {
fprintf (stderr, "mic_read_thread: ALSA: read from audio interface failed (%s)\n",
Expand Down Expand Up @@ -1084,10 +1053,11 @@ static void source_list_cb(pa_context *context,const pa_source_info *s,int eol,v
}
} else if(n_input_devices<MAX_AUDIO_DEVICES) {
input_devices[n_input_devices].name=g_new0(char,strlen(s->name)+1);
strncpy(input_devices[n_input_devices].name,s->name,strlen(s->name));
memcpy(input_devices[n_input_devices].name, s->name, strlen(s->name));
input_devices[n_input_devices].description=g_new0(char,strlen(s->description)+1);
strncpy(input_devices[n_input_devices].description,s->description,strlen(s->description));
memcpy(input_devices[n_input_devices].description,s->description, strlen(s->description));
input_devices[n_input_devices].index=s->index;

n_input_devices++;
}
}
Expand All @@ -1101,9 +1071,9 @@ static void sink_list_cb(pa_context *context,const pa_sink_info *s,int eol,void
op=pa_context_get_source_info_list(pa_ctx,source_list_cb,NULL);
} else if(n_output_devices<MAX_AUDIO_DEVICES) {
output_devices[n_output_devices].name=g_new0(char,strlen(s->name)+1);
strncpy(output_devices[n_output_devices].name,s->name,strlen(s->name));
memcpy(output_devices[n_output_devices].name,s->name,strlen(s->name));
output_devices[n_output_devices].description=g_new0(char,strlen(s->description)+1);
strncpy(output_devices[n_output_devices].description,s->description,strlen(s->description));
memcpy(output_devices[n_output_devices].description,s->description,strlen(s->description));
output_devices[n_output_devices].index=s->index;
n_output_devices++;
}
Expand Down Expand Up @@ -1189,9 +1159,9 @@ g_print("audio: create_audio: USE_SOUNDIO: %d %s\n",soundio_get_backend(soundio,
}

output_devices[n_output_devices].name=g_new0(char,strlen(device->name)+1);
strncpy(output_devices[n_output_devices].name,device->name,strlen(device->name));
memcpy(output_devices[n_output_devices].name,device->name,strlen(device->name));
output_devices[n_output_devices].description=g_new0(char,strlen(device->name)+1);
strncpy(output_devices[n_output_devices].description,device->name,strlen(device->name));
memcpy(output_devices[n_output_devices].description,device->name,strlen(device->name));
output_devices[n_output_devices].index=i;
soundio_device_unref(device);
n_output_devices++;
Expand All @@ -1202,9 +1172,9 @@ g_print("audio: create_audio: USE_SOUNDIO: %d %s\n",soundio_get_backend(soundio,
if(n_input_devices<MAX_AUDIO_DEVICES) {
struct SoundIoDevice *device=soundio_get_input_device(soundio,i);
input_devices[n_input_devices].name=g_new0(char,strlen(device->name)+1);
strncpy(input_devices[n_input_devices].name,device->name,strlen(device->name));
memcpy(input_devices[n_input_devices].name,device->name,strlen(device->name));
input_devices[n_input_devices].description=g_new0(char,strlen(device->name)+1);
strncpy(input_devices[n_input_devices].description,device->name,strlen(device->name));
memcpy(input_devices[n_input_devices].description,device->name,strlen(device->name));
input_devices[n_input_devices].index=i;
soundio_device_unref(device);
n_input_devices++;
Expand Down