diff options
author | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-03-13 19:58:05 +0000 |
---|---|---|
committer | iovar <iovar@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2007-03-13 19:58:05 +0000 |
commit | 25a6bc31f431f59147739876f1d9a96340b65fb2 (patch) | |
tree | 818ca96f721cbc42da2ff9f8b18afde4c40fe830 /recordmydesktop/src | |
parent | ee0b215b94e92a1592a9f7c817c8dd0acefdce83 (diff) |
fixed xdamage with xshm and
removed anything related to conditional shared memory usage.
Added GetZPixmapShm.Cleaned up pdata stuct from unneeded members.
Removed argumednts related to conditional shared (--no-cond-shared,
--shared threshold).Changed default for Shm and --with-shared is now
--no-shared.
Also, dummy cursor has been shaped up a bit.
Version changed to 0.3.4-cvs.
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@293 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop/src')
-rw-r--r-- | recordmydesktop/src/get_frame.c | 52 | ||||
-rw-r--r-- | recordmydesktop/src/getzpixmap.c | 42 | ||||
-rw-r--r-- | recordmydesktop/src/init_encoder.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/initialize_data.c | 46 | ||||
-rw-r--r-- | recordmydesktop/src/load_cache.c | 2 | ||||
-rw-r--r-- | recordmydesktop/src/make_dummy_pointer.c | 30 | ||||
-rw-r--r-- | recordmydesktop/src/parseargs.c | 39 | ||||
-rw-r--r-- | recordmydesktop/src/queryextensions.c | 18 | ||||
-rw-r--r-- | recordmydesktop/src/recordmydesktop.c | 6 | ||||
-rw-r--r-- | recordmydesktop/src/update_image.c | 14 |
10 files changed, 125 insertions, 126 deletions
diff --git a/recordmydesktop/src/get_frame.c b/recordmydesktop/src/get_frame.c index 87e71aa..635a868 100644 --- a/recordmydesktop/src/get_frame.c +++ b/recordmydesktop/src/get_frame.c @@ -29,12 +29,9 @@ void *GetFrame(ProgData *pdata){ int tlist_sel=0; - unsigned char *dtap=NULL; //pointer switching among shared memory and - //normal buffer uint msk_ret; WGeometry mouse_pos_abs,mouse_pos_rel,mouse_pos_temp; Window root_ret,child_ret; - int pixel_total=pdata->brwin.rgeom.width*pdata->brwin.rgeom.height; XFixesCursorImage *xcim=NULL; mouse_pos_abs.x=mouse_pos_temp.x=0; @@ -64,21 +61,6 @@ void *GetFrame(ProgData *pdata){ pdata->list_selector=((pdata->list_selector+1)%2); pthread_mutex_lock(&pdata->list_mutex[tlist_sel]); } - //here we measure the list and decide which way we will go - if(!pdata->args.nocondshared){ - int level=0; - RectArea *temp=pdata->rect_root[tlist_sel]; - - if(temp!=NULL){ - do{ - level+=temp->geom.width*temp->geom.height; - temp=temp->next; - }while(temp!=NULL); - level*=100; - level/=pixel_total; - pdata->args.noshared=(level<pdata->args.shared_thres); - } - } if(pdata->args.xfixes_cursor){ //xfixes pointer sequence //update previous_position @@ -118,10 +100,6 @@ void *GetFrame(ProgData *pdata){ &mouse_pos_abs.x,&mouse_pos_abs.y, &mouse_pos_rel.x,&mouse_pos_rel.y,&msk_ret); } - if(!pdata->args.noshared) - XShmGetImage(pdata->dpy,pdata->specs.root,pdata->shimage, - (pdata->brwin.rgeom.x), - (pdata->brwin.rgeom.y),AllPlanes); if(!pdata->args.full_shots) UpdateImage(pdata->dpy, &pdata->enc_data->yuv, @@ -130,16 +108,16 @@ void *GetFrame(ProgData *pdata){ &pdata->rect_root[tlist_sel], &pdata->brwin, pdata->enc_data, - ((pdata->args.noshared)? - (pdata->datatemp): - (pdata->shimage->data)), + pdata->image->data, pdata->args.noshared, + &pdata->shminfo, + pdata->shm_opcode, pdata->args.no_quick_subsample); else{ - - dtap=(((pdata->args.nocondshared)&&(!pdata->args.noshared))? - ((unsigned char*)pdata->shimage->data): - ((unsigned char*)pdata->image->data)); + if(!pdata->args.noshared) + XShmGetImage(pdata->dpy,pdata->specs.root,pdata->image, + (pdata->brwin.rgeom.x), + (pdata->brwin.rgeom.y),AllPlanes); if(pdata->args.noshared){ GetZPixmap( pdata->dpy, pdata->specs.root, @@ -150,14 +128,14 @@ void *GetFrame(ProgData *pdata){ pdata->brwin.rgeom.height); } pthread_mutex_lock(&pdata->yuv_mutex); - UPDATE_YUV_BUFFER((&pdata->enc_data->yuv),dtap, - (pdata->enc_data->x_offset), - (pdata->enc_data->y_offset), - (pdata->brwin.rgeom.width), - (pdata->brwin.rgeom.height), - pdata->args.noshared, - pdata->args.no_quick_subsample, - pdata->specs.depth); + UPDATE_YUV_BUFFER((&pdata->enc_data->yuv), + ((unsigned char*)pdata->image->data), + (pdata->enc_data->x_offset), + (pdata->enc_data->y_offset), + (pdata->brwin.rgeom.width), + (pdata->brwin.rgeom.height), + pdata->args.no_quick_subsample, + pdata->specs.depth); pthread_mutex_unlock(&pdata->yuv_mutex); } if(pdata->args.xfixes_cursor){ diff --git a/recordmydesktop/src/getzpixmap.c b/recordmydesktop/src/getzpixmap.c index 6deaf15..38ef42d 100644 --- a/recordmydesktop/src/getzpixmap.c +++ b/recordmydesktop/src/getzpixmap.c @@ -59,3 +59,45 @@ int GetZPixmap(Display *dpy, return 0; } +int GetZPixmapSHM(Display *dpy, + Window root, + XShmSegmentInfo *shminfo, + int shm_opcode, + char *data, + int x, + int y, + int width, + int height){ + xShmGetImageReply reply; + xShmGetImageReq *request=NULL; + long nbytes; + + LockDisplay(dpy); + GetReq(ShmGetImage,request); + + request->reqType=shm_opcode; + request->shmReqType=X_ShmGetImage; + request->shmseg=shminfo->shmseg; + + request->drawable=root; + request->x=x; + request->y=y; + request->width=width; + request->height=height; + request->planeMask=AllPlanes; + request->format=ZPixmap; + request->offset=data-shminfo->shmaddr; + + if((!_XReply(dpy,(xReply *)&reply,0,xFalse))||(!reply.length)){ + UnlockDisplay(dpy); + SyncHandle(); + return 1; + } + + nbytes=(long)reply.length << 2; + _XReadPad(dpy,data,nbytes); + UnlockDisplay(dpy); + SyncHandle(); + + return 0; +} diff --git a/recordmydesktop/src/init_encoder.c b/recordmydesktop/src/init_encoder.c index 34775fd..2876c1c 100644 --- a/recordmydesktop/src/init_encoder.c +++ b/recordmydesktop/src/init_encoder.c @@ -95,7 +95,7 @@ void InitEncoder(ProgData *pdata,EncData *enc_data_t,int buffer_ready){ enc_data_t->m_th_inf.pixelformat=OC_PF_420; enc_data_t->m_th_inf.target_bitrate=(pdata)->args.v_bitrate; enc_data_t->m_th_inf.quality=(pdata)->args.v_quality; - enc_data_t->m_th_inf.dropframes_p=(pdata)->args.dropframes; + enc_data_t->m_th_inf.dropframes_p=0; enc_data_t->m_th_inf.quick_p=1; enc_data_t->m_th_inf.keyframe_auto_p=1; enc_data_t->m_th_inf.keyframe_frequency=64; diff --git a/recordmydesktop/src/initialize_data.c b/recordmydesktop/src/initialize_data.c index 806ade5..ede8855 100644 --- a/recordmydesktop/src/initialize_data.c +++ b/recordmydesktop/src/initialize_data.c @@ -47,9 +47,6 @@ int InitializeData(ProgData *pdata, EncData *enc_data, CacheData *cache_data){ int i; - unsigned char *dtap=NULL; //pointer switching among shared memory and - //normal buffer - //these are globals, look for them at the header frames_total=frames_lost=encoder_busy=capture_busy=0; @@ -63,10 +60,8 @@ int InitializeData(ProgData *pdata, } if((pdata->args.noshared)) - pdata->datamain=(char *)malloc(pdata->brwin.nbytes); + pdata->pxl_data=(char *)malloc(pdata->brwin.nbytes); - if(pdata->args.noshared) - pdata->datatemp=(char *)malloc(pdata->brwin.nbytes); 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); @@ -100,7 +95,7 @@ int InitializeData(ProgData *pdata, pdata->specs.depth, ZPixmap, 0, - pdata->datamain, + pdata->pxl_data, pdata->brwin.rgeom.width, pdata->brwin.rgeom.height, 8, @@ -113,24 +108,25 @@ int InitializeData(ProgData *pdata, pdata->brwin.rgeom.width, pdata->brwin.rgeom.height); } - if((!pdata->args.noshared)||(!pdata->args.nocondshared)){ - pdata->shimage=XShmCreateImage(pdata->dpy, - pdata->specs.visual, - pdata->specs.depth, - ZPixmap,pdata->datash, - &pdata->shminfo, - pdata->brwin.rgeom.width, - pdata->brwin.rgeom.height); + if((!pdata->args.noshared)){ + pdata->image=XShmCreateImage(pdata->dpy, + pdata->specs.visual, + pdata->specs.depth, + ZPixmap, + pdata->pxl_data, + &pdata->shminfo, + pdata->brwin.rgeom.width, + pdata->brwin.rgeom.height); pdata->shminfo.shmid=shmget(IPC_PRIVATE, - pdata->shimage->bytes_per_line* - pdata->shimage->height, + pdata->image->bytes_per_line* + pdata->image->height, IPC_CREAT|0777); if(pdata->shminfo.shmid==-1){ fprintf(stderr,"Failed to obtain Shared Memory segment!\n"); return 12; } - pdata->shminfo.shmaddr=pdata->shimage->data=shmat(pdata->shminfo.shmid, - NULL,0); + pdata->shminfo.shmaddr=pdata->image->data=shmat(pdata->shminfo.shmid, + NULL,0); pdata->shminfo.readOnly = False; if(!XShmAttach(pdata->dpy,&pdata->shminfo)){ fprintf(stderr,"Failed to attach shared memory to proccess.\n"); @@ -138,7 +134,7 @@ int InitializeData(ProgData *pdata, } XShmGetImage(pdata->dpy, pdata->specs.root, - pdata->shimage, + pdata->image, pdata->brwin.rgeom.x, pdata->brwin.rgeom.y, AllPlanes); @@ -211,15 +207,11 @@ int InitializeData(ProgData *pdata, pdata->enc_data->yuv.v[i]=pdata->enc_data->yuv.u[i]=127; } - dtap=(((pdata->args.nocondshared)&&(!pdata->args.noshared))? - ((unsigned char*)pdata->shimage->data): - ((unsigned char*)pdata->image->data)); - - - UPDATE_YUV_BUFFER((&pdata->enc_data->yuv),dtap, + UPDATE_YUV_BUFFER((&pdata->enc_data->yuv), + ((unsigned char*)pdata->image->data), (pdata->enc_data->x_offset),(pdata->enc_data->y_offset), (pdata->brwin.rgeom.width),(pdata->brwin.rgeom.height), - __X_IPC,(pdata->args.no_quick_subsample), + (pdata->args.no_quick_subsample), pdata->specs.depth); pdata->frametime=(1000000)/pdata->args.fps; diff --git a/recordmydesktop/src/load_cache.c b/recordmydesktop/src/load_cache.c index 78c81c5..a992a21 100644 --- a/recordmydesktop/src/load_cache.c +++ b/recordmydesktop/src/load_cache.c @@ -150,7 +150,7 @@ void *LoadCache(ProgData *pdata){ VBlocks[(yuv->uv_width*yuv->uv_height)/UV_UNIT_BYTES]; //we allocate the frame that we will use INIT_FRAME(&frame,&fheader,yuv, - YBlocks,UBlocks,VBlocks) + YBlocks,UBlocks,VBlocks); //and the we open our files if(!pdata->args.zerocompression){ ifp=gzopen(pdata->cache_data->imgdata,"rb"); diff --git a/recordmydesktop/src/make_dummy_pointer.c b/recordmydesktop/src/make_dummy_pointer.c index 9e0ad3a..0932af6 100644 --- a/recordmydesktop/src/make_dummy_pointer.c +++ b/recordmydesktop/src/make_dummy_pointer.c @@ -35,22 +35,22 @@ unsigned char *MakeDummyPointer(DisplaySpecs *specs, unsigned long b=(color)?'w':'b', w=(color)?'b':'w'; char pmask[1][16][16]={{ - {w,w,w,w,w,w,o,o,o,o,o,o,o,o,o,o}, - {w,b,b,w,w,w,w,o,o,o,o,o,o,o,o,o}, - {w,b,b,b,w,w,w,w,o,o,o,o,o,o,o,o}, - {w,b,b,b,b,w,w,w,w,o,o,o,o,o,o,o}, + {w,w,o,o,o,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,w,o,o,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,w,o,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,w,o,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,w,o,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,w,o,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,b,w,o,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,b,b,w,o,o,o,o,o,o,o}, + {w,b,b,b,b,b,b,b,b,w,o,o,o,o,o,o}, {w,b,b,b,b,b,w,w,w,w,o,o,o,o,o,o}, - {w,b,b,b,b,b,b,w,w,w,w,o,o,o,o,o}, - {w,b,b,b,b,b,b,b,w,w,w,w,o,o,o,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,b,b,b,b,b,b,b,b,b,w,w,w,w,o,o}, - {w,b,b,b,b,b,b,b,b,b,b,w,w,w,w,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,b,b,b,b,b,b,b,b,w,w,w,w,o,o,o}, - {w,w,w,w,w,b,b,b,b,b,w,w,w,o,o,o}, - {w,w,w,w,w,w,b,b,b,b,w,w,w,o,o,o}, - {o,o,o,o,o,w,w,b,b,b,w,w,w,o,o,o}, - {o,o,o,o,o,o,w,w,w,w,w,w,w,o,o,o}} + {w,b,b,b,b,b,w,o,o,o,o,o,o,o,o,o}, + {w,b,b,w,w,b,b,w,o,o,o,o,o,o,o,o}, + {w,b,w,o,w,b,b,w,o,o,o,o,o,o,o,o}, + {w,w,o,o,o,w,b,b,w,o,o,o,o,o,o,o}, + {o,o,o,o,o,w,b,b,w,o,o,o,o,o,o,o}, + {o,o,o,o,o,o,w,w,o,o,o,o,o,o,o,o}} }; unsigned char *ret=malloc(size*sizeof(char[size*4])); unsigned char wp[4]={ diff --git a/recordmydesktop/src/parseargs.c b/recordmydesktop/src/parseargs.c index a2a55c4..1474838 100644 --- a/recordmydesktop/src/parseargs.c +++ b/recordmydesktop/src/parseargs.c @@ -64,14 +64,8 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ "\t-dummy-cursor color\tColor of the dummy cursor [black|white]\n" "\t--no-cursor\t\tDisable drawing of the cursor.\n" - "\t--with-shared\t\tEnable usage of" - " MIT-shared memory extension at all times.\n" - - "\t--no-cond-shared\tDo not use" - " the MIT-shared memory extension when aquiring large areas.\n" - - "\t-shared-threshold n\tThreshold over" - " which shared memory is used(default 75).\n" + "\t--no-shared\t\tDisable usage of" + " MIT-shared memory extension(Not Recommended!).\n" "\t--full-shots\t\tTake full screenshot at every frame(Not recomended!).\n" "\t--quick-subsampling\tDo subsampling" @@ -104,7 +98,6 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ "\t-v_bitrate n\t\tA number from 45000 to 2000000" " for desired encoded video bitrate(default 45000).\n" - "\t--drop-frames\t\tAllow theora encoder to drop frames.\n" "\t-s_quality n\t\tDesired audio quality(-1 to 10).\n\n" "Misc Options:\n" @@ -397,24 +390,6 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ } i++; } - else if(!strcmp(argv[i],"-shared-threshold")){ - if(i+1<argc){ - int num=atoi(argv[i+1]); - if((num>0)&&(num<100)) - arg_return->shared_thres=num; - else{ - fprintf(stderr,"Argument Usage:" - " -shared-threshold N(0<number<100)\n"); - return 1; - } - } - else{ - fprintf(stderr,"Argument Usage:" - " -shared-threshold N(0<number<100)\n"); - return 1; - } - i++; - } else if(!strcmp(argv[i],"-device")){ if(i+1<argc){ free(arg_return->device); @@ -514,17 +489,11 @@ int ParseArgs(int argc,char **argv,ProgArgs *arg_return){ } else if(!strcmp(argv[i],"--no-sound")) arg_return->nosound=1; - else if(!strcmp(argv[i],"--drop-frames")) - arg_return->dropframes=1; - else if(!strcmp(argv[i],"--with-shared")){ - arg_return->noshared=0; - arg_return->nocondshared=1; + else if(!strcmp(argv[i],"--no-shared")){ + arg_return->noshared=1; } - else if(!strcmp(argv[i],"--no-cond-shared")) - arg_return->nocondshared=1; else if(!strcmp(argv[i],"--full-shots")){ arg_return->full_shots=1; - arg_return->nocondshared=1; } else if(!strcmp(argv[i],"--quick-subsampling")){ arg_return->no_quick_subsample=0; diff --git a/recordmydesktop/src/queryextensions.c b/recordmydesktop/src/queryextensions.c index 3c28a2a..8d6413c 100644 --- a/recordmydesktop/src/queryextensions.c +++ b/recordmydesktop/src/queryextensions.c @@ -30,22 +30,28 @@ void QueryExtensions(Display *dpy, ProgArgs *args, int *damage_event, - int *damage_error){ + int *damage_error, + int *shm_opcode){ int xf_event_basep, - xf_error_basep; + xf_error_basep, + shm_event_base, + shm_error_base; if(!XDamageQueryExtension( dpy, damage_event, damage_error)){ fprintf(stderr,"XDamage extension not found!!!\n"); exit(4); } - if((!args->noshared)&&(XShmQueryExtension(dpy)==False)){ + if((!args->noshared)&&(!XQueryExtension(dpy, + "MIT-SHM", + shm_opcode, + &shm_event_base, + &shm_error_base))){ args->noshared=1; fprintf(stderr,"Shared Memory extension not present!\n" - "Try again removing the --with-shared option" - "(if you used it)\nand add the" - " --no-cond-shared option.\n"); + "Try again using the --no-shared option\n"); exit(5); } + if((args->xfixes_cursor)&& (XFixesQueryExtension(dpy,&xf_event_basep,&xf_error_basep)==False)){ args->xfixes_cursor=0; diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index f30485c..036bf5a 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -90,13 +90,13 @@ int main(int argc,char **argv){ "probably produce faulty results).\n\n"); pdata.args.full_shots=1; pdata.args.noshared=0; - pdata.args.nocondshared=1; } QueryExtensions(pdata.dpy, &pdata.args, &pdata.damage_event, - &pdata.damage_error); + &pdata.damage_error, + &pdata.shm_opcode); if((exit_status=InitializeData(&pdata,&enc_data,&cache_data))!=0) @@ -106,7 +106,7 @@ int main(int argc,char **argv){ rmdThreads(&pdata); fprintf(stderr,"."); - if((!pdata.args.noshared)||(!pdata.args.nocondshared)){ + if(!pdata.args.noshared){ XShmDetach (pdata.dpy, &pdata.shminfo); shmdt (&pdata.shminfo.shmaddr); shmctl (pdata.shminfo.shmid, IPC_RMID, 0); diff --git a/recordmydesktop/src/update_image.c b/recordmydesktop/src/update_image.c index 9681ce7..7a2895f 100644 --- a/recordmydesktop/src/update_image.c +++ b/recordmydesktop/src/update_image.c @@ -36,6 +36,8 @@ void UpdateImage(Display * dpy, EncData *enc, char *datatemp, int noshmem, + XShmSegmentInfo *shminfo, + int shm_opcode, int no_quick_subsample){ RectArea *temp; unsigned char *dtap=(unsigned char*)datatemp; @@ -52,12 +54,22 @@ void UpdateImage(Display * dpy, temp->geom.width, temp->geom.height); } + else{ + GetZPixmapSHM(dpy, + specs->root, + shminfo, + shm_opcode, + datatemp,temp->geom.x, + temp->geom.y, + temp->geom.width, + temp->geom.height); + } pthread_mutex_lock(yuv_mutex); UPDATE_YUV_BUFFER(yuv,dtap, (temp->geom.x-brwin->rgeom.x+enc->x_offset), (temp->geom.y-brwin->rgeom.y+enc->y_offset), (temp->geom.width),(temp->geom.height), - noshmem,no_quick_subsample, + no_quick_subsample, specs->depth); pthread_mutex_unlock(yuv_mutex); temp=temp->next; |