From bbd22c084923065a74e8aae774eb0e4e611454cd Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 1 Jul 2020 19:42:17 -0700 Subject: *: more random cleanups mostly formatting nothing functionally different --- recordmydesktop/src/rmd.c | 2 +- recordmydesktop/src/rmd_cache_audio.c | 4 +- recordmydesktop/src/rmd_capture_sound.c | 33 +++++++-------- recordmydesktop/src/rmd_encode_cache.c | 16 +++---- recordmydesktop/src/rmd_encode_image_buffer.c | 1 - recordmydesktop/src/rmd_encode_sound_buffer.c | 10 ++--- recordmydesktop/src/rmd_flush_to_ogg.c | 2 +- recordmydesktop/src/rmd_get_frame.c | 60 ++++++++++++++------------- recordmydesktop/src/rmd_register_callbacks.c | 16 +++---- recordmydesktop/src/rmd_threads.c | 16 +++---- recordmydesktop/src/rmd_yuv_utils.c | 14 +++---- 11 files changed, 87 insertions(+), 87 deletions(-) diff --git a/recordmydesktop/src/rmd.c b/recordmydesktop/src/rmd.c index 7d3aecb..479a757 100644 --- a/recordmydesktop/src/rmd.c +++ b/recordmydesktop/src/rmd.c @@ -68,7 +68,7 @@ int main(int argc, char **argv){ if (pdata.args.rescue_path != NULL) exit(rmdRescue(pdata.args.rescue_path)); - if (XInitThreads()==0) { + if (XInitThreads() == 0) { fprintf(stderr, "Couldn't initialize thread support!\n"); exit(7); } diff --git a/recordmydesktop/src/rmd_cache_audio.c b/recordmydesktop/src/rmd_cache_audio.c index e3743be..5686d81 100644 --- a/recordmydesktop/src/rmd_cache_audio.c +++ b/recordmydesktop/src/rmd_cache_audio.c @@ -54,7 +54,7 @@ void *rmdCacheSoundBuffer(ProgData *pdata) { #ifdef HAVE_LIBJACK void *jackbuf = NULL; if (pdata->args.use_jack) - jackbuf=malloc(pdata->sound_framesize * pdata->jdata->buffersize); + jackbuf = malloc(pdata->sound_framesize * pdata->jdata->buffersize); #endif while (pdata->running) { @@ -72,7 +72,7 @@ void *rmdCacheSoundBuffer(ProgData *pdata) { buff = pdata->sound_buffer; if (buff) - pdata->sound_buffer = pdata->sound_buffer->next; + pdata->sound_buffer = buff->next; pthread_mutex_unlock(&pdata->sound_buffer_mutex); if (!pdata->running) diff --git a/recordmydesktop/src/rmd_capture_sound.c b/recordmydesktop/src/rmd_capture_sound.c index c1faa44..4ea26fb 100644 --- a/recordmydesktop/src/rmd_capture_sound.c +++ b/recordmydesktop/src/rmd_capture_sound.c @@ -43,14 +43,14 @@ void *rmdCaptureSound(ProgData *pdata) { #ifdef HAVE_LIBASOUND - int frames=pdata->periodsize; + int frames = pdata->periodsize; #endif //start capturing only after first frame is taken usleep(pdata->frametime); while (pdata->running) { - int sret=0; - SndBuffer *newbuf,*tmp; + int sret = 0; + SndBuffer *newbuf, *tmp; if (pdata->paused) { #ifdef HAVE_LIBASOUND @@ -65,7 +65,7 @@ void *rmdCaptureSound(ProgData *pdata) { pthread_mutex_lock(&pdata->pause_mutex); pthread_cond_wait(&pdata->pause_cond, &pdata->pause_mutex); pthread_mutex_unlock(&pdata->pause_mutex); - pdata->sound_handle= + pdata->sound_handle = rmdOpenDev(pdata->args.device, &pdata->args.channels, &pdata->args.frequency, @@ -75,10 +75,10 @@ void *rmdCaptureSound(ProgData *pdata) { NULL//let's hope that the device capabilities //didn't magically change ); - if (pdata->sound_handle==NULL) { - fprintf(stderr,"Couldn't reopen sound device.Exiting\n"); + if (pdata->sound_handle == NULL) { + fprintf(stderr, "Couldn't reopen sound device.Exiting\n"); pdata->running = FALSE; - errno=3; + errno = 3; pthread_exit(&errno); } } @@ -87,28 +87,27 @@ void *rmdCaptureSound(ProgData *pdata) { pthread_mutex_lock(&pdata->pause_mutex); pthread_cond_wait(&pdata->pause_cond, &pdata->pause_mutex); pthread_mutex_unlock(&pdata->pause_mutex); - pdata->sound_handle= + pdata->sound_handle = rmdOpenDev(pdata->args.device, pdata->args.channels, pdata->args.frequency); - if (pdata->sound_handle<0) { - fprintf(stderr,"Couldn't reopen sound device.Exiting\n"); + if (pdata->sound_handle < 0) { + fprintf(stderr,"Couldn't reopen sound device. Exiting\n"); pdata->running = FALSE; - errno=3; + errno = 3; pthread_exit(&errno); } #endif } //create new buffer - newbuf=(SndBuffer *)malloc(sizeof(SndBuffer)); + newbuf = (SndBuffer *)malloc(sizeof(SndBuffer)); #ifdef HAVE_LIBASOUND - newbuf->data=(signed char *)malloc(frames*pdata->sound_framesize); + newbuf->data = (signed char *)malloc(frames*pdata->sound_framesize); #else - newbuf->data=(signed char *)malloc(((pdata->args.buffsize<<1)* - pdata->args.channels)); + newbuf->data = (signed char *)malloc(((pdata->args.buffsize<<1) * pdata->args.channels)); #endif - newbuf->next=NULL; + newbuf->next = NULL; //read data into new buffer #ifdef HAVE_LIBASOUND @@ -126,7 +125,7 @@ void *rmdCaptureSound(ProgData *pdata) { snd_strerror(temp_sret)); snd_pcm_prepare(pdata->sound_handle); } else - sret+=temp_sret; + sret += temp_sret; } #else sret=0; diff --git a/recordmydesktop/src/rmd_encode_cache.c b/recordmydesktop/src/rmd_encode_cache.c index fdcb782..e363480 100644 --- a/recordmydesktop/src/rmd_encode_cache.c +++ b/recordmydesktop/src/rmd_encode_cache.c @@ -40,7 +40,7 @@ void rmdEncodeCache(ProgData *pdata){ - pthread_t flush_to_ogg_t, load_cache_t; + pthread_t flush_to_ogg_t, load_cache_t; fprintf(stderr,"STATE:ENCODING\n"); fprintf(stderr, "Encoding started!\nThis may take several minutes.\n" @@ -50,23 +50,23 @@ void rmdEncodeCache(ProgData *pdata){ "Please wait...\n"); pdata->running = TRUE; - rmdInitEncoder(pdata,pdata->enc_data,1); + rmdInitEncoder(pdata, pdata->enc_data, 1); //load encoding and flushing threads if (!pdata->args.nosound) { //before we start loading again //we need to free any left-overs - while (pdata->sound_buffer!=NULL) { + while (pdata->sound_buffer != NULL) { free(pdata->sound_buffer->data); - pdata->sound_buffer=pdata->sound_buffer->next; + pdata->sound_buffer = pdata->sound_buffer->next; } } - pthread_create(&flush_to_ogg_t,NULL,(void *)rmdFlushToOgg,(void *)pdata); + pthread_create(&flush_to_ogg_t, NULL, (void *)rmdFlushToOgg, (void *)pdata); //start loading image and audio - pthread_create(&load_cache_t,NULL,(void *)rmdLoadCache,(void *)pdata); + pthread_create(&load_cache_t, NULL, (void *)rmdLoadCache, (void *)pdata); //join and finish - pthread_join(load_cache_t,NULL); + pthread_join(load_cache_t, NULL); fprintf(stderr,"Encoding finished!\nWait a moment please...\n"); - pthread_join(flush_to_ogg_t,NULL); + pthread_join(flush_to_ogg_t, NULL); } diff --git a/recordmydesktop/src/rmd_encode_image_buffer.c b/recordmydesktop/src/rmd_encode_image_buffer.c index f7bd5a8..4a17882 100644 --- a/recordmydesktop/src/rmd_encode_image_buffer.c +++ b/recordmydesktop/src/rmd_encode_image_buffer.c @@ -51,7 +51,6 @@ void *rmdEncodeImageBuffer(ProgData *pdata) { pthread_mutex_unlock(&pdata->pause_mutex); pthread_mutex_lock(&pdata->yuv_mutex); - if (theora_encode_YUVin(&enc_data->m_th_st, &enc_data->yuv)) { fprintf(stderr,"Encoder not ready!\n"); pthread_mutex_unlock(&pdata->yuv_mutex); diff --git a/recordmydesktop/src/rmd_encode_sound_buffer.c b/recordmydesktop/src/rmd_encode_sound_buffer.c index 9537368..9e3af06 100644 --- a/recordmydesktop/src/rmd_encode_sound_buffer.c +++ b/recordmydesktop/src/rmd_encode_sound_buffer.c @@ -47,7 +47,7 @@ void *rmdEncodeSoundBuffer(ProgData *pdata) { #endif pdata->v_encoding_clean=0; - while ((pdata->running)) { + while (pdata->running) { float **vorbis_buffer; int count=0,i,j; SndBuffer *buff=NULL; @@ -64,9 +64,8 @@ void *rmdEncodeSoundBuffer(ProgData *pdata) { pthread_cond_wait(&pdata->sound_data_read, &pdata->sound_buffer_mutex); buff = pdata->sound_buffer; - if (buff) //advance the list - pdata->sound_buffer=pdata->sound_buffer->next; - + if (buff) + pdata->sound_buffer = buff->next; pthread_mutex_unlock(&pdata->sound_buffer_mutex); if (!pdata->running) @@ -125,11 +124,12 @@ void *rmdEncodeSoundBuffer(ProgData *pdata) { } pthread_mutex_unlock(&pdata->libogg_mutex); + /* this needs synchronizing */ pdata->avd -= pdata->periodtime; } - pdata->v_encoding_clean=1; pthread_mutex_lock(&pdata->vorbis_lib_mutex); + pdata->v_encoding_clean = 1; pthread_cond_signal(&pdata->vorbis_lib_clean); pthread_mutex_unlock(&pdata->vorbis_lib_mutex); pthread_exit(&errno); diff --git a/recordmydesktop/src/rmd_flush_to_ogg.c b/recordmydesktop/src/rmd_flush_to_ogg.c index 6cd79fe..47abbca 100644 --- a/recordmydesktop/src/rmd_flush_to_ogg.c +++ b/recordmydesktop/src/rmd_flush_to_ogg.c @@ -143,7 +143,7 @@ void *rmdFlushToOgg(ProgData *pdata) { while (!pdata->v_encoding_clean) pthread_cond_wait(&pdata->vorbis_lib_clean, &pdata->vorbis_lib_mutex); pthread_mutex_unlock(&pdata->vorbis_lib_mutex); - rmdSyncEncodeSoundBuffer(pdata,NULL); + rmdSyncEncodeSoundBuffer(pdata, NULL); } } } diff --git a/recordmydesktop/src/rmd_get_frame.c b/recordmydesktop/src/rmd_get_frame.c index 8a8ab8c..c2d109d 100644 --- a/recordmydesktop/src/rmd_get_frame.c +++ b/recordmydesktop/src/rmd_get_frame.c @@ -83,7 +83,7 @@ static void clip_dummy_pointer_area(XRectangle *area, XRectangle *clip, XRectang __depth__) { \ \ register u_int##__depth__##_t *datapi = \ - ((u_int##__depth__##_t *)data) + y_tm *buffer_width + x_tm; \ + ((u_int##__depth__##_t *)data) + y_tm * buffer_width + x_tm; \ \ for(int k = 0; k < height_tm; k++) { \ for(int i = 0; i < width_tm; i++) { \ @@ -269,18 +269,17 @@ static void rmdBlocksFromList( RectArea **root, } void *rmdGetFrame(ProgData *pdata) { - int i=0, - blocknum_x=pdata->enc_data->yuv.y_width/Y_UNIT_WIDTH, - blocknum_y=pdata->enc_data->yuv.y_height/Y_UNIT_WIDTH; + int 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; - XRectangle mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; + XRectangle mouse_pos_abs, mouse_pos_rel, mouse_pos_temp; BRWindow temp_brwin; Window root_ret, child_ret; //Frame - XFixesCursorImage *xcim=NULL; - XImage *image=NULL,*image_back=NULL; //the image that holds + XFixesCursorImage *xcim = NULL; + XImage *image = NULL, *image_back = NULL; //the image that holds //the current full screenshot - XShmSegmentInfo shminfo,shminfo_back; //info structure for the image above. - int init_img1=0,init_img2=0, img_sel,d_buff; + XShmSegmentInfo shminfo, shminfo_back; //info structure for the image above. + int init_img1 = 0, init_img2 = 0, img_sel, d_buff; img_sel=d_buff=pdata->args.full_shots; @@ -293,7 +292,7 @@ void *rmdGetFrame(ProgData *pdata) { pdata->args.filename); } } else { - rmdPurgeCache(pdata->cache_data,!pdata->args.nosound); + rmdPurgeCache(pdata->cache_data, !pdata->args.nosound); } exit(init_img1); @@ -360,13 +359,13 @@ void *rmdGetFrame(ProgData *pdata) { //switch back and front buffers (full_shots only) if (d_buff) - img_sel=(img_sel)?0:1; + img_sel = img_sel ? 0 : 1; rmdBRWinCpy(&temp_brwin, &pdata->brwin); if ( pdata->args.xfixes_cursor || - pdata->args.have_dummy_cursor|| + pdata->args.have_dummy_cursor || pdata->args.follow_mouse) { @@ -375,30 +374,33 @@ void *rmdGetFrame(ProgData *pdata) { // * Update to new position // * Mark new position as dirty with rmdRectInsert() if ( !pdata->args.full_shots && - mouse_pos_temp.x >=0 && - mouse_pos_temp.y >=0 && + mouse_pos_temp.x >= 0 && + mouse_pos_temp.y >= 0 && mouse_pos_temp.width > 0 && mouse_pos_temp.height > 0) { - rmdRectInsert(&pdata->rect_root,&mouse_pos_temp); + rmdRectInsert(&pdata->rect_root, &mouse_pos_temp); } if (pdata->args.xfixes_cursor) { - xcim=XFixesGetCursorImage(pdata->dpy); - mouse_pos_abs.x=xcim->x-xcim->xhot; - mouse_pos_abs.y=xcim->y-xcim->yhot; - mouse_pos_abs.width=xcim->width; - mouse_pos_abs.height=xcim->height; + xcim = XFixesGetCursorImage(pdata->dpy); + mouse_pos_abs.x = xcim->x - xcim->xhot; + mouse_pos_abs.y = xcim->y - xcim->yhot; + mouse_pos_abs.width = xcim->width; + mouse_pos_abs.height = xcim->height; } else { - XQueryPointer(pdata->dpy, - pdata->specs.root, - &root_ret,&child_ret, - (int *)&mouse_pos_abs.x,(int *)&mouse_pos_abs.y, - (int *)&mouse_pos_rel.x,(int *)&mouse_pos_rel.y,&msk_ret); + XQueryPointer( pdata->dpy, + pdata->specs.root, + &root_ret,&child_ret, + (int *)&mouse_pos_abs.x, + (int *)&mouse_pos_abs.y, + (int *)&mouse_pos_rel.x, + (int *)&mouse_pos_rel.y, + &msk_ret); } clip_dummy_pointer_area(&mouse_pos_abs, &temp_brwin.rrect, &mouse_pos_temp); - if ( mouse_pos_temp.x >=0 && - mouse_pos_temp.y >=0 && + if ( mouse_pos_temp.x >= 0 && + mouse_pos_temp.y >= 0 && mouse_pos_temp.width > 0 && mouse_pos_temp.height > 0) { @@ -487,7 +489,7 @@ void *rmdGetFrame(ProgData *pdata) { temp_brwin.rrect.height); pthread_mutex_lock(&pdata->yuv_mutex); - for(i = 0;i < blocknum_x * blocknum_y; i++) + for(int i = 0; i < blocknum_x * blocknum_y; i++) yblocks[i] = ublocks[i] = vblocks[i] = 0; rmdUpdateYuvBuffer( &pdata->enc_data->yuv, @@ -570,7 +572,7 @@ void *rmdGetFrame(ProgData *pdata) { if (pdata->args.xfixes_cursor) { XFree(xcim); - xcim=NULL; + xcim = NULL; } } diff --git a/recordmydesktop/src/rmd_register_callbacks.c b/recordmydesktop/src/rmd_register_callbacks.c index 241f160..33e04dd 100644 --- a/recordmydesktop/src/rmd_register_callbacks.c +++ b/recordmydesktop/src/rmd_register_callbacks.c @@ -34,10 +34,10 @@ // 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_paused = NULL; -static int *pdata_aborted = NULL; -static int *pdata_pause_state_changed = 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 rmdSetPaused(int signum) { @@ -63,10 +63,10 @@ void rmdRegisterCallbacks(ProgData *pdata) { struct sigaction end_act; // 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; + 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); diff --git a/recordmydesktop/src/rmd_threads.c b/recordmydesktop/src/rmd_threads.c index 91823b4..b7e13f3 100644 --- a/recordmydesktop/src/rmd_threads.c +++ b/recordmydesktop/src/rmd_threads.c @@ -55,7 +55,7 @@ void rmdThreads(ProgData *pdata) { flush_to_ogg_t, timer_t; - if (pdata->args.delay>0) { + if (pdata->args.delay > 0) { fprintf(stderr, "Will sleep for %d seconds now.\n", pdata->args.delay); sleep(pdata->args.delay); } @@ -96,14 +96,14 @@ void rmdThreads(ProgData *pdata) { (void *)pdata); } - if(pdata->args.encOnTheFly) + if (pdata->args.encOnTheFly) pthread_create( &flush_to_ogg_t, NULL, (void *)rmdFlushToOgg, (void *)pdata); rmdRegisterCallbacks(pdata); - pdata->timer_alive=1; + pdata->timer_alive = 1; pthread_create( &timer_t, NULL, (void *)rmdTimer, @@ -112,11 +112,11 @@ void rmdThreads(ProgData *pdata) { #ifdef HAVE_LIBJACK if (pdata->args.use_jack) - pdata->jdata->capture_started=1; + pdata->jdata->capture_started = 1; #endif //wait all threads to finish - pthread_join(image_capture_t,NULL); + pthread_join(image_capture_t, NULL); fprintf(stderr,"Shutting down."); //if no damage events have been received the thread will get stuck pthread_mutex_lock(&pdata->img_buff_ready_mutex); @@ -129,9 +129,9 @@ void rmdThreads(ProgData *pdata) { } if (pdata->args.encOnTheFly) - pthread_join(image_encode_t,NULL); + pthread_join(image_encode_t, NULL); else - pthread_join(image_cache_t,NULL); + pthread_join(image_cache_t, NULL); fprintf(stderr,"."); if (!pdata->args.nosound) { @@ -162,6 +162,6 @@ void rmdThreads(ProgData *pdata) { fprintf(stderr,"."); //Now that we are done with recording we cancel the timer - pdata->timer_alive=0; + pdata->timer_alive = 0; pthread_join(timer_t,NULL); } diff --git a/recordmydesktop/src/rmd_yuv_utils.c b/recordmydesktop/src/rmd_yuv_utils.c index d406254..c4bc2e8 100644 --- a/recordmydesktop/src/rmd_yuv_utils.c +++ b/recordmydesktop/src/rmd_yuv_utils.c @@ -157,12 +157,12 @@ static inline int blocknum(int xv, int yv, int widthv, int blocksize) t3 = *datapi_next; \ t4 = *(datapi_next + 1); \ \ - t_val= ((((t1 & 0x00ff0000) +(t2 & 0x00ff0000) + \ - (t3 & 0x00ff0000)+ (t4 & 0x00ff0000)) / 4) & 0x00ff0000) + \ + t_val = ((((t1 & 0x00ff0000) + (t2 & 0x00ff0000) + \ + (t3 & 0x00ff0000) + (t4 & 0x00ff0000)) / 4) & 0x00ff0000) + \ ((((t1 & 0x0000ff00) + (t2 & 0x0000ff00) + \ - (t3 & 0x0000ff00)+ (t4 & 0x0000ff00)) / 4) & 0x0000ff00) + \ + (t3 & 0x0000ff00) + (t4 & 0x0000ff00)) / 4) & 0x0000ff00) + \ ((((t1 & 0x000000ff) + (t2 & 0x000000ff) + \ - (t3 & 0x000000ff)+ (t4 & 0x000000ff)) / 4) & 0x000000ff); \ + (t3 & 0x000000ff) + (t4 & 0x000000ff)) / 4) & 0x000000ff); \ } #define UPDATE_A_UV_PIXEL( yuv_U, \ @@ -174,7 +174,7 @@ static inline int blocknum(int xv, int yv, int widthv, int blocksize) sampling, \ __depth__) \ \ - if(sampling == __PXL_AVERAGE) { \ + if (sampling == __PXL_AVERAGE) { \ CALC_TVAL_AVG_##__depth__(t_val, datapi, datapi_next) \ } else \ t_val = *(datapi); \ @@ -297,8 +297,8 @@ static inline int blocknum(int xv, int yv, int widthv, int blocksize) datapi_back_next = datapi_back + width_tm; \ \ for (int k = 0; k < height_tm; k += 2) { \ - for(int i = 0; i < width_tm; i += 2) { \ - if( ( (*datapi != *datapi_back) || \ + for (int i = 0; i < width_tm; i += 2) { \ + if ( ( (*datapi != *datapi_back) || \ (*(datapi + 1) != *(datapi_back + 1)) || \ (*datapi_next != *datapi_back_next) || \ (*(datapi_next + 1) != *(datapi_back_next + 1)))) { \ -- cgit v1.2.3