summaryrefslogtreecommitdiff
path: root/recordmydesktop/src
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-10-23 03:29:06 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-10-23 03:29:06 +0000
commit51e1ec5f589862ddfd9322daf5bcd684698fb48f (patch)
tree1eea3b729ae556d50fc5accb927e16ba99129418 /recordmydesktop/src
parentb1429e05f61d0cbf5c0e62598cf4109672aa09d9 (diff)
av sync imporovements
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@106 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r--recordmydesktop/src/flush_to_ogg.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/recordmydesktop/src/flush_to_ogg.c b/recordmydesktop/src/flush_to_ogg.c
index fed07c5..15b537b 100644
--- a/recordmydesktop/src/flush_to_ogg.c
+++ b/recordmydesktop/src/flush_to_ogg.c
@@ -27,31 +27,53 @@
#include <recordmydesktop.h>
void *FlushToOgg(void *pdata){
- int videoflag=0,audioflag=0;
+ int videoflag=0,audioflag=0,a_v=0;
double video_bytesout=0,audio_bytesout=0;
+ ogg_int64_t v_pos=0,a_pos=0;
ogg_page videopage,audiopage;
while(((ProgData *)pdata)->running){
- pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex);
- videoflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage);
- pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex);
- if(videoflag){
- video_bytesout+=fwrite(videopage.header,1,videopage.header_len,((ProgData *)pdata)->enc_data->fp);
- video_bytesout+=fwrite(videopage.body,1,videopage.body_len,((ProgData *)pdata)->enc_data->fp);
- videoflag=0;
+ a_v=0;
+// v_pos=theora_granule_time(&(((ProgData *)pdata)->enc_data->m_th_st),((ProgData *)pdata)->enc_data->m_ogg_ts.granulepos);
+// a_pos=
+
+ if(v_pos<=a_pos){
+ pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex);
+ videoflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage);
+
+ if(videoflag){
+ v_pos=theora_granule_time(&(((ProgData *)pdata)->enc_data->m_th_st),
+ ((ProgData *)pdata)->enc_data->m_ogg_ts.granulepos);
+ pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex);
+ video_bytesout+=fwrite(videopage.header,1,videopage.header_len,((ProgData *)pdata)->enc_data->fp);
+ video_bytesout+=fwrite(videopage.body,1,videopage.body_len,((ProgData *)pdata)->enc_data->fp);
+ videoflag=0;
+ a_v=1;
+ }
+ else
+ pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex);
+ }
+ if(a_pos<v_pos){
if(!((ProgData *)pdata)->args.nosound){
pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex);
audioflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_vs,&audiopage);
- pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex);
if(audioflag){
+ a_pos=vorbis_granule_time(&(((ProgData *)pdata)->enc_data->m_vo_dsp),
+ ((ProgData *)pdata)->enc_data->m_vo_dsp.granulepos);
+ pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex);
audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,((ProgData *)pdata)->enc_data->fp);
audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,((ProgData *)pdata)->enc_data->fp);
audioflag=0;
+ a_v=1;
}
+ else
+ pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex);
+
+
}
}
- else
+ if(!a_v)
usleep(10000);
-
+// fprintf(stderr,"v %d a %d %d\n",(int)v_pos,(int)a_pos,(int)v_pos-(int)a_pos);
}
//last packages
videoflag=ogg_stream_flush(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage);
© All Rights Reserved