From e0e54b16485fa34d416c9a9aaaae2cfab1e1e887 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 10 Jul 2020 01:38:53 -0700 Subject: capture_sound: simplify locking and buffer acquisition More tidying of things --- recordmydesktop/src/rmd_capture_sound.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/recordmydesktop/src/rmd_capture_sound.c b/recordmydesktop/src/rmd_capture_sound.c index 2d02aee..63c46f3 100644 --- a/recordmydesktop/src/rmd_capture_sound.c +++ b/recordmydesktop/src/rmd_capture_sound.c @@ -144,22 +144,17 @@ void *rmdCaptureSound(ProgData *pdata) { #endif //queue the new buffer pthread_mutex_lock(&pdata->sound_buffer_mutex); - tmp=pdata->sound_buffer; - if (pdata->sound_buffer==NULL) - pdata->sound_buffer=newbuf; + tmp = pdata->sound_buffer; + if (!tmp) + pdata->sound_buffer = newbuf; else { - while (tmp->next!=NULL) - tmp=tmp->next; + while (tmp->next != NULL) + tmp = tmp->next; - tmp->next=newbuf; + tmp->next = newbuf; } - pthread_mutex_unlock(&pdata->sound_buffer_mutex); - - - //signal that there are data to be proccessed - pthread_mutex_lock(&pdata->snd_buff_ready_mutex); pthread_cond_signal(&pdata->sound_data_read); - pthread_mutex_unlock(&pdata->snd_buff_ready_mutex); + pthread_mutex_unlock(&pdata->sound_buffer_mutex); } #ifdef HAVE_LIBASOUND snd_pcm_close(pdata->sound_handle); -- cgit v1.2.3