summaryrefslogtreecommitdiff
path: root/recordmydesktop/src/flush_to_ogg.c
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-12-10 14:56:00 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-12-10 14:56:00 +0000
commit9ed6f5963df909cb4710b7dac1ca27d9e6147f90 (patch)
tree3d9d663bae2674bc1759b2bcf14a50ad0c847dbe /recordmydesktop/src/flush_to_ogg.c
parentcef7f3227bc7479254e3d2173680825291c9deb3 (diff)
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
Diffstat (limited to 'recordmydesktop/src/flush_to_ogg.c')
-rw-r--r--recordmydesktop/src/flush_to_ogg.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/recordmydesktop/src/flush_to_ogg.c b/recordmydesktop/src/flush_to_ogg.c
index 2390810..10d9553 100644
--- a/recordmydesktop/src/flush_to_ogg.c
+++ b/recordmydesktop/src/flush_to_ogg.c
@@ -65,6 +65,9 @@ void *FlushToOgg(ProgData *pdata){
double audiotime=0;
double videotime=0;
+ pthread_mutex_t imut,vmut;
+ pthread_mutex_init(&imut,NULL);
+ pthread_mutex_init(&vmut,NULL);
int working=1,
th_st_fin=0,
v_st_fin=(pdata->args.nosound);
@@ -93,7 +96,12 @@ void *FlushToOgg(ProgData *pdata){
if(videoflag)ogg_page_cp(&videopage_copy,&videopage);
pthread_mutex_unlock(&pdata->libogg_mutex);
//we need the last page to properly close the stream
- if(!videoflag)SyncEncodeImageBuffer(pdata);
+ if(!videoflag){
+ if(!pdata->th_encoding_clean){
+ pthread_cond_wait(&pdata->theora_lib_clean,&imut);
+ }
+ SyncEncodeImageBuffer(pdata);
+ }
}
if(!pdata->args.nosound && !v_st_fin &&!audioflag){
pthread_mutex_lock(&pdata->libogg_mutex);
@@ -102,7 +110,12 @@ void *FlushToOgg(ProgData *pdata){
if(audioflag)ogg_page_cp(&audiopage_copy,&audiopage);
pthread_mutex_unlock(&pdata->libogg_mutex);
//we need the last page to properly close the stream
- if(!audioflag)SyncEncodeSoundBuffer(pdata,NULL);
+ if(!audioflag){
+ if(!pdata->v_encoding_clean){
+ pthread_cond_wait(&pdata->vorbis_lib_clean,&vmut);
+ }
+ SyncEncodeSoundBuffer(pdata,NULL);
+ }
}
}
if(th_st_fin)videoflag=0;
@@ -150,8 +163,6 @@ void *FlushToOgg(ProgData *pdata){
working=(!th_st_fin || !v_st_fin);
}
- //last packages
-
pthread_mutex_lock(&pdata->libogg_mutex);
ogg_stream_clear(&pdata->enc_data->m_ogg_ts);
if(!pdata->args.nosound)
@@ -161,7 +172,6 @@ void *FlushToOgg(ProgData *pdata){
// theora_clear(&pdata->enc_data->m_th_st);
if(pdata->enc_data->fp)fclose(pdata->enc_data->fp);
-
fprintf(stderr,"\r \nDone.\nWritten %.0f bytes\n(%.0f of which were video data and %.0f audio data)\n\n",video_bytesout+audio_bytesout,video_bytesout,audio_bytesout);
pthread_exit(&errno);
}
© All Rights Reserved