diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-12-05 17:50:09 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-12-05 17:50:09 +0000 |
commit | b97fd0333d1faf11675c2ec522979ee1ba81a524 (patch) | |
tree | 72cafec7303f18953191997bfdbf8b14787965de | |
parent | 80819a827a4bc44ca9c247f216d6a0c9bba5f584 (diff) |
moved pause cond signaling to rmd_timer thread (was in signal handler)
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@458 f606c939-3180-4ac9-a4b8-4b8779d57d0a
-rw-r--r-- | recordmydesktop/include/recordmydesktop.h | 2 | ||||
-rw-r--r-- | recordmydesktop/src/initialize_data.c | 1 | ||||
-rw-r--r-- | recordmydesktop/src/register_callbacks.c | 24 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_timer.c | 27 |
4 files changed, 31 insertions, 23 deletions
diff --git a/recordmydesktop/include/recordmydesktop.h b/recordmydesktop/include/recordmydesktop.h index 0064fd7..298384f 100644 --- a/recordmydesktop/include/recordmydesktop.h +++ b/recordmydesktop/include/recordmydesktop.h @@ -50,7 +50,7 @@ u_int32_t *yblocks, /**Globals*/ //I've read somewhere that I'll go to hell for using globals... -int Paused,*Running,Aborted; +int Paused,*Running,Aborted,PauseStateChanged; pthread_cond_t *time_cond,*pause_cond; pthread_mutex_t pause_mutex,time_mutex; unsigned char Yr[256],Yg[256],Yb[256], diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c index 6e363f6..a3566ba 100644 --- a/recordmydesktop/src/initialize_data.c +++ b/recordmydesktop/src/initialize_data.c @@ -88,6 +88,7 @@ int InitializeData(ProgData *pdata, time_cond=&pdata->time_cond; pause_cond=&pdata->pause_cond; Running=&pdata->running; + PauseStateChanged=0; if(!pdata->args.nosound){ if(!pdata->args.use_jack){ diff --git a/recordmydesktop/src/register_callbacks.c b/recordmydesktop/src/register_callbacks.c index a0d2552..c5d22d1 100644 --- a/recordmydesktop/src/register_callbacks.c +++ b/recordmydesktop/src/register_callbacks.c @@ -28,25 +28,9 @@ #include <recordmydesktop.h> void SetPaused(int signum){ - if(!Paused){ - Paused=1; - fprintf(stderr,"STATE:PAUSED\n"); - } - else{ - Paused=0; - fprintf(stderr,"STATE:RECORDING\n"); -/*FIXME */ -//This is not safe. -//cond_var signaling must move away from signal handlers -//alltogether (JackCapture, SetExpired, SetPaused). -//Better would be a set of pipes for each of these. -//The callback should write on the pipe and the main thread -//should perform a select over the fd's, signaling afterwards the -//appropriate cond_var. - pthread_mutex_lock(&pause_mutex); - pthread_cond_broadcast(pause_cond); - pthread_mutex_unlock(&pause_mutex); - } + + PauseStateChanged=1; + } @@ -60,7 +44,7 @@ void SetRunning(int signum){ void RegisterCallbacks(ProgArgs *args){ struct sigaction pause_act,end_act; - + pause_act.sa_handler=SetPaused; end_act.sa_handler=SetRunning; sigfillset(&(pause_act.sa_mask)); diff --git a/recordmydesktop/src/rmd_timer.c b/recordmydesktop/src/rmd_timer.c index ff1fc9b..da26f18 100644 --- a/recordmydesktop/src/rmd_timer.c +++ b/recordmydesktop/src/rmd_timer.c @@ -35,10 +35,30 @@ void *rmdTimer(ProgData *pdata){ - + + long unsigned int secs_tw=1/pdata->args.fps; + long unsigned int usecs_tw=(1000000)/pdata->args.fps- + secs_tw*1000000; while(pdata->timer_alive){ + if(PauseStateChanged){ + PauseStateChanged=0; + + if(!Paused){ + Paused=1; + fprintf(stderr,"STATE:PAUSED\n"); + } + else{ + Paused=0; + fprintf(stderr,"STATE:RECORDING\n"); + pthread_mutex_lock(&pause_mutex); + pthread_cond_broadcast(pause_cond); + pthread_mutex_unlock(&pause_mutex); + } + + } + if(!Paused){ frames_total++; if(capture_busy){ @@ -48,7 +68,10 @@ void *rmdTimer(ProgData *pdata){ pthread_cond_broadcast(time_cond); pthread_mutex_unlock(&time_mutex); } - usleep(pdata->frametime); + + if(secs_tw) + sleep(secs_tw); + usleep(usecs_tw); } |