From: c vw Date: Tue, 21 Apr 2020 12:11:15 +0000 (+0200) Subject: Added a mutex for CW 'local' audio output, such that X-Git-Url: https://git.rkrishnan.org/pf/content/reliability?a=commitdiff_plain;h=b836ad045f41800345bbf2b96de4213a2510085c;p=pihpsdr.git Added a mutex for CW 'local' audio output, such that audio_write and cw_audio_write are mutally exclusive. --- diff --git a/portaudio.c b/portaudio.c index 2ed083c..c9c77df 100644 --- a/portaudio.c +++ b/portaudio.c @@ -458,6 +458,7 @@ int cw_audio_write(float sample) { RECEIVER *rx = active_receiver; float *buffer = rx->local_audio_buffer; + g_mutex_lock(&rx->local_audio_mutex); if (rx->playback_handle != NULL && rx->local_audio_buffer != NULL) { buffer[rx->local_audio_buffer_offset++] = sample; if (rx->local_audio_buffer_offset == MY_AUDIO_BUFFER_SIZE) { @@ -466,6 +467,7 @@ int cw_audio_write(float sample) { rx->local_audio_buffer_offset=0; } } + g_mutex_unlock(&rx->local_audio_mutex); return 0; }