summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--recordmydesktop/ChangeLog9
-rw-r--r--recordmydesktop/configure.ac2
-rw-r--r--recordmydesktop/include/recordmydesktop.h7
-rw-r--r--recordmydesktop/src/encode_image_buffer.c28
-rw-r--r--recordmydesktop/src/encode_sound_buffer.c38
-rw-r--r--recordmydesktop/src/flush_to_ogg.c41
-rw-r--r--recordmydesktop/src/get_frame.c1
-rw-r--r--recordmydesktop/src/recordmydesktop.c2
-rw-r--r--recordmydesktop/src/register_callbacks.c5
9 files changed, 69 insertions, 64 deletions
diff --git a/recordmydesktop/ChangeLog b/recordmydesktop/ChangeLog
index bd60427..d06cdd8 100644
--- a/recordmydesktop/ChangeLog
+++ b/recordmydesktop/ChangeLog
@@ -49,4 +49,11 @@ pixel discarding is an option(used to be otherwise).
/*VERSION 0.2.6*/
-*internal framedrop counter
+*Behavior on stream desync has been changed.
+Now, instead of dropping sound buffers, the
+last image is duplicated. When not recording
+sound this does not apply.
+*Theora return values are now properly checked,
+to avoid inserting corrupt packages into the stream.
+
+
diff --git a/recordmydesktop/configure.ac b/recordmydesktop/configure.ac
index 21e8b83..6850723 100644
--- a/recordmydesktop/configure.ac
+++ b/recordmydesktop/configure.ac
@@ -3,7 +3,7 @@
AC_PREREQ(2.59)
AC_INIT(src/recordmydesktop.c)
-AM_INIT_AUTOMAKE(recordmydesktop,0.2.5,)
+AM_INIT_AUTOMAKE(recordmydesktop,0.2.6,)
AC_CONFIG_SRCDIR([src/recordmydesktop.c])
AM_CONFIG_HEADER(config.h)
diff --git a/recordmydesktop/include/recordmydesktop.h b/recordmydesktop/include/recordmydesktop.h
index 78a4b4b..56eed77 100644
--- a/recordmydesktop/include/recordmydesktop.h
+++ b/recordmydesktop/include/recordmydesktop.h
@@ -238,13 +238,16 @@ pthread_cond_t *time_cond,*pause_cond;
unsigned char Yr[256],Yg[256],Yb[256],
Ur[256],Ug[256],Ub[256],
Vr[256],Vg[256],Vb[256];
+//the following values are of no effect
+//but they might be usefull later for profiling
unsigned int frames_total,//frames calculated by total time expirations
- frames_lost,//the value of shame
- frames_to_add;//number of fake packets to be fed into the ogg stream
+ frames_lost;//the value of shame
//used to determine frame drop which can
//happen on failure to receive a signal over a condition variable
int capture_busy,
encoder_busy;
+
+
/**Macros*/
#define CLIP_EVENT_AREA(e,brwin,wgeom){\
diff --git a/recordmydesktop/src/encode_image_buffer.c b/recordmydesktop/src/encode_image_buffer.c
index 315ad5c..aaede04 100644
--- a/recordmydesktop/src/encode_image_buffer.c
+++ b/recordmydesktop/src/encode_image_buffer.c
@@ -25,26 +25,36 @@
**********************************************************************************/
#include <recordmydesktop.h>
-
void *EncodeImageBuffer(void *pdata){
pthread_mutex_t pmut,imut;
pthread_mutex_init(&pmut,NULL);
pthread_mutex_init(&imut,NULL);
-
while(((ProgData *)pdata)->running){
encoder_busy=1;
pthread_cond_wait(&((ProgData *)pdata)->image_buffer_ready,&imut);
if(Paused)
pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut);//this may not be needed
pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex);
- int za=theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv);
- if(za){
- fprintf(stderr,"Encoder not ready %d!\n",za);
+//code duplication is evil.
+//almost as evil as globals...
+ while(((ProgData *)pdata)->avd<=0){
+ if(!theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv)){
+ if(theora_encode_packetout(&((ProgData *)pdata)->enc_data->m_th_st,0,&((ProgData *)pdata)->enc_data->m_ogg_pckt1)==1)
+ ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt1);
+ ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels;
+ }
+ }
+ if(theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv)){
+ fprintf(stderr,"Encoder not ready!\n");
+ pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex);
+ }
+ else{
+ pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex);
+ if(theora_encode_packetout(&((ProgData *)pdata)->enc_data->m_th_st,0,&((ProgData *)pdata)->enc_data->m_ogg_pckt1)==1){
+ ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt1);
+ ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels;
+ }
}
- pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex);
- theora_encode_packetout(&((ProgData *)pdata)->enc_data->m_th_st,0,&((ProgData *)pdata)->enc_data->m_ogg_pckt1);
- ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt1);
- ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels;
encoder_busy=0;
}
//last packet
diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c
index 56bf990..48410f3 100644
--- a/recordmydesktop/src/encode_sound_buffer.c
+++ b/recordmydesktop/src/encode_sound_buffer.c
@@ -52,28 +52,26 @@ void *EncodeSoundBuffer(void *pdata){
((ProgData *)pdata)->sound_buffer=((ProgData *)pdata)->sound_buffer->next;
pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex);
- if (((ProgData *)pdata)->avd>0){
- vorbis_buffer=vorbis_analysis_buffer(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread);
-
- for(i=0;i<sampread;i++){
- for(j=0;j<((ProgData *)pdata)->args.channels;j++){
- vorbis_buffer[j][i]=((buff->data[count+1]<<8)|
- (0x00ff&(int)buff->data[count]))/32768.f;
- count+=2;
- }
- }
- vorbis_analysis_wrote(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread);
-
- while(vorbis_analysis_blockout(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_vo_block)==1){
-
- vorbis_analysis(&((ProgData *)pdata)->enc_data->m_vo_block,NULL);
- vorbis_bitrate_addblock(&((ProgData *)pdata)->enc_data->m_vo_block);
-
- while(vorbis_bitrate_flushpacket(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_ogg_pckt2))
- ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_vs,&((ProgData *)pdata)->enc_data->m_ogg_pckt2);
+ vorbis_buffer=vorbis_analysis_buffer(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread);
+ for(i=0;i<sampread;i++){
+ for(j=0;j<((ProgData *)pdata)->args.channels;j++){
+ vorbis_buffer[j][i]=((buff->data[count+1]<<8)|
+ (0x00ff&(int)buff->data[count]))/32768.f;
+ count+=2;
}
- ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime;
}
+ vorbis_analysis_wrote(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread);
+
+ while(vorbis_analysis_blockout(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_vo_block)==1){
+
+ vorbis_analysis(&((ProgData *)pdata)->enc_data->m_vo_block,NULL);
+ vorbis_bitrate_addblock(&((ProgData *)pdata)->enc_data->m_vo_block);
+
+ while(vorbis_bitrate_flushpacket(&((ProgData *)pdata)->enc_data->m_vo_dsp,&((ProgData *)pdata)->enc_data->m_ogg_pckt2))
+ ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_vs,&((ProgData *)pdata)->enc_data->m_ogg_pckt2);
+ }
+ ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime;
+
free(buff);
}
diff --git a/recordmydesktop/src/flush_to_ogg.c b/recordmydesktop/src/flush_to_ogg.c
index b33ed1c..0892d2c 100644
--- a/recordmydesktop/src/flush_to_ogg.c
+++ b/recordmydesktop/src/flush_to_ogg.c
@@ -30,36 +30,23 @@ void *FlushToOgg(void *pdata){
int videoflag=0,audioflag=0;
double video_bytesout=0,audio_bytesout=0;
ogg_page videopage,audiopage;
- int prev=0;
while(((ProgData *)pdata)->running){
-// if(Paused)pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&((ProgData *)pdata)->pause_cond_mutex);
-// if(!prev){
- videoflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage);
- 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;
-// prev=(!((ProgData *)pdata)->args.nosound);
-
-
-// }
- if(!((ProgData *)pdata)->args.nosound){
-
- audioflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_vs,&audiopage);
-
- if(audioflag){
- 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;
- prev=0;
+ videoflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage);
+ 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;
+ if(!((ProgData *)pdata)->args.nosound){
+ audioflag=ogg_stream_pageout(&((ProgData *)pdata)->enc_data->m_ogg_vs,&audiopage);
+ if(audioflag){
+ 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;
+ }
}
}
-// else
-// if(!did_one)
-// usleep(10000);
- }
- else /*if(((ProgData *)pdata)->args.nosound)*/
- usleep(10000);
+ else
+ usleep(10000);
}
//last packages
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index 2a55ba2..2ee525d 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -191,7 +191,6 @@ void *GetFrame(void *pdata){
}
if(encoder_busy){
frames_lost++;
- frames_to_add++;
}
pthread_cond_broadcast(&((ProgData *)pdata)->image_buffer_ready);
capture_busy=0;
diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c
index 3ebdd6a..6a106b9 100644
--- a/recordmydesktop/src/recordmydesktop.c
+++ b/recordmydesktop/src/recordmydesktop.c
@@ -74,7 +74,7 @@ int main(int argc,char **argv){
//these are globals, look for them at the header
- frames_total=frames_lost=frames_to_add=encoder_busy=capture_busy=0;
+ frames_total=frames_lost=encoder_busy=capture_busy=0;
if(!pdata.args.scshot){
fprintf(stderr,"Initializing...\n");
diff --git a/recordmydesktop/src/register_callbacks.c b/recordmydesktop/src/register_callbacks.c
index 262e3ae..677fc75 100644
--- a/recordmydesktop/src/register_callbacks.c
+++ b/recordmydesktop/src/register_callbacks.c
@@ -29,10 +29,11 @@
void SetExpired(int signum){
frames_total++;
if(capture_busy){
- frames_to_add++;
frames_lost++;
}
- pthread_cond_broadcast(time_cond);
+ pthread_cond_broadcast(time_cond);//sig handlers should not call this func
+ //could be a set_expired and main thread
+ //doing a while(running) if set_expired broadcast else usleep(n)
}
void SetPaused(int signum){
© All Rights Reserved