From 9ed6f5963df909cb4710b7dac1ca27d9e6147f90 Mon Sep 17 00:00:00 2001 From: iovar Date: Sun, 10 Dec 2006 14:56:00 +0000 Subject: Many changes, mostly focusing around proper interleaving of theora and vorbis streams (which should now be correct). Also missing eos has been taken care. New condition variables have been added to signal end of encoding threads and avoid lockups, caused by the new configuration for eos. Also the main thread handles better the joins now, making sure that the encoding threads do not get stuck waiting. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@230 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/src/recordmydesktop.c | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'recordmydesktop/src/recordmydesktop.c') diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index f15bdc9..0a9aa79 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -119,6 +119,8 @@ int main(int argc,char **argv){ pthread_mutex_init(&pdata.list_mutex[1],NULL); pthread_mutex_init(&pdata.sound_buffer_mutex,NULL); pthread_mutex_init(&pdata.libogg_mutex,NULL); +// pthread_mutex_init(&pdata.libtheora_mutex,NULL); +// pthread_mutex_init(&pdata.libvorbis_mutex,NULL); pthread_mutex_init(&pdata.yuv_mutex,NULL); pthread_cond_init(&pdata.time_cond,NULL); @@ -126,6 +128,9 @@ int main(int argc,char **argv){ pthread_cond_init(&pdata.image_buffer_ready,NULL); pthread_cond_init(&pdata.sound_buffer_ready,NULL); pthread_cond_init(&pdata.sound_data_read,NULL); + pthread_cond_init(&pdata.theora_lib_clean,NULL); + pthread_cond_init(&pdata.vorbis_lib_clean,NULL); + pdata.th_encoding_clean=pdata.v_encoding_clean=1; pdata.list_selector=Paused=Aborted=pdata.avd=0; pdata.sound_buffer=NULL; pdata.running=1; @@ -233,34 +238,31 @@ int main(int argc,char **argv){ pthread_join(image_capture_t,NULL); fprintf(stderr,"Shutting down."); //if no damage events have been received the thread will get stuck - pthread_cond_broadcast(&pdata.image_buffer_ready); - if(pdata.args.encOnTheFly) + while(!pdata.th_enc_thread_waiting && !pdata.th_encoding_clean){ + usleep(10000); + pthread_cond_signal(&pdata.image_buffer_ready); + } +// pthread_cond_broadcast(&pdata.image_buffer_ready); + if(pdata.args.encOnTheFly){ pthread_join(image_encode_t,NULL); + } else pthread_join(image_cache_t,NULL); fprintf(stderr,"."); if(!pdata.args.nosound){ - int *snd_exit; - pthread_join(sound_capture_t,(void *)(&snd_exit)); + pthread_join(sound_capture_t,NULL); fprintf(stderr,"."); - + while(!pdata.v_enc_thread_waiting && !pdata.v_encoding_clean){ + usleep(10000); + pthread_cond_signal(&pdata.sound_data_read); + } if(pdata.args.encOnTheFly){ - if(!(*snd_exit)) - pthread_join(sound_encode_t,NULL); - else{ - pthread_cancel(sound_encode_t); - exit_status=*snd_exit; - } + pthread_join(sound_encode_t,NULL); } else{ - if(!(*snd_exit)) - pthread_join(sound_cache_t,NULL); - else{ - pthread_cancel(sound_cache_t); - exit_status=*snd_exit; - } + pthread_join(sound_cache_t,NULL); } } else -- cgit v1.2.1