summaryrefslogtreecommitdiff
path: root/recordmydesktop/src
diff options
context:
space:
mode:
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r--recordmydesktop/src/rmd_cache_audio.c5
-rw-r--r--recordmydesktop/src/rmd_cache_frame.c6
-rw-r--r--recordmydesktop/src/rmd_encode_image_buffer.c7
-rw-r--r--recordmydesktop/src/rmd_encode_sound_buffer.c5
-rw-r--r--recordmydesktop/src/rmd_load_cache.c4
-rw-r--r--recordmydesktop/src/rmd_threads.c18
-rw-r--r--recordmydesktop/src/rmd_types.h2
7 files changed, 26 insertions, 21 deletions
diff --git a/recordmydesktop/src/rmd_cache_audio.c b/recordmydesktop/src/rmd_cache_audio.c
index 5686d81..5a71050 100644
--- a/recordmydesktop/src/rmd_cache_audio.c
+++ b/recordmydesktop/src/rmd_cache_audio.c
@@ -87,11 +87,12 @@ void *rmdCacheSoundBuffer(ProgData *pdata) {
(*jack_ringbuffer_read)(pdata->jdata->sound_buffer, jackbuf, write_size);
fwrite(jackbuf, 1, write_size, pdata->cache_data->afp);
} else {
- pdata->v_enc_thread_waiting=1;
+ /* FIXME TODO this needs redoing... */
+ //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;
+ //pdata->v_enc_thread_waiting=0;
continue;
}
diff --git a/recordmydesktop/src/rmd_cache_frame.c b/recordmydesktop/src/rmd_cache_frame.c
index 8d6c452..6014aa0 100644
--- a/recordmydesktop/src/rmd_cache_frame.c
+++ b/recordmydesktop/src/rmd_cache_frame.c
@@ -123,12 +123,12 @@ void *rmdCacheImageBuffer(ProgData *pdata) {
ynum = unum = vnum = 0;
- pthread_mutex_lock(&pdata->time_mutex);
+ pthread_mutex_lock(&pdata->img_buff_ready_mutex);
while (pdata->running && capture_frameno >= pdata->capture_frameno)
- pthread_cond_wait(&pdata->time_cond, &pdata->time_mutex);
+ pthread_cond_wait(&pdata->image_buffer_ready, &pdata->img_buff_ready_mutex);
capture_frameno = pdata->capture_frameno;
- pthread_mutex_unlock(&pdata->time_mutex);
+ pthread_mutex_unlock(&pdata->img_buff_ready_mutex);
pthread_mutex_lock(&pdata->pause_mutex);
while (pdata->paused)
diff --git a/recordmydesktop/src/rmd_encode_image_buffer.c b/recordmydesktop/src/rmd_encode_image_buffer.c
index 4a17882..14dd983 100644
--- a/recordmydesktop/src/rmd_encode_image_buffer.c
+++ b/recordmydesktop/src/rmd_encode_image_buffer.c
@@ -33,16 +33,17 @@
void *rmdEncodeImageBuffer(ProgData *pdata) {
+ unsigned int encode_frameno = 0;
+
pdata->th_encoding_clean = 0;
while (pdata->running) {
EncData *enc_data = pdata->enc_data;
pthread_mutex_lock(&pdata->img_buff_ready_mutex);
- pdata->th_enc_thread_waiting = 1;
- while (pdata->th_enc_thread_waiting)
+ while (pdata->running && encode_frameno >= pdata->capture_frameno)
pthread_cond_wait(&pdata->image_buffer_ready, &pdata->img_buff_ready_mutex);
- /* whoever signals us to run sets waiting=0 */
+ encode_frameno = pdata->capture_frameno;
pthread_mutex_unlock(&pdata->img_buff_ready_mutex);
pthread_mutex_lock(&pdata->pause_mutex);
diff --git a/recordmydesktop/src/rmd_encode_sound_buffer.c b/recordmydesktop/src/rmd_encode_sound_buffer.c
index 9e3af06..e0b6e75 100644
--- a/recordmydesktop/src/rmd_encode_sound_buffer.c
+++ b/recordmydesktop/src/rmd_encode_sound_buffer.c
@@ -101,11 +101,12 @@ void *rmdEncodeSoundBuffer(ProgData *pdata) {
}
}
} else {
- pdata->v_enc_thread_waiting = 1;
+ /* FIXME TODO this needs redoing, I don't have JACK ATM so I can't build/test it for now */
+ // 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;
+ // pdata->v_enc_thread_waiting=0;
continue;
}
#endif
diff --git a/recordmydesktop/src/rmd_load_cache.c b/recordmydesktop/src/rmd_load_cache.c
index 297b1a0..09e3138 100644
--- a/recordmydesktop/src/rmd_load_cache.c
+++ b/recordmydesktop/src/rmd_load_cache.c
@@ -311,11 +311,13 @@ void *rmdLoadCache(ProgData *pdata) {
}
}
- pdata->v_encoding_clean = pdata->th_encoding_clean = 1;
pthread_mutex_lock(&pdata->theora_lib_mutex);
+ pdata->th_encoding_clean = 1;
pthread_cond_signal(&pdata->theora_lib_clean);
pthread_mutex_unlock(&pdata->theora_lib_mutex);
+
pthread_mutex_lock(&pdata->vorbis_lib_mutex);
+ pdata->v_encoding_clean = 1;
pthread_cond_signal(&pdata->vorbis_lib_clean);
pthread_mutex_unlock(&pdata->vorbis_lib_mutex);
fprintf(stdout,"\n");
diff --git a/recordmydesktop/src/rmd_threads.c b/recordmydesktop/src/rmd_threads.c
index b7e13f3..cb81f84 100644
--- a/recordmydesktop/src/rmd_threads.c
+++ b/recordmydesktop/src/rmd_threads.c
@@ -119,14 +119,15 @@ void rmdThreads(ProgData *pdata) {
pthread_join(image_capture_t, NULL);
fprintf(stderr,"Shutting down.");
//if no damage events have been received the thread will get stuck
- pthread_mutex_lock(&pdata->img_buff_ready_mutex);
- while (pdata->th_enc_thread_waiting && !pdata->th_encoding_clean) {
+ pthread_mutex_lock(&pdata->theora_lib_mutex);
+ while (!pdata->th_encoding_clean) {
puts("waiting for th_enc");
- pdata->th_enc_thread_waiting = 0;
pthread_cond_signal(&pdata->image_buffer_ready);
- pthread_mutex_unlock(&pdata->img_buff_ready_mutex);
+ pthread_mutex_unlock(&pdata->theora_lib_mutex);
usleep(10000);
+ pthread_mutex_lock(&pdata->theora_lib_mutex);
}
+ pthread_mutex_unlock(&pdata->theora_lib_mutex);
if (pdata->args.encOnTheFly)
pthread_join(image_encode_t, NULL);
@@ -143,14 +144,15 @@ void rmdThreads(ProgData *pdata) {
pthread_join(sound_capture_t,NULL);
fprintf(stderr,".");
- pthread_mutex_lock(&pdata->snd_buff_ready_mutex);
- while (pdata->v_enc_thread_waiting || !pdata->v_encoding_clean) {
+ pthread_mutex_lock(&pdata->vorbis_lib_mutex);
+ while (!pdata->v_encoding_clean) {
puts("waiting for v_enc");
- pdata->v_enc_thread_waiting = 0;
pthread_cond_signal(&pdata->sound_data_read);
- pthread_mutex_unlock(&pdata->snd_buff_ready_mutex);
+ pthread_mutex_unlock(&pdata->vorbis_lib_mutex);
usleep(10000);
+ pthread_mutex_lock(&pdata->vorbis_lib_mutex);
}
+ pthread_mutex_unlock(&pdata->vorbis_lib_mutex);
if (pdata->args.encOnTheFly)
pthread_join(sound_encode_t, NULL);
diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h
index 051e034..e80b73f 100644
--- a/recordmydesktop/src/rmd_types.h
+++ b/recordmydesktop/src/rmd_types.h
@@ -310,8 +310,6 @@ struct _ProgData {
dummy_p_size, //dummy pointer size,initially 16x16,always square
th_encoding_clean, //thread exit inidcator
v_encoding_clean, // >> >>
- v_enc_thread_waiting, //these indicate a wait
- th_enc_thread_waiting, //condition on the cond vars.
timer_alive, //determines loop of timer thread
hard_pause, //if sound device doesn't support pause
//we have to close and reopen
© All Rights Reserved