summaryrefslogtreecommitdiff
path: root/recordmydesktop/src
diff options
context:
space:
mode:
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r--recordmydesktop/src/get_frame.c26
-rw-r--r--recordmydesktop/src/initialize_data.c6
-rw-r--r--recordmydesktop/src/poll_events.c25
-rw-r--r--recordmydesktop/src/rmd_timer.c8
-rw-r--r--recordmydesktop/src/rmdthreads.c29
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);
© All Rights Reserved