diff options
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/cache_audio.c | 26 | ||||
-rw-r--r-- | recordmydesktop/src/cache_frame.c | 42 | ||||
-rw-r--r-- | recordmydesktop/src/capture_sound.c | 66 | ||||
-rw-r--r-- | recordmydesktop/src/encode_image_buffer.c | 32 | ||||
-rw-r--r-- | recordmydesktop/src/encode_sound_buffer.c | 66 | ||||
-rw-r--r-- | recordmydesktop/src/flush_to_ogg.c | 54 | ||||
-rw-r--r-- | recordmydesktop/src/get_frame.c | 176 | ||||
-rw-r--r-- | recordmydesktop/src/load_cache.c | 44 | ||||
-rw-r--r-- | recordmydesktop/src/poll_damage.c | 38 | ||||
-rw-r--r-- | recordmydesktop/src/recordmydesktop.c | 20 |
10 files changed, 282 insertions, 282 deletions
diff --git a/recordmydesktop/src/cache_audio.c b/recordmydesktop/src/cache_audio.c index 7b17d7b..156f4a1 100644 --- a/recordmydesktop/src/cache_audio.c +++ b/recordmydesktop/src/cache_audio.c @@ -25,43 +25,43 @@ **********************************************************************************/ #include <recordmydesktop.h> -void *CacheSoundBuffer(void *pdata){ +void *CacheSoundBuffer(ProgData *pdata){ //We are simply going to throw sound on the disk. //It's sound is tiny compared to that of image, so //compressing would reducethe overall size by only an //insignificant fraction. pthread_mutex_t smut; pthread_mutex_init(&smut,NULL); - while((((ProgData *)pdata)->running)){ + while((pdata->running)){ SndBuffer *buff; if(Paused){ pthread_mutex_t tmut; pthread_mutex_init(&tmut,NULL); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&tmut); + pthread_cond_wait(&pdata->pause_cond,&tmut); } - if(((ProgData *)pdata)->sound_buffer==NULL) - pthread_cond_wait(&((ProgData *)pdata)->sound_data_read,&smut); + if(pdata->sound_buffer==NULL) + pthread_cond_wait(&pdata->sound_data_read,&smut); - pthread_mutex_lock(&((ProgData *)pdata)->sound_buffer_mutex); - buff=((ProgData *)pdata)->sound_buffer; + pthread_mutex_lock(&pdata->sound_buffer_mutex); + buff=pdata->sound_buffer; //advance the list - ((ProgData *)pdata)->sound_buffer=((ProgData *)pdata)->sound_buffer->next; - pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex); + pdata->sound_buffer=pdata->sound_buffer->next; + pthread_mutex_unlock(&pdata->sound_buffer_mutex); - fwrite(buff->data,((ProgData *)pdata)->periodsize,1,((ProgData *)pdata)->cache_data->afp); + fwrite(buff->data,pdata->periodsize,1,pdata->cache_data->afp); - ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime; + pdata->avd-=pdata->periodtime; free(buff->data); free(buff); } - fclose(((ProgData *)pdata)->cache_data->afp); + fclose(pdata->cache_data->afp); pthread_exit(&errno); } - + diff --git a/recordmydesktop/src/cache_frame.c b/recordmydesktop/src/cache_frame.c index 412db6c..7f8c826 100644 --- a/recordmydesktop/src/cache_frame.c +++ b/recordmydesktop/src/cache_frame.c @@ -66,7 +66,7 @@ int FlushBlock(unsigned char *buf,int blockno,int width, int height,int divisor, return ((height*width)/pow(divisor,2)); } -void *CacheImageBuffer(void *pdata){ +void *CacheImageBuffer(ProgData *pdata){ pthread_mutex_t pmut,imut; pthread_mutex_init(&pmut,NULL); pthread_mutex_init(&imut,NULL); @@ -81,21 +81,21 @@ void *CacheImageBuffer(void *pdata){ nbytes=0, nth_cache=1; - if(!((ProgData *)pdata)->args.zerocompression){ - fp=((ProgData *)pdata)->cache_data->ifp; + if(!pdata->args.zerocompression){ + fp=pdata->cache_data->ifp; if(fp==NULL)exit(13); } else{ - ucfp=((ProgData *)pdata)->cache_data->uncifp; + ucfp=pdata->cache_data->uncifp; if(ucfp==NULL)exit(13); } for(i=0;i<2;i++){ - yuv[i].y_width=((ProgData *)pdata)->enc_data->yuv.y_width; - yuv[i].y_height=((ProgData *)pdata)->enc_data->yuv.y_height; - yuv[i].uv_width=((ProgData *)pdata)->enc_data->yuv.uv_width; - yuv[i].uv_height=((ProgData *)pdata)->enc_data->yuv.uv_height; + yuv[i].y_width=pdata->enc_data->yuv.y_width; + yuv[i].y_height=pdata->enc_data->yuv.y_height; + yuv[i].uv_width=pdata->enc_data->yuv.uv_width; + yuv[i].uv_height=pdata->enc_data->yuv.uv_height; yuv[i].y=(unsigned char *)malloc(yuv[i].y_width*yuv[i].y_height); yuv[i].u=(unsigned char *)malloc(yuv[i].uv_width*yuv[i].uv_height); @@ -103,7 +103,7 @@ void *CacheImageBuffer(void *pdata){ } - while(((ProgData *)pdata)->running){ + while(pdata->running){ int prev; int j; unsigned short ynum,unum,vnum; @@ -111,20 +111,20 @@ void *CacheImageBuffer(void *pdata){ FrameHeader fheader; ynum=unum=vnum=0; - pthread_cond_wait(&((ProgData *)pdata)->image_buffer_ready,&imut); + pthread_cond_wait(&pdata->image_buffer_ready,&imut); if(Paused) - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); + pthread_cond_wait(&pdata->pause_cond,&pmut); + pthread_mutex_lock(&pdata->yuv_mutex); //rotate buffers prev=current; current=(current)?0:1; //copy incoming - memcpy(yuv[current].y,((ProgData *)pdata)->enc_data->yuv.y,yuv[current].y_width*yuv[current].y_height); - memcpy(yuv[current].u,((ProgData *)pdata)->enc_data->yuv.u,yuv[current].uv_width*yuv[current].uv_height); - memcpy(yuv[current].v,((ProgData *)pdata)->enc_data->yuv.v,yuv[current].uv_width*yuv[current].uv_height); + memcpy(yuv[current].y,pdata->enc_data->yuv.y,yuv[current].y_width*yuv[current].y_height); + memcpy(yuv[current].u,pdata->enc_data->yuv.u,yuv[current].uv_width*yuv[current].uv_height); + memcpy(yuv[current].v,pdata->enc_data->yuv.v,yuv[current].uv_width*yuv[current].uv_height); //release main buffer - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); + pthread_mutex_unlock(&pdata->yuv_mutex); //get checksums for new //find and flush different blocks @@ -166,7 +166,7 @@ void *CacheImageBuffer(void *pdata){ } /**WRITE FRAME TO DISK*/ - if(!((ProgData *)pdata)->args.zerocompression){ + if(!pdata->args.zerocompression){ if(ynum+unum+vnum>(pow(divisor,2)+pow(divisor/2,2)*2)/10) gzsetparams (fp,1,Z_FILTERED); else @@ -180,7 +180,7 @@ void *CacheImageBuffer(void *pdata){ fheader.Unum=unum; fheader.Vnum=vnum; fheader.pad=0; - if(!((ProgData *)pdata)->args.zerocompression){ + if(!pdata->args.zerocompression){ nbytes+=gzwrite(fp,(void*)&fheader,sizeof(FrameHeader)); //flush indexes if(ynum)nbytes+=gzwrite(fp,yblocks,ynum); @@ -222,9 +222,9 @@ void *CacheImageBuffer(void *pdata){ /**@________________@**/ - ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels; + pdata->avd+=pdata->frametime*2*pdata->args.channels; if(nbytes>CACHE_FILE_SIZE_LIMIT){ - if(SwapCacheFilesWrite(((ProgData *)pdata)->cache_data->imgdata,nth_cache,&fp,&ucfp)){ + if(SwapCacheFilesWrite(pdata->cache_data->imgdata,nth_cache,&fp,&ucfp)){ fprintf(stderr,"New cache file could not be created.\nEnding recording...\n"); fflush(stderr); raise(SIGINT); //if for some reason we cannot make a new file @@ -249,7 +249,7 @@ void *CacheImageBuffer(void *pdata){ free(yuv[i].v); } fprintf(stderr,"Saved %d frames in a total of %d requests\n",frameno,frames_total); - if(!((ProgData *)pdata)->args.zerocompression){ + if(!pdata->args.zerocompression){ gzflush(fp,Z_FINISH); gzclose(fp); } diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c index 3bda596..f9a7675 100644 --- a/recordmydesktop/src/capture_sound.c +++ b/recordmydesktop/src/capture_sound.c @@ -27,83 +27,83 @@ #include <recordmydesktop.h> -void *CaptureSound(void *pdata){ +void *CaptureSound(ProgData *pdata){ - int frames=((ProgData *)pdata)->periodsize>>((ProgData *)pdata)->args.channels; -// fprintf(stderr,"fr %d ps %d\n",frames,((ProgData *)pdata)->periodsize);fflush(stderr); + int frames=pdata->periodsize>>pdata->args.channels; +// fprintf(stderr,"fr %d ps %d\n",frames,pdata->periodsize);fflush(stderr); pthread_mutex_t pmut; pthread_mutex_init(&pmut,NULL); - ((ProgData *)pdata)->sound_buffer=NULL; + pdata->sound_buffer=NULL; - while(((ProgData *)pdata)->running){ + while(pdata->running){ int sret=0; SndBuffer *newbuf,*tmp; if(Paused){ - if(!((ProgData *)pdata)->hard_pause){ - snd_pcm_pause(((ProgData *)pdata)->sound_handle,1); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); - snd_pcm_pause(((ProgData *)pdata)->sound_handle,0); + if(!pdata->hard_pause){ + snd_pcm_pause(pdata->sound_handle,1); + pthread_cond_wait(&pdata->pause_cond,&pmut); + snd_pcm_pause(pdata->sound_handle,0); } else{//device doesn't support pause(is this the norm?mine doesn't) - snd_pcm_close(((ProgData *)pdata)->sound_handle); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); + snd_pcm_close(pdata->sound_handle); + pthread_cond_wait(&pdata->pause_cond,&pmut); - ((ProgData *)pdata)->sound_handle= - OpenDev(((ProgData *)pdata)->args.device, - &((ProgData *)pdata)->args.channels, - &((ProgData *)pdata)->args.frequency, + pdata->sound_handle= + OpenDev(pdata->args.device, + &pdata->args.channels, + &pdata->args.frequency, NULL, NULL, NULL//let's hope that the device capabilities didn't magically change ); - if(((ProgData *)pdata)->sound_handle==NULL){ + if(pdata->sound_handle==NULL){ fprintf(stderr,"Couldn't reopen sound device.Exiting\n"); - ((ProgData *)pdata)->running=0; + pdata->running=0; errno=3; pthread_exit(&errno); - } + } } } //create new buffer newbuf=(SndBuffer *)malloc(sizeof(SndBuffer *)); - newbuf->data=(signed char *)malloc(((ProgData *)pdata)->periodsize); + newbuf->data=(signed char *)malloc(pdata->periodsize); newbuf->next=NULL; - - //read data into new buffer + + //read data into new buffer while(sret<frames){ - int temp_sret=snd_pcm_readi(((ProgData *)pdata)->sound_handle, - newbuf->data+2*((ProgData *)pdata)->args.channels*sret, + int temp_sret=snd_pcm_readi(pdata->sound_handle, + newbuf->data+2*pdata->args.channels*sret, frames-sret); if(temp_sret==-EPIPE) - snd_pcm_prepare(((ProgData *)pdata)->sound_handle); + snd_pcm_prepare(pdata->sound_handle); else if (temp_sret<0){ fprintf(stderr,"An error occured while reading sound data:\n %s\n",snd_strerror(temp_sret)); - snd_pcm_prepare(((ProgData *)pdata)->sound_handle); + snd_pcm_prepare(pdata->sound_handle); } else sret+=temp_sret; } //queue the new buffer - pthread_mutex_lock(&((ProgData *)pdata)->sound_buffer_mutex); - tmp=((ProgData *)pdata)->sound_buffer; - if(((ProgData *)pdata)->sound_buffer==NULL) - ((ProgData *)pdata)->sound_buffer=newbuf; + pthread_mutex_lock(&pdata->sound_buffer_mutex); + tmp=pdata->sound_buffer; + if(pdata->sound_buffer==NULL) + pdata->sound_buffer=newbuf; else{ while(tmp->next!=NULL) tmp=tmp->next; tmp->next=newbuf; } - pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex); + pthread_mutex_unlock(&pdata->sound_buffer_mutex); //signal that there are data to be proccessed - pthread_cond_signal(&((ProgData *)pdata)->sound_data_read); + pthread_cond_signal(&pdata->sound_data_read); } - snd_pcm_close(((ProgData *)pdata)->sound_handle); + snd_pcm_close(pdata->sound_handle); pthread_exit(&errno); -} +} diff --git a/recordmydesktop/src/encode_image_buffer.c b/recordmydesktop/src/encode_image_buffer.c index 8ff9629..b68a71e 100644 --- a/recordmydesktop/src/encode_image_buffer.c +++ b/recordmydesktop/src/encode_image_buffer.c @@ -25,39 +25,39 @@ **********************************************************************************/ #include <recordmydesktop.h> -void *EncodeImageBuffer(void *pdata){ +void *EncodeImageBuffer(ProgData *pdata){ pthread_mutex_t pmut,imut; pthread_mutex_init(&pmut,NULL); pthread_mutex_init(&imut,NULL); - while(((ProgData *)pdata)->running){ - pthread_cond_wait(&((ProgData *)pdata)->image_buffer_ready,&imut); + while(pdata->running){ + pthread_cond_wait(&pdata->image_buffer_ready,&imut); encoder_busy=1; if(Paused) - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut);//this may not be needed - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - if(theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv)){ + pthread_cond_wait(&pdata->pause_cond,&pmut);//this may not be needed + pthread_mutex_lock(&pdata->yuv_mutex); + if(theora_encode_YUVin(&pdata->enc_data->m_th_st,&pdata->enc_data->yuv)){ fprintf(stderr,"Encoder not ready!\n"); - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); + pthread_mutex_unlock(&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){ - pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex); - ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt1); - pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex); - ((ProgData *)pdata)->avd+=((ProgData *)pdata)->frametime*2*((ProgData *)pdata)->args.channels; + pthread_mutex_unlock(&pdata->yuv_mutex); + if(theora_encode_packetout(&pdata->enc_data->m_th_st,0,&pdata->enc_data->m_ogg_pckt1)==1){ + pthread_mutex_lock(&pdata->libogg_mutex); + ogg_stream_packetin(&pdata->enc_data->m_ogg_ts,&pdata->enc_data->m_ogg_pckt1); + pthread_mutex_unlock(&pdata->libogg_mutex); + pdata->avd+=pdata->frametime*2*pdata->args.channels; } } encoder_busy=0; } //last packet - if(theora_encode_YUVin(&((ProgData *)pdata)->enc_data->m_th_st,&((ProgData *)pdata)->enc_data->yuv)){ + if(theora_encode_YUVin(&pdata->enc_data->m_th_st,&pdata->enc_data->yuv)){ fprintf(stderr,"Encoder not ready!\n"); } - theora_encode_packetout(&((ProgData *)pdata)->enc_data->m_th_st,1,&((ProgData *)pdata)->enc_data->m_ogg_pckt1); + theora_encode_packetout(&pdata->enc_data->m_th_st,1,&pdata->enc_data->m_ogg_pckt1); -// ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_ts,&((ProgData *)pdata)->enc_data->m_ogg_pckt); +// ogg_stream_packetin(&pdata->enc_data->m_ogg_ts,&pdata->enc_data->m_ogg_pckt); pthread_exit(&errno); } diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c index 73f6d48..aeea402 100644 --- a/recordmydesktop/src/encode_sound_buffer.c +++ b/recordmydesktop/src/encode_sound_buffer.c @@ -27,12 +27,12 @@ #include <recordmydesktop.h> -void *EncodeSoundBuffer(void *pdata){ +void *EncodeSoundBuffer(ProgData *pdata){ - int sampread=((ProgData *)pdata)->periodsize/(2*((ProgData *)pdata)->args.channels); + int sampread=pdata->periodsize/(2*pdata->args.channels); pthread_mutex_t smut; pthread_mutex_init(&smut,NULL); - while((((ProgData *)pdata)->running)){ + while((pdata->running)){ float **vorbis_buffer; int count=0,i,j; SndBuffer *buff; @@ -40,51 +40,51 @@ void *EncodeSoundBuffer(void *pdata){ if(Paused){ pthread_mutex_t tmut; pthread_mutex_init(&tmut,NULL); - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&tmut); + pthread_cond_wait(&pdata->pause_cond,&tmut); } - if(((ProgData *)pdata)->sound_buffer==NULL) - pthread_cond_wait(&((ProgData *)pdata)->sound_data_read,&smut); + if(pdata->sound_buffer==NULL) + pthread_cond_wait(&pdata->sound_data_read,&smut); - pthread_mutex_lock(&((ProgData *)pdata)->sound_buffer_mutex); - buff=((ProgData *)pdata)->sound_buffer; + pthread_mutex_lock(&pdata->sound_buffer_mutex); + buff=pdata->sound_buffer; //advance the list - ((ProgData *)pdata)->sound_buffer=((ProgData *)pdata)->sound_buffer->next; - pthread_mutex_unlock(&((ProgData *)pdata)->sound_buffer_mutex); - - vorbis_buffer=vorbis_analysis_buffer(&((ProgData *)pdata)->enc_data->m_vo_dsp,sampread); + pdata->sound_buffer=pdata->sound_buffer->next; + pthread_mutex_unlock(&pdata->sound_buffer_mutex); + + vorbis_buffer=vorbis_analysis_buffer(&pdata->enc_data->m_vo_dsp,sampread); for(i=0;i<sampread;i++){ - for(j=0;j<((ProgData *)pdata)->args.channels;j++){ + for(j=0;j<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)){ - pthread_mutex_lock(&((ProgData *)pdata)->libogg_mutex); - ogg_stream_packetin(&((ProgData *)pdata)->enc_data->m_ogg_vs,&((ProgData *)pdata)->enc_data->m_ogg_pckt2); - pthread_mutex_unlock(&((ProgData *)pdata)->libogg_mutex); + vorbis_analysis_wrote(&pdata->enc_data->m_vo_dsp,sampread); + + while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_vo_block)==1){ + + vorbis_analysis(&pdata->enc_data->m_vo_block,NULL); + vorbis_bitrate_addblock(&pdata->enc_data->m_vo_block); + + while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_ogg_pckt2)){ + pthread_mutex_lock(&pdata->libogg_mutex); + ogg_stream_packetin(&pdata->enc_data->m_ogg_vs,&pdata->enc_data->m_ogg_pckt2); + pthread_mutex_unlock(&pdata->libogg_mutex); } } - ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime; + pdata->avd-=pdata->periodtime; free(buff->data); free(buff); } - vorbis_analysis_wrote(&((ProgData *)pdata)->enc_data->m_vo_dsp,0); -// 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_analysis_wrote(&pdata->enc_data->m_vo_dsp,0); +// while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_vo_block)==1){ +// vorbis_analysis(&pdata->enc_data->m_vo_block,NULL); +// vorbis_bitrate_addblock(&pdata->enc_data->m_vo_block); +// while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_ogg_pckt2)) +// ogg_stream_packetin(&pdata->enc_data->m_ogg_vs,&pdata->enc_data->m_ogg_pckt2); // } pthread_exit(&errno); @@ -106,10 +106,10 @@ void SyncEncodeSoundBuffer(ProgData *pdata,signed char *buff){ vorbis_analysis_wrote(&pdata->enc_data->m_vo_dsp,sampread); while(vorbis_analysis_blockout(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_vo_block)==1){ - + vorbis_analysis(&pdata->enc_data->m_vo_block,NULL); vorbis_bitrate_addblock(&pdata->enc_data->m_vo_block); - + while(vorbis_bitrate_flushpacket(&pdata->enc_data->m_vo_dsp,&pdata->enc_data->m_ogg_pckt2)){ pthread_mutex_lock(&pdata->libogg_mutex); ogg_stream_packetin(&pdata->enc_data->m_ogg_vs,&pdata->enc_data->m_ogg_pckt2); diff --git a/recordmydesktop/src/flush_to_ogg.c b/recordmydesktop/src/flush_to_ogg.c index fed07c5..f28adbe 100644 --- a/recordmydesktop/src/flush_to_ogg.c +++ b/recordmydesktop/src/flush_to_ogg.c @@ -26,55 +26,55 @@ #include <recordmydesktop.h> -void *FlushToOgg(void *pdata){ +void *FlushToOgg(ProgData *pdata){ int videoflag=0,audioflag=0; double video_bytesout=0,audio_bytesout=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); + while(pdata->running){ + pthread_mutex_lock(&pdata->libogg_mutex); + videoflag=ogg_stream_pageout(&pdata->enc_data->m_ogg_ts,&videopage); + pthread_mutex_unlock(&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); + video_bytesout+=fwrite(videopage.header,1,videopage.header_len,pdata->enc_data->fp); + video_bytesout+=fwrite(videopage.body,1,videopage.body_len,pdata->enc_data->fp); videoflag=0; - 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(!pdata->args.nosound){ + pthread_mutex_lock(&pdata->libogg_mutex); + audioflag=ogg_stream_pageout(&pdata->enc_data->m_ogg_vs,&audiopage); + pthread_mutex_unlock(&pdata->libogg_mutex); 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); + audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,pdata->enc_data->fp); + audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,pdata->enc_data->fp); audioflag=0; } } } else usleep(10000); - + } //last packages - videoflag=ogg_stream_flush(&((ProgData *)pdata)->enc_data->m_ogg_ts,&videopage); + videoflag=ogg_stream_flush(&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); + video_bytesout+=fwrite(videopage.header,1,videopage.header_len,pdata->enc_data->fp); + video_bytesout+=fwrite(videopage.body,1,videopage.body_len,pdata->enc_data->fp); videoflag=0; } - if(!((ProgData *)pdata)->args.nosound) - audioflag=ogg_stream_flush(&((ProgData *)pdata)->enc_data->m_ogg_vs,&audiopage); + if(!pdata->args.nosound) + audioflag=ogg_stream_flush(&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); + audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,pdata->enc_data->fp); + audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,pdata->enc_data->fp); audioflag=0; } - ogg_stream_clear(&((ProgData *)pdata)->enc_data->m_ogg_ts); - if(!((ProgData *)pdata)->args.nosound) - ogg_stream_clear(&((ProgData *)pdata)->enc_data->m_ogg_vs); + ogg_stream_clear(&pdata->enc_data->m_ogg_ts); + if(!pdata->args.nosound) + ogg_stream_clear(&pdata->enc_data->m_ogg_vs); //this always gives me a segfault :( -// theora_clear(&((ProgData *)pdata)->enc_data->m_th_st); - - if(((ProgData *)pdata)->enc_data->fp)fclose(((ProgData *)pdata)->enc_data->fp); +// 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); diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c index b1da1fe..d020f97 100644 --- a/recordmydesktop/src/get_frame.c +++ b/recordmydesktop/src/get_frame.c @@ -27,47 +27,47 @@ #include <recordmydesktop.h> -void *GetFrame(void *pdata){ +void *GetFrame(ProgData *pdata){ int tlist_sel=0; pthread_mutex_t pmut,tmut; uint msk_ret; WGeometry mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; Window root_ret,child_ret; - int pixel_total=((ProgData *)pdata)->brwin.rgeom.width*((ProgData *)pdata)->brwin.rgeom.height; + int pixel_total=pdata->brwin.rgeom.width*pdata->brwin.rgeom.height; XFixesCursorImage *xcim=NULL; mouse_pos_abs.x=mouse_pos_temp.x=0; mouse_pos_abs.y=mouse_pos_temp.y=0; - mouse_pos_abs.width=mouse_pos_temp.width=((ProgData *)pdata)->dummy_p_size; - mouse_pos_abs.height=mouse_pos_temp.height=((ProgData *)pdata)->dummy_p_size; + mouse_pos_abs.width=mouse_pos_temp.width=pdata->dummy_p_size; + mouse_pos_abs.height=mouse_pos_temp.height=pdata->dummy_p_size; pthread_mutex_init(&pmut,NULL); pthread_mutex_init(&tmut,NULL); - while(((ProgData *)pdata)->running){ - + while(pdata->running){ + //if we are left behind we must not wait. - //also before actually pausing we must make sure the streams + //also before actually pausing we must make sure the streams //are synced. sound stops so this should only happen quickly. - if(((ProgData *)pdata)->avd>0){ - pthread_cond_wait(&((ProgData *)pdata)->time_cond,&tmut); + if(pdata->avd>0){ + pthread_cond_wait(&pdata->time_cond,&tmut); if(Paused){ - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); + pthread_cond_wait(&pdata->pause_cond,&pmut); } } capture_busy=1; - - /*pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&((ProgData *)pdata)->pause_cond_mutex);*/ + + /*pthread_cond_wait(&pdata->pause_cond,&pdata->pause_cond_mutex);*/ //mutexes and lists with changes are useless when full_shots is enabled - if(!((ProgData *)pdata)->args.full_shots){ - tlist_sel=((ProgData *)pdata)->list_selector; - ((ProgData *)pdata)->list_selector=((((ProgData *)pdata)->list_selector+1)%2); - pthread_mutex_lock(&((ProgData *)pdata)->list_mutex[tlist_sel]); + if(!pdata->args.full_shots){ + tlist_sel=pdata->list_selector; + pdata->list_selector=((pdata->list_selector+1)%2); + pthread_mutex_lock(&pdata->list_mutex[tlist_sel]); } //here we measure the list and decide which way we will go - if(!((ProgData *)pdata)->args.nocondshared){ + if(!pdata->args.nocondshared){ int level=0; - RectArea *temp=((ProgData *)pdata)->rect_root[tlist_sel]; - + RectArea *temp=pdata->rect_root[tlist_sel]; + if(temp!=NULL){ do{ level+=temp->geom.width*temp->geom.height; @@ -75,102 +75,102 @@ void *GetFrame(void *pdata){ }while(temp!=NULL); level*=100; level/=pixel_total; - ((ProgData *)pdata)->args.noshared=(level<((ProgData *)pdata)->args.shared_thres); -// if(!((ProgData *)pdata)->args.noshared){ + pdata->args.noshared=(level<pdata->args.shared_thres); +// if(!pdata->args.noshared){ // fprintf(stderr,"shared screenshot with %d\n",level); // } } } - if(((ProgData *)pdata)->args.xfixes_cursor){ + if(pdata->args.xfixes_cursor){ //xfixes pointer sequence //update previous_position //(if full_shots is enabled this is skipped since it's pointless) - if(!((ProgData *)pdata)->args.full_shots){ - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); + if(!pdata->args.full_shots){ + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)) - RectInsert(&((ProgData *)pdata)->rect_root[tlist_sel],&mouse_pos_temp); + RectInsert(&pdata->rect_root[tlist_sel],&mouse_pos_temp); } - xcim=XFixesGetCursorImage(((ProgData *)pdata)->dpy); + xcim=XFixesGetCursorImage(pdata->dpy); mouse_pos_abs.x=xcim->x; mouse_pos_abs.y=xcim->y; mouse_pos_abs.width=xcim->width; mouse_pos_abs.height=xcim->height; } - if(((ProgData *)pdata)->args.have_dummy_cursor){ + if(pdata->args.have_dummy_cursor){ //dummy pointer sequence //update previous_position //(if full_shots is enabled this is skipped since it's pointless) - if(!((ProgData *)pdata)->args.full_shots){ - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); + if(!pdata->args.full_shots){ + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)) - RectInsert(&((ProgData *)pdata)->rect_root[tlist_sel],&mouse_pos_temp); + RectInsert(&pdata->rect_root[tlist_sel],&mouse_pos_temp); } //find new one - XQueryPointer(((ProgData *)pdata)->dpy, - ((ProgData *)pdata)->specs.root, + XQueryPointer(pdata->dpy, + pdata->specs.root, &root_ret,&child_ret, &mouse_pos_abs.x,&mouse_pos_abs.y, &mouse_pos_rel.x,&mouse_pos_rel.y,&msk_ret); } - if(!((ProgData *)pdata)->args.noshared) - XShmGetImage(((ProgData *)pdata)->dpy,((ProgData *)pdata)->specs.root,((ProgData *)pdata)->shimage,(((ProgData *)pdata)->brwin.rgeom.x),(((ProgData *)pdata)->brwin.rgeom.y),AllPlanes); - if(!((ProgData *)pdata)->args.full_shots) - UpdateImage(((ProgData *)pdata)->dpy, - &((ProgData *)pdata)->enc_data->yuv, - &((ProgData *)pdata)->yuv_mutex, - &((ProgData *)pdata)->specs, - &((ProgData *)pdata)->rect_root[tlist_sel], - &((ProgData *)pdata)->brwin, - ((ProgData *)pdata)->enc_data, - ((((ProgData *)pdata)->args.noshared)?(((ProgData *)pdata)->datatemp):((ProgData *)pdata)->shimage->data), - ((ProgData *)pdata)->args.noshared, - ((ProgData *)pdata)->args.no_quick_subsample); + if(!pdata->args.noshared) + XShmGetImage(pdata->dpy,pdata->specs.root,pdata->shimage,(pdata->brwin.rgeom.x),(pdata->brwin.rgeom.y),AllPlanes); + if(!pdata->args.full_shots) + UpdateImage(pdata->dpy, + &pdata->enc_data->yuv, + &pdata->yuv_mutex, + &pdata->specs, + &pdata->rect_root[tlist_sel], + &pdata->brwin, + pdata->enc_data, + ((pdata->args.noshared)?(pdata->datatemp):pdata->shimage->data), + pdata->args.noshared, + pdata->args.no_quick_subsample); else{ - if(((ProgData *)pdata)->args.noshared){ - GetZPixmap( ((ProgData *)pdata)->dpy, - ((ProgData *)pdata)->specs.root, - ((ProgData *)pdata)->image->data, - ((ProgData *)pdata)->brwin.rgeom.x, - ((ProgData *)pdata)->brwin.rgeom.y, - ((ProgData *)pdata)->brwin.rgeom.width, - ((ProgData *)pdata)->brwin.rgeom.height); - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - if(((ProgData *)pdata)->args.no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->image->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); + if(pdata->args.noshared){ + GetZPixmap( pdata->dpy, + pdata->specs.root, + pdata->image->data, + pdata->brwin.rgeom.x, + pdata->brwin.rgeom.y, + pdata->brwin.rgeom.width, + pdata->brwin.rgeom.height); + pthread_mutex_lock(&pdata->yuv_mutex); + if(pdata->args.no_quick_subsample){ + UPDATE_YUV_BUFFER_IM_AVG((&pdata->enc_data->yuv),((unsigned char*)pdata->image->data), + (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), + (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height)); } else{ - UPDATE_YUV_BUFFER_IM((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->image->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); + UPDATE_YUV_BUFFER_IM((&pdata->enc_data->yuv),((unsigned char*)pdata->image->data), + (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), + (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height)); } - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); + pthread_mutex_unlock(&pdata->yuv_mutex); } else{ - pthread_mutex_lock(&((ProgData *)pdata)->yuv_mutex); - if(((ProgData *)pdata)->args.no_quick_subsample){ - UPDATE_YUV_BUFFER_IM_AVG((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->shimage->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); + pthread_mutex_lock(&pdata->yuv_mutex); + if(pdata->args.no_quick_subsample){ + UPDATE_YUV_BUFFER_IM_AVG((&pdata->enc_data->yuv),((unsigned char*)pdata->shimage->data), + (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), + (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height)); } else{ - UPDATE_YUV_BUFFER_IM((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)((ProgData *)pdata)->shimage->data), - (((ProgData *)pdata)->enc_data->x_offset),(((ProgData *)pdata)->enc_data->y_offset), - (((ProgData *)pdata)->brwin.rgeom.width),(((ProgData *)pdata)->brwin.rgeom.height)); + UPDATE_YUV_BUFFER_IM((&pdata->enc_data->yuv),((unsigned char*)pdata->shimage->data), + (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), + (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height)); } - pthread_mutex_unlock(&((ProgData *)pdata)->yuv_mutex); + pthread_mutex_unlock(&pdata->yuv_mutex); } } - if(((ProgData *)pdata)->args.xfixes_cursor){ + if(pdata->args.xfixes_cursor){ //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); //draw the cursor if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)){ - XFIXES_POINTER_TO_YUV((&((ProgData *)pdata)->enc_data->yuv),((unsigned char*)xcim->pixels), - (mouse_pos_temp.x-((ProgData *)pdata)->brwin.rgeom.x+((ProgData *)pdata)->enc_data->x_offset), - (mouse_pos_temp.y-((ProgData *)pdata)->brwin.rgeom.y+((ProgData *)pdata)->enc_data->y_offset), + XFIXES_POINTER_TO_YUV((&pdata->enc_data->yuv),((unsigned char*)xcim->pixels), + (mouse_pos_temp.x-pdata->brwin.rgeom.x+pdata->enc_data->x_offset), + (mouse_pos_temp.y-pdata->brwin.rgeom.y+pdata->enc_data->y_offset), mouse_pos_temp.width, mouse_pos_temp.height, (xcim->width-mouse_pos_temp.width)); @@ -179,31 +179,31 @@ void *GetFrame(void *pdata){ xcim=NULL; } - if(((ProgData *)pdata)->args.have_dummy_cursor){ + if(pdata->args.have_dummy_cursor){ //avoid segfaults - CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&((ProgData *)pdata)->brwin,&mouse_pos_temp); + CLIP_DUMMY_POINTER_AREA(mouse_pos_abs,&pdata->brwin,&mouse_pos_temp); //draw the cursor if((mouse_pos_temp.x>=0)&&(mouse_pos_temp.y>=0)&&(mouse_pos_temp.width>0)&&(mouse_pos_temp.height>0)){ - DUMMY_POINTER_TO_YUV((&((ProgData *)pdata)->enc_data->yuv), - ((ProgData *)pdata)->dummy_pointer, - (mouse_pos_temp.x-((ProgData *)pdata)->brwin.rgeom.x+((ProgData *)pdata)->enc_data->x_offset), - (mouse_pos_temp.y-((ProgData *)pdata)->brwin.rgeom.y+((ProgData *)pdata)->enc_data->y_offset), + DUMMY_POINTER_TO_YUV((&pdata->enc_data->yuv), + pdata->dummy_pointer, + (mouse_pos_temp.x-pdata->brwin.rgeom.x+pdata->enc_data->x_offset), + (mouse_pos_temp.y-pdata->brwin.rgeom.y+pdata->enc_data->y_offset), mouse_pos_temp.width, mouse_pos_temp.height, - ((ProgData *)pdata)->npxl); + pdata->npxl); } } - if(!((ProgData *)pdata)->args.full_shots){ - ClearList(&((ProgData *)pdata)->rect_root[tlist_sel]); - pthread_mutex_unlock(&((ProgData *)pdata)->list_mutex[tlist_sel]); + if(!pdata->args.full_shots){ + ClearList(&pdata->rect_root[tlist_sel]); + pthread_mutex_unlock(&pdata->list_mutex[tlist_sel]); } if(encoder_busy){ frames_lost++; } - pthread_cond_broadcast(&((ProgData *)pdata)->image_buffer_ready); + pthread_cond_broadcast(&pdata->image_buffer_ready); capture_busy=0; } - pthread_cond_broadcast(&((ProgData *)pdata)->image_buffer_ready); + pthread_cond_broadcast(&pdata->image_buffer_ready); pthread_exit(&errno); } diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c index 2606900..8a61159 100644 --- a/recordmydesktop/src/load_cache.c +++ b/recordmydesktop/src/load_cache.c @@ -40,15 +40,15 @@ void LoadBlock(unsigned char *dest,unsigned char *source,int blockno,int width, -void *LoadCache(void *pdata){ +void *LoadCache(ProgData *pdata){ - yuv_buffer *yuv=&((ProgData *)pdata)->enc_data->yuv; + yuv_buffer *yuv=&pdata->enc_data->yuv; gzFile *ifp=NULL; FILE *ucfp=NULL; - FILE *afp=((ProgData *)pdata)->cache_data->afp; + FILE *afp=pdata->cache_data->afp; FrameHeader fheader; CachedFrame frame; - signed char *sound_data=(signed char *)malloc(((ProgData *)pdata)->periodsize); + signed char *sound_data=(signed char *)malloc(pdata->periodsize); int j=0, nth_cache=1, @@ -63,15 +63,15 @@ void *LoadCache(void *pdata){ //we allocate the frame that we will use INIT_FRAME(&frame,&fheader,yuv) //and the we open our files - if(!((ProgData *)pdata)->args.zerocompression){ - ifp=gzopen(((ProgData *)pdata)->cache_data->imgdata,"rb"); + if(!pdata->args.zerocompression){ + ifp=gzopen(pdata->cache_data->imgdata,"rb"); if(ifp==NULL){ thread_exit=-1; pthread_exit(&thread_exit); } } else{ - ucfp=fopen(((ProgData *)pdata)->cache_data->imgdata,"rb"); + ucfp=fopen(pdata->cache_data->imgdata,"rb"); if(ucfp==NULL){ thread_exit=-1; pthread_exit(&thread_exit); @@ -79,8 +79,8 @@ void *LoadCache(void *pdata){ } - if(!((ProgData *)pdata)->args.nosound){ - afp=fopen(((ProgData *)pdata)->cache_data->audiodata,"rb"); + if(!pdata->args.nosound){ + afp=fopen(pdata->cache_data->audiodata,"rb"); if(afp==NULL){ thread_exit=-1; pthread_exit(&thread_exit); @@ -93,20 +93,20 @@ void *LoadCache(void *pdata){ //this will be used now to define if we proccess audio or video //on any given loop. - ((ProgData *)pdata)->avd=0; + pdata->avd=0; //If sound finishes first,we go on with the video. //If video ends we will do one more run to flush audio in the ogg file - while(((ProgData *)pdata)->running){ + while(pdata->running){ //video load and encoding - if(((ProgData *)pdata)->avd<=0 || ((ProgData *)pdata)->args.nosound || audio_end){ + if(pdata->avd<=0 || pdata->args.nosound || audio_end){ if(missing_frames>0){ extra_frames++; missing_frames--; - SyncEncodeImageBuffer((ProgData *)pdata); + SyncEncodeImageBuffer(pdata); } - else if(((!((ProgData *)pdata)->args.zerocompression)&& + else if(((!pdata->args.zerocompression)&& (gzread(ifp,frame.header,sizeof(FrameHeader))==sizeof(FrameHeader) ))|| - ((((ProgData *)pdata)->args.zerocompression)&& + ((pdata->args.zerocompression)&& (fread(frame.header,sizeof(FrameHeader),1,ucfp)==1))){ //sync missing_frames+=frame.header->current_total-(extra_frames+frame.header->frameno); @@ -119,7 +119,7 @@ void *LoadCache(void *pdata){ (frame.header->Vnum<=pow(divisor/2,2)) && ( - ((!((ProgData *)pdata)->args.zerocompression)&& + ((!pdata->args.zerocompression)&& ((gzread(ifp,frame.YBlocks,frame.header->Ynum)==frame.header->Ynum) && (gzread(ifp,frame.UBlocks,frame.header->Unum)==frame.header->Unum) && (gzread(ifp,frame.VBlocks,frame.header->Vnum)==frame.header->Vnum) && @@ -127,7 +127,7 @@ void *LoadCache(void *pdata){ (gzread(ifp,frame.UData,(blockszuv*frame.header->Unum))==(blockszuv*frame.header->Unum)) && (gzread(ifp,frame.VData,(blockszuv*frame.header->Vnum))==(blockszuv*frame.header->Vnum)))) || - ((((ProgData *)pdata)->args.zerocompression)&& + ((pdata->args.zerocompression)&& ((fread(frame.YBlocks,1,frame.header->Ynum,ucfp)==frame.header->Ynum) && (fread(frame.UBlocks,1,frame.header->Unum,ucfp)==frame.header->Unum) && (fread(frame.VBlocks,1,frame.header->Vnum,ucfp)==frame.header->Vnum) && @@ -164,7 +164,7 @@ void *LoadCache(void *pdata){ divisor/2); //encode. This is not made in a thread since now blocking is not a problem //and this way sync problems can be avoided more easily. - SyncEncodeImageBuffer((ProgData *)pdata); + SyncEncodeImageBuffer(pdata); } else{ raise(SIGINT); @@ -172,7 +172,7 @@ void *LoadCache(void *pdata){ } } else{ - if(SwapCacheFilesRead(((ProgData *)pdata)->cache_data->imgdata,nth_cache,&ifp,&ucfp)){ + if(SwapCacheFilesRead(pdata->cache_data->imgdata,nth_cache,&ifp,&ucfp)){ raise(SIGINT); } else{ @@ -185,11 +185,11 @@ void *LoadCache(void *pdata){ //audio load and encoding else{ if(!audio_end){ - int nbytes=fread(sound_data,((ProgData *)pdata)->periodsize,1,afp); + int nbytes=fread(sound_data,pdata->periodsize,1,afp); if(nbytes<=0) audio_end=1; else - SyncEncodeSoundBuffer((ProgData *)pdata,sound_data); + SyncEncodeSoundBuffer(pdata,sound_data); } } } @@ -197,7 +197,7 @@ void *LoadCache(void *pdata){ CLEAR_FRAME(&frame) free(sound_data); - if(!((ProgData *)pdata)->args.nosound){ + if(!pdata->args.nosound){ fclose(afp); } diff --git a/recordmydesktop/src/poll_damage.c b/recordmydesktop/src/poll_damage.c index 9bf7ee2..09de911 100644 --- a/recordmydesktop/src/poll_damage.c +++ b/recordmydesktop/src/poll_damage.c @@ -27,7 +27,7 @@ #include <recordmydesktop.h> -void *PollDamage(void *pdata){ +void *PollDamage(ProgData *pdata){ Window root_return, parent_return, *children; @@ -36,10 +36,10 @@ void *PollDamage(void *pdata){ inserts=0; XEvent event; - XSelectInput (((ProgData *)pdata)->dpy,((ProgData *)pdata)->specs.root, SubstructureNotifyMask); + XSelectInput (pdata->dpy,pdata->specs.root, SubstructureNotifyMask); - XQueryTree (((ProgData *)pdata)->dpy, - ((ProgData *)pdata)->specs.root, + XQueryTree (pdata->dpy, + pdata->specs.root, &root_return, &parent_return, &children, @@ -47,38 +47,38 @@ void *PollDamage(void *pdata){ for (i = 0; i < nchildren; i++){ XWindowAttributes attribs; - if (XGetWindowAttributes (((ProgData *)pdata)->dpy,children[i],&attribs)){ - if (!attribs.override_redirect && attribs.depth==((ProgData *)pdata)->specs.depth) - XDamageCreate (((ProgData *)pdata)->dpy, children[i],XDamageReportRawRectangles); + if (XGetWindowAttributes (pdata->dpy,children[i],&attribs)){ + if (!attribs.override_redirect && attribs.depth==pdata->specs.depth) + XDamageCreate (pdata->dpy, children[i],XDamageReportRawRectangles); } } - XDamageCreate( ((ProgData *)pdata)->dpy, ((ProgData *)pdata)->brwin.windowid, XDamageReportRawRectangles); + XDamageCreate( pdata->dpy, pdata->brwin.windowid, XDamageReportRawRectangles); - while(((ProgData *)pdata)->running){ + while(pdata->running){ //damage polling doesn't stop,eventually full image may be needed //30/10/2006 : when and why did I write the above line? what did I mean? - XNextEvent(((ProgData *)pdata)->dpy,&event); + XNextEvent(pdata->dpy,&event); if (event.type == MapNotify ){ XWindowAttributes attribs; - if (!((XMapEvent *)(&event))->override_redirect && XGetWindowAttributes (((ProgData *)pdata)->dpy, + if (!((XMapEvent *)(&event))->override_redirect && XGetWindowAttributes (pdata->dpy, event.xcreatewindow.window, &attribs)){ - if (!attribs.override_redirect && attribs.depth==((ProgData *)pdata)->specs.depth) - XDamageCreate (((ProgData *)pdata)->dpy,event.xcreatewindow.window,XDamageReportRawRectangles); + if (!attribs.override_redirect && attribs.depth==pdata->specs.depth) + XDamageCreate (pdata->dpy,event.xcreatewindow.window,XDamageReportRawRectangles); } } - else if(event.type == ((ProgData *)pdata)->damage_event + XDamageNotify ){ + else if(event.type == pdata->damage_event + XDamageNotify ){ XDamageNotifyEvent *e =(XDamageNotifyEvent *)( &event ); WGeometry wgeom; - CLIP_EVENT_AREA(e,&(((ProgData *)pdata)->brwin),&wgeom); + CLIP_EVENT_AREA(e,&(pdata->brwin),&wgeom); if((wgeom.x>=0)&&(wgeom.y>=0)&&(wgeom.width>0)&&(wgeom.height>0)) { - int tlist_sel=((ProgData *)pdata)->list_selector; - pthread_mutex_lock(&((ProgData *)pdata)->list_mutex[tlist_sel]); - inserts+=RectInsert(&((ProgData *)pdata)->rect_root[tlist_sel],&wgeom); - pthread_mutex_unlock(&((ProgData *)pdata)->list_mutex[tlist_sel]); + int tlist_sel=pdata->list_selector; + pthread_mutex_lock(&pdata->list_mutex[tlist_sel]); + inserts+=RectInsert(&pdata->rect_root[tlist_sel],&wgeom); + pthread_mutex_unlock(&pdata->list_mutex[tlist_sel]); } } diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index 5f2c981..ac1ea16 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -206,22 +206,22 @@ int main(int argc,char **argv){ /*start threads*/ if(!pdata.args.full_shots) - pthread_create(&poll_damage_t,NULL,PollDamage,(void *)&pdata); - pthread_create(&image_capture_t,NULL,GetFrame,(void *)&pdata); + pthread_create(&poll_damage_t,NULL,(void *)PollDamage,(void *)&pdata); + pthread_create(&image_capture_t,NULL,(void *)GetFrame,(void *)&pdata); if(pdata.args.encOnTheFly) - pthread_create(&image_encode_t,NULL,EncodeImageBuffer,(void *)&pdata); + pthread_create(&image_encode_t,NULL,(void *)EncodeImageBuffer,(void *)&pdata); else - pthread_create(&image_cache_t,NULL,CacheImageBuffer,(void *)&pdata); + pthread_create(&image_cache_t,NULL,(void *)CacheImageBuffer,(void *)&pdata); if(!pdata.args.nosound){ - pthread_create(&sound_capture_t,NULL,CaptureSound,(void *)&pdata); + pthread_create(&sound_capture_t,NULL,(void *)CaptureSound,(void *)&pdata); if(pdata.args.encOnTheFly) - pthread_create(&sound_encode_t,NULL,EncodeSoundBuffer,(void *)&pdata); + pthread_create(&sound_encode_t,NULL,(void *)EncodeSoundBuffer,(void *)&pdata); else - pthread_create(&sound_cache_t,NULL,CacheSoundBuffer,(void *)&pdata); + pthread_create(&sound_cache_t,NULL,(void *)CacheSoundBuffer,(void *)&pdata); } if(pdata.args.encOnTheFly) - pthread_create(&flush_to_ogg_t,NULL,FlushToOgg,(void *)&pdata); + pthread_create(&flush_to_ogg_t,NULL,(void *)FlushToOgg,(void *)&pdata); RegisterCallbacks(&pdata.args); @@ -303,11 +303,11 @@ int main(int argc,char **argv){ pdata.sound_buffer=pdata.sound_buffer->next; } } - pthread_create(&flush_to_ogg_t,NULL,FlushToOgg,(void *)&pdata); + pthread_create(&flush_to_ogg_t,NULL,(void *)FlushToOgg,(void *)&pdata); //start loading image and audio - pthread_create(&load_cache_t,NULL,LoadCache,(void *)&pdata); + pthread_create(&load_cache_t,NULL,(void *)LoadCache,(void *)&pdata); //join and finish pthread_join(load_cache_t,NULL); |