summaryrefslogtreecommitdiff
path: root/recordmydesktop/src/rmd_cache_audio.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-06-23 18:00:38 -0700
committerVito Caputo <vcaputo@pengaru.com>2020-07-11 13:36:41 -0700
commit2eb2828f6f3eeefdc025986b0fce6418254ea3be (patch)
treea6e76db9bc61e44e86451d25519d9c7d1139dcba /recordmydesktop/src/rmd_cache_audio.c
parent6fa40224ae7f78092537f30d034b2cdd247237b1 (diff)
cache_audio: more unfucking of synchronization
leaving the libjack related fixes for later
Diffstat (limited to 'recordmydesktop/src/rmd_cache_audio.c')
-rw-r--r--recordmydesktop/src/rmd_cache_audio.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/recordmydesktop/src/rmd_cache_audio.c b/recordmydesktop/src/rmd_cache_audio.c
index 71c9611..e3743be 100644
--- a/recordmydesktop/src/rmd_cache_audio.c
+++ b/recordmydesktop/src/rmd_cache_audio.c
@@ -60,29 +60,24 @@ void *rmdCacheSoundBuffer(ProgData *pdata) {
while (pdata->running) {
SndBuffer *buff = NULL;
- if (pdata->paused) {
- pthread_mutex_lock(&pdata->pause_mutex);
+ pthread_mutex_lock(&pdata->pause_mutex);
+ while (pdata->paused)
pthread_cond_wait(&pdata->pause_cond, &pdata->pause_mutex);
- pthread_mutex_unlock(&pdata->pause_mutex);
- }
+ pthread_mutex_unlock(&pdata->pause_mutex);
if (!pdata->args.use_jack) {
- if (pdata->sound_buffer == NULL) {
- pdata->v_enc_thread_waiting = 1;
- pthread_mutex_lock(&pdata->snd_buff_ready_mutex);
- pthread_cond_wait(&pdata->sound_data_read, &pdata->snd_buff_ready_mutex);
- pthread_mutex_unlock(&pdata->snd_buff_ready_mutex);
- pdata->v_enc_thread_waiting = 0;
- }
-
- if (pdata->sound_buffer == NULL || !pdata->running)
- break;
-
pthread_mutex_lock(&pdata->sound_buffer_mutex);
+ while (!pdata->sound_buffer && pdata->running)
+ pthread_cond_wait(&pdata->sound_data_read, &pdata->sound_buffer_mutex);
+
buff = pdata->sound_buffer;
- //advance the list
- pdata->sound_buffer = pdata->sound_buffer->next;
+ if (buff)
+ pdata->sound_buffer = pdata->sound_buffer->next;
pthread_mutex_unlock(&pdata->sound_buffer_mutex);
+
+ if (!pdata->running)
+ break;
+
fwrite(buff->data, 1, write_size, pdata->cache_data->afp);
free(buff->data);
free(buff);
© All Rights Reserved