[Mplayer-cvslog] CVS: main/libvo x11_common.h,1.5,1.6 x11_common.c,1.19,1.20 vo_x11.c,1.20,1.21 vo_xmga.c,1.20,1.21 vo_xv.c,1.20,1.21

Gabor Lenart lgb at users.sourceforge.net
Fri Jun 1 00:33:00 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory usw-pr-cvs1:/tmp/cvs-serv9561/main/libvo

Modified Files:
	x11_common.h x11_common.c vo_x11.c vo_xmga.c vo_xv.c 
Log Message:
Centralized and cleaned up X11 connecting, fixed remote X11 playing, -display option for mplayer. SHOULD BE TESTED.

Index: x11_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** x11_common.h	2001/05/08 12:17:03	1.5
--- x11_common.h	2001/05/31 22:32:58	1.6
***************
*** 8,11 ****
--- 8,17 ----
  extern int vo_dheight;
  
+ extern char *mDisplayName;
+ extern Display *mDisplay;
+ extern Window *mRootWin;
+ extern int mScreen;
+ extern int mLocalDisplay;
+ 
  int vo_init( void );
  int vo_hidecursor ( Display* , Window );

Index: x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** x11_common.c	2001/05/09 20:15:37	1.19
--- x11_common.c	2001/05/31 22:32:58	1.20
***************
*** 23,27 ****
--- 23,33 ----
  static int timeout_save=0;
  
+ char* mDisplayName=NULL;
+ Display* mDisplay;
+ Window   mRootWin;
+ int mScreen;
+ int mLocalDisplay;
  
+ 
  void vo_hidecursor ( Display *disp , Window win )
  {
***************
*** 43,61 ****
  {
   int       CompletionType = -1;
!  int       mScreen;
   int bpp;
!  char    * DisplayName = ":0.0";
!  Display * mDisplay;
   XImage  * mXImage;
!  Window    mRootWin;
   static XWindowAttributes attribs;
  
   if(vo_depthonscreen) return 1; // already called
  
!  if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
!  mDisplay=XOpenDisplay( DisplayName );
   if ( !mDisplay )
    {
!    printf( "vo: couldn't open the X11 display!\n" );
     return 0;
    }
--- 49,70 ----
  {
   int       CompletionType = -1;
! // int       mScreen;
   int bpp;
! // char    * DisplayName = ":0.0";
! // Display * mDisplay;
   XImage  * mXImage;
! // Window    mRootWin;
   static XWindowAttributes attribs;
  
   if(vo_depthonscreen) return 1; // already called
+ 
+  if (!mDisplayName)
+    if (!(mDisplayName=getenv("DISPLAY")))
+      mDisplayName=strdup(":0.0");
  
!  mDisplay=XOpenDisplay(mDisplayName);
   if ( !mDisplay )
    {
!    printf( "vo: couldn't open the X11 display (%s)!\n",mDisplayName );
     return 0;
    }
***************
*** 73,78 ****
     XDestroyImage( mXImage );
   if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
!  XCloseDisplay( mDisplay );
!  printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
   return 1;
  }
--- 82,89 ----
     XDestroyImage( mXImage );
   if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
! // XCloseDisplay( mDisplay );
! #warning Better local display detection method is needed. 
!  if (*mDisplayName==':') mLocalDisplay=1; else mLocalDisplay=0;
!  printf("X11 running at %dx%d depth: %d (\"%s\" => %s display)\n",vo_screenwidth,vo_screenheight,vo_depthonscreen,mDisplayName,mLocalDisplay?"local":"remote");
   return 1;
  }

Index: vo_x11.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_x11.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** vo_x11.c	2001/05/24 20:48:45	1.20
--- vo_x11.c	2001/05/31 22:32:58	1.21
***************
*** 62,66 ****
  
  /* X11 related variables */
! static Display *mDisplay;
  static Window mywindow;
  static GC mygc;
--- 62,66 ----
  
  /* X11 related variables */
! //static Display *mDisplay;
  static Window mywindow;
  static GC mygc;
***************
*** 121,125 ****
   unsigned int fg,bg;
   char *hello=( title == NULL ) ? "X11 render" : title;
!  char *name=":0.0";
   XSizeHints hint;
   XVisualInfo vinfo;
--- 121,125 ----
   unsigned int fg,bg;
   char *hello=( title == NULL ) ? "X11 render" : title;
! // char *name=":0.0";
   XSizeHints hint;
   XVisualInfo vinfo;
***************
*** 137,151 ****
   if( !vo_init() ) return 0; // Can't open X11
  
-  if( getenv( "DISPLAY" ) ) name=getenv( "DISPLAY" );
- 
-  mDisplay=XOpenDisplay( name );
- 
-  if ( mDisplay == NULL )
-   {
-    printf( "Can not open display\n" );
-    return -1;
-   }
-  screen=DefaultScreen( mDisplay );
- 
   hint.x=0;
   hint.y=0;
--- 137,140 ----
***************
*** 173,177 ****
      if (have_vm) {
        if (vidmodes==NULL)
!         XF86VidModeGetAllModeLines(mDisplay,screen,&modecount,&vidmodes);
        j=0;
        modeline_width=vidmodes[0]->hdisplay;
--- 162,166 ----
      if (have_vm) {
        if (vidmodes==NULL)
!         XF86VidModeGetAllModeLines(mDisplay,mScreen,&modecount,&vidmodes);
        j=0;
        modeline_width=vidmodes[0]->hdisplay;
***************
*** 192,201 ****
  
        printf("XF86VM: Selected video mode %dx%d for image size %dx%d.\n",modeline_width, modeline_height, image_width, image_height);
!       XF86VidModeLockModeSwitch(mDisplay,screen,0);
!       XF86VidModeSwitchToMode(mDisplay,screen,vidmodes[j]);
!       XF86VidModeSwitchToMode(mDisplay,screen,vidmodes[j]);
        X=(vo_screenwidth-modeline_width)/2;
        Y=(vo_screenheight-modeline_height)/2;
!       XF86VidModeSetViewPort(mDisplay,screen,X,Y);
      }
    }
--- 181,190 ----
  
        printf("XF86VM: Selected video mode %dx%d for image size %dx%d.\n",modeline_width, modeline_height, image_width, image_height);
!       XF86VidModeLockModeSwitch(mDisplay,mScreen,0);
!       XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]);
!       XF86VidModeSwitchToMode(mDisplay,mScreen,vidmodes[j]);
        X=(vo_screenwidth-modeline_width)/2;
        Y=(vo_screenheight-modeline_height)/2;
!       XF86VidModeSetViewPort(mDisplay,mScreen,X,Y);
      }
    }
***************
*** 212,217 ****
   hint.flags=PPosition | PSize;
  
!  bg=WhitePixel( mDisplay,screen );
!  fg=BlackPixel( mDisplay,screen );
  
   XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs );
--- 201,206 ----
   hint.flags=PPosition | PSize;
  
!  bg=WhitePixel( mDisplay,mScreen );
!  fg=BlackPixel( mDisplay,mScreen );
  
   XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs );
***************
*** 219,225 ****
  
   if ( depth != 15 && depth != 16 && depth != 24 && depth != 32 ) depth=24;
!  XMatchVisualInfo( mDisplay,screen,depth,TrueColor,&vinfo );
  
!  theCmap  =XCreateColormap( mDisplay,RootWindow( mDisplay,screen ),
   vinfo.visual,AllocNone );
  
--- 208,214 ----
  
   if ( depth != 15 && depth != 16 && depth != 24 && depth != 32 ) depth=24;
!  XMatchVisualInfo( mDisplay,mScreen,depth,TrueColor,&vinfo );
  
!  theCmap  =XCreateColormap( mDisplay,RootWindow( mDisplay,mScreen ),
   vinfo.visual,AllocNone );
  
***************
*** 229,233 ****
   xswamask=CWBackPixel | CWBorderPixel |CWColormap;
  
!  mywindow=XCreateWindow( mDisplay,RootWindow( mDisplay,screen ),
                           hint.x,hint.y,
                           hint.width,hint.height,
--- 218,222 ----
   xswamask=CWBackPixel | CWBorderPixel |CWColormap;
  
!  mywindow=XCreateWindow( mDisplay,RootWindow( mDisplay,mScreen ),
                           hint.x,hint.y,
                           hint.width,hint.height,
***************
*** 249,253 ****
  
  #ifdef SH_MEM
!  if ( XShmQueryExtension( mDisplay ) ) Shmem_Flag=1;
    else
     {
--- 238,242 ----
  
  #ifdef SH_MEM
!  if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag=1;
    else
     {

Index: vo_xmga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xmga.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** vo_xmga.c	2001/05/20 21:49:45	1.20
--- vo_xmga.c	2001/05/31 22:32:58	1.21
***************
*** 63,67 ****
  };
  
! static Display              * mDisplay;
  static Window                 mWindow;
  static GC                     mGC;
--- 63,67 ----
  };
  
! //static Display              * mDisplay;
  static Window                 mWindow;
  static GC                     mGC;
***************
*** 226,240 ****
   if ( X_already_started ) return -1;
  
!  vo_init();
! 
!  if ( getenv( "DISPLAY" ) ) name=getenv( "DISPLAY" );
!  mDisplay=XOpenDisplay(name);
!  if ( mDisplay == NULL )
!   {
!    printf( "Can not open X11 display\n" );
!    return -1;
!   }
! 
!  mScreen=DefaultScreen( mDisplay );
  
   mvWidth=width; mvHeight=height;
--- 226,230 ----
   if ( X_already_started ) return -1;
  
!  if (!vo_init()) return -1;
  
   mvWidth=width; mvHeight=height;

Index: vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** vo_xv.c	2001/05/20 21:48:50	1.20
--- vo_xv.c	2001/05/31 22:32:58	1.21
***************
*** 49,53 ****
  
  /* X11 related variables */
! static Display *mydisplay;
  static Window mywindow;
  static GC mygc;
--- 49,53 ----
  
  /* X11 related variables */
! //static Display *mydisplay;
  static Window mywindow;
  static GC mygc;
***************
*** 96,102 ****
  static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
  {
!  int screen;
   char *hello = (title == NULL) ? "Xv render" : title;
!  char *name = ":0.0";
   XSizeHints hint;
   XVisualInfo vinfo;
--- 96,102 ----
  static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
  {
! // int screen;
   char *hello = (title == NULL) ? "Xv render" : title;
! // char *name = ":0.0";
   XSizeHints hint;
   XVisualInfo vinfo;
***************
*** 113,129 ****
   mFullscreen=flags&1;
   dwidth=d_width; dheight=d_height;
  
-  if(getenv("DISPLAY")) name = getenv("DISPLAY");
- 
-  mydisplay = XOpenDisplay(name);
- 
-  if (mydisplay == NULL)
-   {
-    printf("Can't open display\n");
-    return -1;
-   }
- 
-  screen = DefaultScreen(mydisplay);
- 
  #ifdef HAVE_GUI
   if ( vo_window == None )
--- 113,119 ----
   mFullscreen=flags&1;
   dwidth=d_width; dheight=d_height;
+  
+  if (!vo_init()) return -1;
  
  #ifdef HAVE_GUI
   if ( vo_window == None )
***************
*** 140,147 ****
      }
     hint.flags = PPosition | PSize;
!    XGetWindowAttributes(mydisplay, DefaultRootWindow(mydisplay), &attribs);
     depth=attribs.depth;
     if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24;
!    XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo);
  
     xswa.background_pixel = 0;
--- 130,137 ----
      }
     hint.flags = PPosition | PSize;
!    XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
     depth=attribs.depth;
     if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24;
!    XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
  
     xswa.background_pixel = 0;
***************
*** 149,163 ****
     xswamask = CWBackPixel | CWBorderPixel;
  
!    mywindow = XCreateWindow(mydisplay, RootWindow(mydisplay,screen),
     hint.x, hint.y, hint.width, hint.height,
     0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa);
!    vo_hidecursor(mydisplay,mywindow);
  
!    XSelectInput(mydisplay, mywindow, StructureNotifyMask | KeyPressMask );
!    XSetStandardProperties(mydisplay, mywindow, hello, hello, None, NULL, 0, &hint);
!    if ( mFullscreen ) vo_x11_decoration( mydisplay,mywindow,0 );
!    XMapWindow(mydisplay, mywindow);
!    XFlush(mydisplay);
!    XSync(mydisplay, False);
  #ifdef HAVE_GUI
    }
--- 139,153 ----
     xswamask = CWBackPixel | CWBorderPixel;
  
!    mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
     hint.x, hint.y, hint.width, hint.height,
     0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa);
!    vo_hidecursor(mDisplay,mywindow);
  
!    XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask );
!    XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
!    if ( mFullscreen ) vo_x11_decoration( mDisplay,mywindow,0 );
!    XMapWindow(mDisplay, mywindow);
!    XFlush(mDisplay);
!    XSync(mDisplay, False);
  #ifdef HAVE_GUI
    }
***************
*** 168,173 ****
       if ( vo_screenwidth != d_width )
        {
!        XMoveWindow( mydisplay,mywindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 );
!        XResizeWindow( mydisplay,mywindow,d_width,d_height );
        }
        else mFullscreen=1;
--- 158,163 ----
       if ( vo_screenwidth != d_width )
        {
!        XMoveWindow( mDisplay,mywindow,( vo_screenwidth - d_width ) / 2,( vo_screenheight - d_height ) / 2 );
!        XResizeWindow( mDisplay,mywindow,d_width,d_height );
        }
        else mFullscreen=1;
***************
*** 175,185 ****
  #endif
  
!  mygc = XCreateGC(mydisplay, mywindow, 0L, &xgcv);
  
   xv_port = 0;
!  if (Success == XvQueryExtension(mydisplay,&ver,&rel,&req,&ev,&err))
    {
     /* check for Xvideo support */
!    if (Success != XvQueryAdaptors(mydisplay,DefaultRootWindow(mydisplay), &adaptors,&ai))
      {
       printf("Xv: XvQueryAdaptors failed");
--- 165,175 ----
  #endif
  
!  mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
  
   xv_port = 0;
!  if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err))
    {
     /* check for Xvideo support */
!    if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai))
      {
       printf("Xv: XvQueryAdaptors failed");
***************
*** 194,198 ****
     if (xv_port != 0)
      {
!      fo = XvListImageFormats(mydisplay, xv_port, (int*)&formats);
       xv_format=0;
       for(i = 0; i < formats; i++)
--- 184,188 ----
     if (xv_port != 0)
      {
!      fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats);
       xv_format=0;
       for(i = 0; i < formats; i++)
***************
*** 217,223 ****
       current_buf=0;
  
!      XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
       drwX=0; drwY=0;
!      XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
       printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
  
--- 207,213 ----
       current_buf=0;
  
!      XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
       drwX=0; drwY=0;
!      XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
       printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
  
***************
*** 233,237 ****
        }
  
!      saver_off(mydisplay);  // turning off screen saver
       return 0;
      }
--- 223,227 ----
        }
  
!      saver_off(mDisplay);  // turning off screen saver
       return 0;
      }
***************
*** 252,256 ****
    * mit-shm this will bomb...
    */
!  xvimage[foo] = XvShmCreateImage(mydisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
  
   Shminfo[foo].shmid    = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
--- 242,246 ----
    * mit-shm this will bomb...
    */
!  xvimage[foo] = XvShmCreateImage(mDisplay, xv_port, xv_format, 0, image_width, image_height, &Shminfo[foo]);
  
   Shminfo[foo].shmid    = shmget(IPC_PRIVATE, xvimage[foo]->data_size, IPC_CREAT | 0777);
***************
*** 259,264 ****
  
   xvimage[foo]->data = Shminfo[foo].shmaddr;
!  XShmAttach(mydisplay, &Shminfo[foo]);
!  XSync(mydisplay, False);
   shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
   memset(xvimage[foo]->data,128,xvimage[foo]->data_size);
--- 249,254 ----
  
   xvimage[foo]->data = Shminfo[foo].shmaddr;
!  XShmAttach(mDisplay, &Shminfo[foo]);
!  XSync(mDisplay, False);
   shmctl(Shminfo[foo].shmid, IPC_RMID, 0);
   memset(xvimage[foo]->data,128,xvimage[foo]->data_size);
***************
*** 268,277 ****
  static void check_events(void)
  {
!  int e=vo_x11_check_events(mydisplay);
   if(e&VO_EVENT_RESIZE)
    {
!    XGetGeometry( mydisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
     drwX=0; drwY=0;
!    XTranslateCoordinates( mydisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
     printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
  
--- 258,267 ----
  static void check_events(void)
  {
!  int e=vo_x11_check_events(mDisplay);
   if(e&VO_EVENT_RESIZE)
    {
!    XGetGeometry( mDisplay,mywindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth );
     drwX=0; drwY=0;
!    XTranslateCoordinates( mDisplay,mywindow,mRoot,0,0,&drwcX,&drwcY,&mRoot );
     printf( "[xv] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
  
***************
*** 328,336 ****
   vo_draw_text(image_width,image_height,draw_alpha);
   check_events();
!  XvShmPutImage(mydisplay, xv_port, mywindow, mygc, xvimage[current_buf],
           0, 0,  image_width, image_height,
           drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
           False);
!  XFlush(mydisplay);
   current_buf=(current_buf+1)%NUM_BUFFERS;
   return;
--- 318,326 ----
   vo_draw_text(image_width,image_height,draw_alpha);
   check_events();
!  XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf],
           0, 0,  image_width, image_height,
           drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
           False);
!  XFlush(mDisplay);
   current_buf=(current_buf+1)%NUM_BUFFERS;
   return;
***************
*** 437,441 ****
  
  static void uninit(void) {
!     saver_on(mydisplay); // screen saver back on
  }
  
--- 427,431 ----
  
  static void uninit(void) {
!     saver_on(mDisplay); // screen saver back on
  }
  


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list