diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-10-01 00:18:03 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2006-10-01 00:18:03 +0000 |
commit | ecdc60f49dd56d6cb9253d0105a85027abeb414d (patch) | |
tree | 19dc3c910cf9da35c7ef6df72d8647da19df354b | |
parent | 6d529d133342903f66532231daa301c39784d521 (diff) |
major memory leakage fixed
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@75 f606c939-3180-4ac9-a4b8-4b8779d57d0a
-rw-r--r-- | recordmydesktop/src/encode_image_buffer.c | 14 | ||||
-rw-r--r-- | recordmydesktop/src/encode_sound_buffer.c | 1 | ||||
-rw-r--r-- | recordmydesktop/src/get_frame.c | 22 | ||||
-rw-r--r-- | recordmydesktop/src/recordmydesktop.c | 9 | ||||
-rw-r--r-- | recordmydesktop/src/rectinsert.c | 11 |
5 files changed, 30 insertions, 27 deletions
diff --git a/recordmydesktop/src/encode_image_buffer.c b/recordmydesktop/src/encode_image_buffer.c index 92df5fe..c360488 100644 --- a/recordmydesktop/src/encode_image_buffer.c +++ b/recordmydesktop/src/encode_image_buffer.c @@ -29,26 +29,12 @@ void *EncodeImageBuffer(void *pdata){ pthread_mutex_t pmut,imut; pthread_mutex_init(&pmut,NULL); pthread_mutex_init(&imut,NULL); - int counter=0; 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); -//code duplication is evil. -//almost as evil as globals... - counter=((ProgData *)pdata)->args.fps; - 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(!((ProgData *)pdata)->running || counter<=0) - break; - counter--; - } 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); diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c index 48410f3..094b64c 100644 --- a/recordmydesktop/src/encode_sound_buffer.c +++ b/recordmydesktop/src/encode_sound_buffer.c @@ -72,6 +72,7 @@ void *EncodeSoundBuffer(void *pdata){ } ((ProgData *)pdata)->avd-=((ProgData *)pdata)->periodtime; + free(buff->data); free(buff); } diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c index 2ee525d..d34af43 100644 --- a/recordmydesktop/src/get_frame.c +++ b/recordmydesktop/src/get_frame.c @@ -36,17 +36,23 @@ void *GetFrame(void *pdata){ int pixel_total=((ProgData *)pdata)->brwin.rgeom.width*((ProgData *)pdata)->brwin.rgeom.height; XFixesCursorImage *xcim=NULL; - mouse_pos_abs.x=0; - mouse_pos_abs.y=0; - mouse_pos_abs.width=((ProgData *)pdata)->dummy_p_size; - mouse_pos_abs.height=((ProgData *)pdata)->dummy_p_size; + 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; pthread_mutex_init(&pmut,NULL); pthread_mutex_init(&tmut,NULL); while(((ProgData *)pdata)->running){ - pthread_cond_wait(&((ProgData *)pdata)->time_cond,&tmut); - if(Paused){ - pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); + + //if we are left behind we must not wait. + //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(Paused){ + pthread_cond_wait(&((ProgData *)pdata)->pause_cond,&pmut); + } } capture_busy=1; @@ -169,6 +175,8 @@ void *GetFrame(void *pdata){ mouse_pos_temp.height, (xcim->width-mouse_pos_temp.width)); } + XFree(xcim); + xcim=NULL; } if(((ProgData *)pdata)->args.have_dummy_cursor){ diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index 6a106b9..adfc343 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -139,11 +139,12 @@ int main(int argc,char **argv){ fprintf(stderr,"done!\n"); exit(0); } - if(!pdata.args.nosound) + if(!pdata.args.nosound){ pdata.sound_handle=OpenDev(pdata.args.device,&pdata.args.channels,&pdata.args.frequency,&pdata.periodsize, &pdata.periodtime,&pdata.hard_pause); - if(pdata.sound_handle==NULL){ - fprintf(stderr,"Error while opening/configuring soundcard %s\nTry running with the --no-sound or specify a correct device.\n",pdata.args.device); - exit(3); + if(pdata.sound_handle==NULL){ + fprintf(stderr,"Error while opening/configuring soundcard %s\nTry running with the --no-sound or specify a correct device.\n",pdata.args.device); + exit(3); + } } InitEncoder(&pdata,&enc_data); for(i=0;i<(pdata.enc_data->yuv.y_width*pdata.enc_data->yuv.y_height);i++) diff --git a/recordmydesktop/src/rectinsert.c b/recordmydesktop/src/rectinsert.c index 3bec07d..a4bb7a6 100644 --- a/recordmydesktop/src/rectinsert.c +++ b/recordmydesktop/src/rectinsert.c @@ -152,7 +152,11 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in //if the first one breaks(which is already inserted) //then we reenter the part that was left and the one //that was to be inserted - wgeom_return[1]=wgeom2; +// wgeom_return[1]=wgeom2; + wgeom_return[1]->x=wgeom2->x; + wgeom_return[1]->y=wgeom2->y; + wgeom_return[1]->width=wgeom2->width; + wgeom_return[1]->height=wgeom2->height; // wgeom_return[0]=(WGeometry *)malloc(sizeof(WGeometry)); wgeom_return[0]->x=wgeom1->x; wgeom_return[0]->y=wgeom1->y; @@ -268,7 +272,7 @@ int CollideRects(WGeometry *wgeom1,WGeometry *wgeom2,WGeometry **wgeom_return,in int RectInsert(RectArea **root,WGeometry *wgeom){ int total_insertions=0; - RectArea *temp,*newnode=(RectArea *)malloc(sizeof(RectArea)); + RectArea *temp=NULL,*newnode=(RectArea *)malloc(sizeof(RectArea)); //align //we do need to know boundaries wgeom->width+=(wgeom->width%2)|(wgeom->x%2); @@ -466,6 +470,9 @@ int RectInsert(RectArea **root,WGeometry *wgeom){ break; } }; + + free(wgeom_return[0]); + free(wgeom_return[1]); } return total_insertions; } |