diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2008-02-11 10:28:03 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2008-02-11 10:28:03 +0000 |
commit | 26f59efe2c94581d822ce7a0a707a75035b7d046 (patch) | |
tree | c601628f4987284329e31436eee9f6ff6a043169 /recordmydesktop | |
parent | d026b9ec4798582d21dab0f384fbe77b809b7567 (diff) |
src/get_frame.c: added calls to InitEventsPolling and
EventLoop. Now damage events are received and processed
synchronously, before each frame capture.
src/initialize_data.c: removed initalization of some removed
members (dual recy roots ahd their mutexes)
src/poll_events.c: Broken previous/ thread/func (PollEvents)
to InitEventsPolling and EventLoop, which are called from
GetFrame.
src/rmdthreads.c: removed initalization/end of poll_events
thread, as well as hack with extra window, to end that thread.
src/rmd_timer.c: time_cond is broadcasted ecery time now
(nnedeed with new changes)
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@490 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop')
-rw-r--r-- | recordmydesktop/src/get_frame.c | 26 | ||||
-rw-r--r-- | recordmydesktop/src/initialize_data.c | 6 | ||||
-rw-r--r-- | recordmydesktop/src/poll_events.c | 25 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_timer.c | 8 | ||||
-rw-r--r-- | recordmydesktop/src/rmdthreads.c | 29 |
5 files changed, 33 insertions, 61 deletions
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c index cb473b6..6e8463d 100644 --- a/recordmydesktop/src/get_frame.c +++ b/recordmydesktop/src/get_frame.c @@ -130,7 +130,6 @@ void MoveCaptureArea( BRWindow *brwin, void *GetFrame(ProgData *pdata){ int i=0, - tlist_sel=0, blocknum_x=pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH, blocknum_y=pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH; unsigned int msk_ret; @@ -202,6 +201,8 @@ void *GetFrame(ProgData *pdata){ mouse_pos_abs.width=mouse_pos_temp.width=pdata->dummy_p_size; mouse_pos_abs.height=mouse_pos_temp.height=pdata->dummy_p_size; + InitEventsPolling(pdata); + while(pdata->running){ //if we are left behind we must not wait. @@ -212,22 +213,18 @@ void *GetFrame(ProgData *pdata){ pthread_cond_wait(&pdata->time_cond,&time_mutex); pthread_mutex_unlock(&time_mutex); if(Paused){ - pthread_mutex_lock(&pause_mutex); - pthread_cond_wait(&pdata->pause_cond,&pause_mutex); - pthread_mutex_unlock(&pause_mutex); + EventLoop(pdata); + continue; } } + EventLoop(pdata); if(d_buff) img_sel=(img_sel)?0:1; capture_busy=1; BRWinCpy(&temp_brwin,&pdata->brwin); - //mutexes and lists with changes are useless when full_shots is enabled - 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]); - } + + if(pdata->args.xfixes_cursor || pdata->args.have_dummy_cursor|| pdata->args.follow_mouse){ @@ -244,7 +241,7 @@ void *GetFrame(ProgData *pdata){ (mouse_pos_temp.y>=0)&& (mouse_pos_temp.width>0)&& (mouse_pos_temp.height>0)) - RectInsert(&pdata->rect_root[tlist_sel],&mouse_pos_temp); + RectInsert(&pdata->rect_root,&mouse_pos_temp); } //find new one if(pdata->args.xfixes_cursor){ @@ -284,7 +281,7 @@ void *GetFrame(ProgData *pdata){ UpdateImage(pdata->dpy, &pdata->enc_data->yuv, &pdata->specs, - &pdata->rect_root[tlist_sel], + &pdata->rect_root, &temp_brwin, pdata->enc_data, image->data, @@ -292,7 +289,7 @@ void *GetFrame(ProgData *pdata){ &shminfo, pdata->shm_opcode, pdata->args.no_quick_subsample); - BlocksFromList(&pdata->rect_root[tlist_sel], + BlocksFromList(&pdata->rect_root, temp_brwin.rgeom.x, temp_brwin.rgeom.y, pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH, @@ -409,8 +406,7 @@ void *GetFrame(ProgData *pdata){ } } if(!pdata->args.full_shots){ - ClearList(&pdata->rect_root[tlist_sel]); - pthread_mutex_unlock(&pdata->list_mutex[tlist_sel]); + ClearList(&pdata->rect_root); } if(encoder_busy){ frames_lost++; diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c index 2c2dad1..0b2d929 100644 --- a/recordmydesktop/src/initialize_data.c +++ b/recordmydesktop/src/initialize_data.c @@ -62,9 +62,7 @@ int InitializeData(ProgData *pdata, pdata->dummy_p_size=0; - pdata->rect_root[0]=pdata->rect_root[1]=NULL; - pthread_mutex_init(&pdata->list_mutex[0],NULL); - pthread_mutex_init(&pdata->list_mutex[1],NULL); + pdata->rect_root=NULL; pthread_mutex_init(&pdata->sound_buffer_mutex,NULL); pthread_mutex_init(&pdata->snd_buff_ready_mutex,NULL); pthread_mutex_init(&pdata->img_buff_ready_mutex,NULL); @@ -82,7 +80,7 @@ int InitializeData(ProgData *pdata, pthread_cond_init(&pdata->theora_lib_clean,NULL); pthread_cond_init(&pdata->vorbis_lib_clean,NULL); pdata->th_encoding_clean=pdata->v_encoding_clean=1; - pdata->list_selector=Paused=Aborted=pdata->avd=0; + Paused=Aborted=pdata->avd=0; pdata->sound_buffer=NULL; pdata->running=1; time_cond=&pdata->time_cond; diff --git a/recordmydesktop/src/poll_events.c b/recordmydesktop/src/poll_events.c index 4ddcfae..1532115 100644 --- a/recordmydesktop/src/poll_events.c +++ b/recordmydesktop/src/poll_events.c @@ -40,14 +40,12 @@ #include <rmdmacro.h> -void *PollEvents(ProgData *pdata){ +void InitEventsPolling(ProgData *pdata){ Window root_return, parent_return, *children; unsigned int i, - nchildren, - inserts=0; - XEvent event; + nchildren; XSelectInput (pdata->dpy,pdata->specs.root, SubstructureNotifyMask); @@ -78,7 +76,16 @@ void *PollEvents(ProgData *pdata){ } - while(pdata->running){ + +} + + +void EventLoop(ProgData *pdata){ + int inserts=0; + + XEvent event; + + while(XPending(pdata->dpy)){ XNextEvent(pdata->dpy,&event); if(event.type == KeyPress){ XKeyEvent *e=(XKeyEvent *)(&event); @@ -146,10 +153,7 @@ void *PollEvents(ProgData *pdata){ if((wgeom.x>=0)&&(wgeom.y>=0)&& (wgeom.width>0)&&(wgeom.height>0)){ - 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]); + inserts+=RectInsert(&pdata->rect_root,&wgeom); } } @@ -157,6 +161,7 @@ void *PollEvents(ProgData *pdata){ } - pthread_exit(&errno); + } + diff --git a/recordmydesktop/src/rmd_timer.c b/recordmydesktop/src/rmd_timer.c index a6c7568..2fb3f82 100644 --- a/recordmydesktop/src/rmd_timer.c +++ b/recordmydesktop/src/rmd_timer.c @@ -64,10 +64,12 @@ void *rmdTimer(ProgData *pdata){ if(capture_busy){ frames_lost++; } - pthread_mutex_lock(&time_mutex); - pthread_cond_broadcast(time_cond); - pthread_mutex_unlock(&time_mutex); } + + pthread_mutex_lock(&time_mutex); + pthread_cond_broadcast(time_cond); + pthread_mutex_unlock(&time_mutex); + if(secs_tw) sleep(secs_tw); diff --git a/recordmydesktop/src/rmdthreads.c b/recordmydesktop/src/rmdthreads.c index a1b8e53..b1716cf 100644 --- a/recordmydesktop/src/rmdthreads.c +++ b/recordmydesktop/src/rmdthreads.c @@ -48,7 +48,6 @@ void rmdThreads(ProgData *pdata){ sound_cache_t, flush_to_ogg_t, timer_t; - Window dummy_w; if(pdata->args.delay>0){ fprintf(stderr,"Will sleep for %d seconds now.\n",pdata->args.delay); @@ -56,10 +55,6 @@ void rmdThreads(ProgData *pdata){ } /*start threads*/ - pthread_create(&poll_events_t, - NULL, - (void *)PollEvents, - (void *)pdata); pthread_create(&image_capture_t, NULL, (void *)GetFrame, @@ -157,30 +152,6 @@ void rmdThreads(ProgData *pdata){ pthread_join(flush_to_ogg_t,NULL); fprintf(stderr,"."); - /* - * HACK ALERT - * This window (dummy_w) is created - * only so that we will receive a final - * create notify event. This is needed - * especially for the full_shots mode were - * there are no damage events and the - * poll_events thread might get stuck indefinatelly. - * XFlush is also needed in order to get the event - * before the current thread gets stuck at the join call. - * The second XFlush should be unnecesary. - */ - - dummy_w=XCreateSimpleWindow(pdata->dpy, - pdata->specs.root, - 1,1,1,1,0, - pdata->specs.bpixel, - pdata->specs.wpixel); - XFlush(pdata->dpy); - XDestroyWindow(pdata->dpy,dummy_w); - XFlush(pdata->dpy); - - pthread_join(poll_events_t,NULL); - //Now that we are done with recording we cancel the timer pdata->timer_alive=0; pthread_join(timer_t,NULL); |