comparison libvo/vo_xv.c @ 5622:d354889a3944

Support XV over remote connections, patch by Dmitry Karasik <dimakar at yahoo.com>
author atmos4
date Sun, 14 Apr 2002 22:15:29 +0000
parents 1972c3475d93
children b8d8d72776f2
comparison
equal deleted inserted replaced
5621:0426f9b887cd 5622:d354889a3944
492 { 492 {
493 /* 493 /*
494 * allocate XvImages. FIXME: no error checking, without 494 * allocate XvImages. FIXME: no error checking, without
495 * mit-shm this will bomb... 495 * mit-shm this will bomb...
496 */ 496 */
497 xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]); 497 if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag = 1;
498 498 else
499 Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777); 499 {
500 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0); 500 Shmem_Flag = 0;
501 Shminfo[foo].readOnly = False; 501 if ( !Quiet_Flag ) printf( "Shared memory not supported\nReverting to normal Xv\n" );
502 502 }
503 xvimage[foo]->data = Shminfo[foo].shmaddr; 503 if ( Shmem_Flag )
504 XShmAttach(mDisplay, &Shminfo[foo]); 504 {
505 XSync(mDisplay, False); 505 xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
506 shmctl(Shminfo[foo].shmid, IPC_RMID, 0); 506
507 Shminfo[foo].shmid = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
508 Shminfo[foo].shmaddr = (char *) shmat(Shminfo[foo].shmid, 0, 0);
509 Shminfo[foo].readOnly = False;
510
511 xvimage[foo]->data = Shminfo[foo].shmaddr;
512 XShmAttach(mDisplay, &Shminfo[foo]);
513 XSync(mDisplay, False);
514 shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
515 }
516 else
517 {
518 xvimage[foo] = XvCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height);
519 xvimage[foo]->data = malloc(xvimage[foo]->data_size);
520 XSync(mDisplay,False);
521 }
507 memset(xvimage[foo]->data,128,xvimage[foo]->data_size); 522 memset(xvimage[foo]->data,128,xvimage[foo]->data_size);
508 return; 523 return;
509 } 524 }
510 525
511 static void deallocate_xvimage(int foo) 526 static void deallocate_xvimage(int foo)
512 { 527 {
513 XShmDetach( mDisplay,&Shminfo[foo] ); 528 if ( Shmem_Flag )
514 shmdt( Shminfo[foo].shmaddr ); 529 {
530 XShmDetach( mDisplay,&Shminfo[foo] );
531 shmdt( Shminfo[foo].shmaddr );
532 }
533 else
534 {
535 free(xvimage[foo]->data);
536 }
537 XFree(xvimage[foo]);
538
515 XFlush( mDisplay ); 539 XFlush( mDisplay );
516 XSync(mDisplay, False); 540 XSync(mDisplay, False);
517 return; 541 return;
518 } 542 }
519 543
540 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); 564 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
541 } 565 }
542 } 566 }
543 if ( e & VO_EVENT_EXPOSE ) 567 if ( e & VO_EVENT_EXPOSE )
544 { 568 {
545 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX, drwY, 1, 1, False); 569 if ( Shmem_Flag )
546 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight), False); 570 {
571 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX, drwY, 1, 1, False);
572 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight), False);
573 }
574 else
575 {
576 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX, drwY, 1, 1);
577 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 0, 0, image_width, image_height, drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight));
578 }
547 } 579 }
548 } 580 }
549 581
550 static void draw_osd(void) 582 static void draw_osd(void)
551 { vo_draw_text(image_width,image_height,draw_alpha_fnc);} 583 { vo_draw_text(image_width,image_height,draw_alpha_fnc);}
552 584
553 static void flip_page(void) 585 static void flip_page(void)
554 { 586 {
555 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf], 587 if ( Shmem_Flag )
588 {
589 XvShmPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf],
556 0, 0, image_width, image_height, 590 0, 0, image_width, image_height,
557 drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight), 591 drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight),
558 False); 592 False);
593 }
594 else
595 {
596 XvPutImage(mDisplay, xv_port, vo_window, vo_gc, xvimage[current_buf],
597 0, 0, image_width, image_height,
598 drwX,drwY,drwWidth,(vo_fs?drwHeight - 1:drwHeight));
599 }
559 if (num_buffers>1){ 600 if (num_buffers>1){
560 current_buf=(current_buf+1)%num_buffers; 601 current_buf=(current_buf+1)%num_buffers;
561 XFlush(mDisplay); 602 XFlush(mDisplay);
562 } else 603 } else
563 XSync(mDisplay, False); 604 XSync(mDisplay, False);