summaryrefslogtreecommitdiff
path: root/recordmydesktop/src
diff options
context:
space:
mode:
authoriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-09-28 09:18:19 +0000
committeriovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2006-09-28 09:18:19 +0000
commit395830a22e96d29a9bdf9001e9147bc25d71fd3f (patch)
treeafaa6ac8c13750d794fc81980dd8350e018170d2 /recordmydesktop/src
parent1cc2dacb502aec6ca162d7c76619e45067a28e15 (diff)
frame duplication instead of dropping sound
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@72 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-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
6 files changed, 55 insertions, 60 deletions
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