From b836ad045f41800345bbf2b96de4213a2510085c Mon Sep 17 00:00:00 2001 From: c vw Date: Tue, 21 Apr 2020 14:11:15 +0200 Subject: [PATCH] Added a mutex for CW 'local' audio output, such that audio_write and cw_audio_write are mutally exclusive. --- portaudio.c | 2 ++ 1 file changed, 2 insertions(+) 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; } -- 2.45.2