summaryrefslogtreecommitdiff
path: root/recordmydesktop/src
diff options
context:
space:
mode:
authorenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-13 12:37:57 +0000
committerenselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a>2008-09-13 12:37:57 +0000
commit28697c059df1f6b276a490123611c439996085c8 (patch)
treeb6740929c6479baa794083434beb6fca8eb02a4d /recordmydesktop/src
parent3f5d20573bd0aac953bd2db2d72997ff44365caf (diff)
include/recordmydesktop.h: Remove the globals Paused, Aborted and
PauseStateChanged. include/rmdtypes.h: Add the previous globals as members in ProgData. src/rmd_jack.c src/get_frame.c src/rmd_timer.c src/rmd_rescue.c src/cache_audio.c src/cache_frame.c src/capture_sound.c src/initialize_data.c src/recordmydesktop.c src/register_callbacks.c src/encode_image_buffer.c src/encode_sound_buffer.c: Adapt. git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@529 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r--recordmydesktop/src/cache_audio.c2
-rw-r--r--recordmydesktop/src/cache_frame.c2
-rw-r--r--recordmydesktop/src/capture_sound.c2
-rw-r--r--recordmydesktop/src/encode_image_buffer.c2
-rw-r--r--recordmydesktop/src/encode_sound_buffer.c2
-rw-r--r--recordmydesktop/src/get_frame.c2
-rw-r--r--recordmydesktop/src/initialize_data.c6
-rw-r--r--recordmydesktop/src/recordmydesktop.c4
-rw-r--r--recordmydesktop/src/register_callbacks.c28
-rw-r--r--recordmydesktop/src/rmd_jack.c2
-rw-r--r--recordmydesktop/src/rmd_rescue.c3
-rw-r--r--recordmydesktop/src/rmd_timer.c12
12 files changed, 37 insertions, 30 deletions
diff --git a/recordmydesktop/src/cache_audio.c b/recordmydesktop/src/cache_audio.c
index 387d536..ac21615 100644
--- a/recordmydesktop/src/cache_audio.c
+++ b/recordmydesktop/src/cache_audio.c
@@ -42,7 +42,7 @@ void *CacheSoundBuffer(ProgData *pdata){
while((pdata->running)){
SndBuffer *buff=NULL;
- if(Paused){
+ if (pdata->paused) {
pthread_mutex_lock(&pause_mutex);
pthread_cond_wait(&pdata->pause_cond,&pause_mutex);
pthread_mutex_unlock(&pause_mutex);
diff --git a/recordmydesktop/src/cache_frame.c b/recordmydesktop/src/cache_frame.c
index f7f1f75..79e955f 100644
--- a/recordmydesktop/src/cache_frame.c
+++ b/recordmydesktop/src/cache_frame.c
@@ -115,7 +115,7 @@ void *CacheImageBuffer(ProgData *pdata){
pthread_mutex_unlock(&pdata->img_buff_ready_mutex);
pdata->th_enc_thread_waiting=0;
- if(Paused){
+ if (pdata->paused) {
pthread_mutex_lock(&pause_mutex);
pthread_cond_wait(&pdata->pause_cond,&pause_mutex);
pthread_mutex_unlock(&pause_mutex);
diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c
index 1a87429..f9fb295 100644
--- a/recordmydesktop/src/capture_sound.c
+++ b/recordmydesktop/src/capture_sound.c
@@ -39,7 +39,7 @@ void *CaptureSound(ProgData *pdata){
while(pdata->running){
int sret=0;
SndBuffer *newbuf,*tmp;
- if(Paused){
+ if (pdata->paused) {
#ifdef HAVE_LIBASOUND
if(!pdata->hard_pause){
snd_pcm_pause(pdata->sound_handle,1);
diff --git a/recordmydesktop/src/encode_image_buffer.c b/recordmydesktop/src/encode_image_buffer.c
index 7b21263..94cd5d2 100644
--- a/recordmydesktop/src/encode_image_buffer.c
+++ b/recordmydesktop/src/encode_image_buffer.c
@@ -38,7 +38,7 @@ void *EncodeImageBuffer(ProgData *pdata){
pthread_mutex_unlock(&pdata->img_buff_ready_mutex);
pdata->th_enc_thread_waiting=0;
encoder_busy=1;
- if(Paused){
+ if (pdata->paused) {
pthread_mutex_lock(&pause_mutex);
pthread_cond_wait(&pdata->pause_cond,&pause_mutex);
pthread_mutex_unlock(&pause_mutex);
diff --git a/recordmydesktop/src/encode_sound_buffer.c b/recordmydesktop/src/encode_sound_buffer.c
index c58d926..47b8211 100644
--- a/recordmydesktop/src/encode_sound_buffer.c
+++ b/recordmydesktop/src/encode_sound_buffer.c
@@ -42,7 +42,7 @@ void *EncodeSoundBuffer(ProgData *pdata){
int count=0,i,j;
SndBuffer *buff=NULL;
- if(Paused){
+ if (pdata->paused) {
pthread_mutex_lock(&pause_mutex);
pthread_cond_wait(&pdata->pause_cond,&pause_mutex);
pthread_mutex_unlock(&pause_mutex);
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c
index 9f16a4b..d4dee67 100644
--- a/recordmydesktop/src/get_frame.c
+++ b/recordmydesktop/src/get_frame.c
@@ -393,7 +393,7 @@ void *GetFrame(ProgData *pdata){
pthread_mutex_lock(&time_mutex);
pthread_cond_wait(&pdata->time_cond,&time_mutex);
pthread_mutex_unlock(&time_mutex);
- if(Paused){
+ if (pdata->paused) {
//this is necessary since event loop processes
//the shortcuts which will unpause the program
EventLoop(pdata);
diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c
index df30292..a10205e 100644
--- a/recordmydesktop/src/initialize_data.c
+++ b/recordmydesktop/src/initialize_data.c
@@ -107,12 +107,14 @@ 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;
- Paused=Aborted=pdata->avd=0;
+ pdata->avd=0;
pdata->sound_buffer=NULL;
pdata->running=1;
+ pdata->paused=0;
+ pdata->aborted=0;
+ pdata->pause_state_changed=0;
time_cond=&pdata->time_cond;
pause_cond=&pdata->pause_cond;
- PauseStateChanged=0;
if(!pdata->args.nosound){
if(!pdata->args.use_jack){
diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c
index e2b394e..5a04bbc 100644
--- a/recordmydesktop/src/recordmydesktop.c
+++ b/recordmydesktop/src/recordmydesktop.c
@@ -151,7 +151,7 @@ int main(int argc,char **argv){
//encode and then cleanup cache
if(!pdata.args.encOnTheFly && !pdata.args.no_encode){
- if(!Aborted){
+ if (!pdata.aborted) {
EncodeCache(&pdata);
}
fprintf(stderr,"Cleanning up cache...\n");
@@ -162,7 +162,7 @@ int main(int argc,char **argv){
}
- if(Aborted && pdata.args.encOnTheFly){
+ if (pdata.aborted && pdata.args.encOnTheFly) {
if(remove(pdata.args.filename)){
perror("Error while removing file:\n");
return 1;
diff --git a/recordmydesktop/src/register_callbacks.c b/recordmydesktop/src/register_callbacks.c
index c16f7b1..3371673 100644
--- a/recordmydesktop/src/register_callbacks.c
+++ b/recordmydesktop/src/register_callbacks.c
@@ -32,36 +32,40 @@
// There seem to be no way of passing user data to the signal handler,
// so hack around not being able to pass ProgData to them
-static int *pdata_running = NULL;
+static int *pdata_running = NULL;
+static int *pdata_paused = NULL;
+static int *pdata_aborted = NULL;
+static int *pdata_pause_state_changed = NULL;
static void SetPaused(int signum) {
- PauseStateChanged = 1;
+ *pdata_pause_state_changed = 1;
}
static void SetRunning(int signum) {
-
- if (!Paused){
- if (pdata_running != NULL) {
- *pdata_running = 0;
- }
+ if (!*pdata_paused) {
+
+ *pdata_running = 0;
if (signum == SIGABRT) {
- Aborted = 1;
+ *pdata_aborted = 1;
}
}
}
-void RegisterCallbacks(ProgData *pata) {
+void RegisterCallbacks(ProgData *pdata) {
struct sigaction pause_act;
struct sigaction end_act;
- // Is there some way to pass pata to the signal handlers?
- pdata_running = &pata->running;
-
+ // Is there some way to pass pdata to the signal handlers?
+ pdata_running = &pdata->running;
+ pdata_paused = &pdata->paused;
+ pdata_aborted = &pdata->aborted;
+ pdata_pause_state_changed = &pdata->pause_state_changed;
+
// Setup pause_act
sigfillset(&pause_act.sa_mask);
pause_act.sa_flags = SA_RESTART;
diff --git a/recordmydesktop/src/rmd_jack.c b/recordmydesktop/src/rmd_jack.c
index 1718c09..e15042e 100644
--- a/recordmydesktop/src/rmd_jack.c
+++ b/recordmydesktop/src/rmd_jack.c
@@ -91,7 +91,7 @@ static int JackCapture(jack_nframes_t nframes,void *jdata_t) {
int i=0;
JackData *jdata=(JackData *)jdata_t;
- if (!jdata->pdata->running || Paused || !jdata->capture_started) {
+ if (!jdata->pdata->running || jdata->pdata->paused || !jdata->capture_started) {
return 0;
}
diff --git a/recordmydesktop/src/rmd_rescue.c b/recordmydesktop/src/rmd_rescue.c
index f49cd1b..fbba518 100644
--- a/recordmydesktop/src/rmd_rescue.c
+++ b/recordmydesktop/src/rmd_rescue.c
@@ -108,9 +108,10 @@ int rmdRescue(const char *path){
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;
- Aborted=pdata.avd=0;
+ pdata.avd=0;
pdata.sound_buffer=NULL;
pdata.running=1;
+ pdata.aborted=0;
RegisterCallbacks(&pdata);
fprintf(stderr,"Restoring %s!!!\n",path);
diff --git a/recordmydesktop/src/rmd_timer.c b/recordmydesktop/src/rmd_timer.c
index 5aac3bd..2430156 100644
--- a/recordmydesktop/src/rmd_timer.c
+++ b/recordmydesktop/src/rmd_timer.c
@@ -43,15 +43,15 @@ void *rmdTimer(ProgData *pdata){
while(pdata->timer_alive){
- if(PauseStateChanged){
- PauseStateChanged=0;
+ if (pdata->pause_state_changed) {
+ pdata->pause_state_changed = 0;
- if(!Paused){
- Paused=1;
+ if (!pdata->paused) {
+ pdata->paused = 1;
fprintf(stderr,"STATE:PAUSED\n");fflush(stderr);
}
else{
- Paused=0;
+ pdata->paused = 0;
fprintf(stderr,"STATE:RECORDING\n");fflush(stderr);
pthread_mutex_lock(&pause_mutex);
pthread_cond_broadcast(pause_cond);
@@ -60,7 +60,7 @@ void *rmdTimer(ProgData *pdata){
}
- if(!Paused){
+ if (!pdata->paused) {
frames_total++;
if(capture_busy){
frames_lost++;
© All Rights Reserved