[MPlayer-cvslog] r27924 - in trunk/libvo: vo_x11.c vo_xv.c vo_xvmc.c x11_common.c x11_common.h

reimar subversion at mplayerhq.hu
Sat Nov 15 19:56:25 CET 2008


Author: reimar
Date: Sat Nov 15 19:56:25 2008
New Revision: 27924

Log:
Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same
boiler-plate code with them, just with different bugs.


Modified:
   trunk/libvo/vo_x11.c
   trunk/libvo/vo_xv.c
   trunk/libvo/vo_xvmc.c
   trunk/libvo/x11_common.c
   trunk/libvo/x11_common.h

Modified: trunk/libvo/vo_x11.c
==============================================================================
--- trunk/libvo/vo_x11.c	(original)
+++ trunk/libvo/vo_x11.c	Sat Nov 15 19:56:25 2008
@@ -377,17 +377,7 @@ static int config(uint32_t width, uint32
 #ifdef CONFIG_XF86VM
         if (vm)
         {
-            if ((d_width == 0) && (d_height == 0))
-            {
-                vm_width = image_width;
-                vm_height = image_height;
-            } else
-            {
-                vm_width = d_width;
-                vm_height = d_height;
-            }
-            vo_vm_switch(vm_width, vm_height, &modeline_width,
-                         &modeline_height);
+            vo_vm_switch();
         }
 #endif
         bg = WhitePixel(mDisplay, mScreen);
@@ -704,7 +694,7 @@ static void uninit(void)
     freeMyXImage();
 
 #ifdef CONFIG_XF86VM
-    vo_vm_close(mDisplay);
+    vo_vm_close();
 #endif
 
     zoomFlag = 0;

Modified: trunk/libvo/vo_xv.c
==============================================================================
--- trunk/libvo/vo_xv.c	(original)
+++ trunk/libvo/vo_xv.c	Sat Nov 15 19:56:25 2008
@@ -232,17 +232,7 @@ static int config(uint32_t width, uint32
 #ifdef CONFIG_XF86VM
         if (vm)
         {
-            if ((d_width == 0) && (d_height == 0))
-            {
-                vm_width = image_width;
-                vm_height = image_height;
-            } else
-            {
-                vm_width = d_width;
-                vm_height = d_height;
-            }
-            vo_vm_switch(vm_width, vm_height, &modeline_width,
-                         &modeline_height);
+            vo_vm_switch();
         } else
 #endif
         XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay),
@@ -659,7 +649,7 @@ static void uninit(void)
     for (i = 0; i < num_buffers; i++)
         deallocate_xvimage(i);
 #ifdef CONFIG_XF86VM
-    vo_vm_close(mDisplay);
+    vo_vm_close();
 #endif
     mp_input_rm_event_fd(ConnectionNumber(mDisplay));
     vo_x11_uninit();

Modified: trunk/libvo/vo_xvmc.c
==============================================================================
--- trunk/libvo/vo_xvmc.c	(original)
+++ trunk/libvo/vo_xvmc.c	Sat Nov 15 19:56:25 2008
@@ -656,16 +656,7 @@ skip_surface_allocation:
 #ifdef CONFIG_XF86VM
       if ( vm )
       {
-	 if ((d_width==0) && (d_height==0))
-	    { vm_width=image_width; vm_height=image_height; }
-	 else
-	    { vm_width=d_width; vm_height=d_height; }
-	 vo_vm_switch(vm_width, vm_height,&modeline_width, &modeline_height);
-	 hint.x=(vo_screenwidth-modeline_width)/2;
-	 hint.y=(vo_screenheight-modeline_height)/2;
-	 hint.width=modeline_width;
-	 hint.height=modeline_height;
-	 aspect_save_screenres(modeline_width,modeline_height);
+	 vo_vm_switch();
       }
       else
 #endif
@@ -1152,7 +1143,7 @@ static void uninit(void){
    xvmc_free();
  //from vo_xv
 #ifdef CONFIG_XF86VM
-   vo_vm_close(mDisplay);
+   vo_vm_close();
 #endif
    vo_x11_uninit();
 }

Modified: trunk/libvo/x11_common.c
==============================================================================
--- trunk/libvo/x11_common.c	(original)
+++ trunk/libvo/x11_common.c	Sat Nov 15 19:56:25 2008
@@ -1743,12 +1743,13 @@ void vo_x11_selectinput_witherr(Display 
 }
 
 #ifdef CONFIG_XF86VM
-void vo_vm_switch(uint32_t X, uint32_t Y, int *modeline_width,
-                  int *modeline_height)
+void vo_vm_switch(void)
 {
     int vm_event, vm_error;
     int vm_ver, vm_rev;
     int i, j, have_vm = 0;
+    int X = vo_dwidth, Y = vo_dheight;
+    int modeline_width, modeline_height;
 
     int modecount;
 
@@ -1761,8 +1762,6 @@ void vo_vm_switch(uint32_t X, uint32_t Y
     } else {
         mp_msg(MSGT_VO, MSGL_WARN,
                "XF86VidMode extension not available.\n");
-        *modeline_width = vo_screenwidth;
-        *modeline_height = vo_screenheight;
     }
 
     if (have_vm)
@@ -1771,39 +1770,39 @@ void vo_vm_switch(uint32_t X, uint32_t Y
             XF86VidModeGetAllModeLines(mDisplay, mScreen, &modecount,
                                        &vidmodes);
         j = 0;
-        *modeline_width = vidmodes[0]->hdisplay;
-        *modeline_height = vidmodes[0]->vdisplay;
+        modeline_width = vidmodes[0]->hdisplay;
+        modeline_height = vidmodes[0]->vdisplay;
 
         for (i = 1; i < modecount; i++)
             if ((vidmodes[i]->hdisplay >= X)
                 && (vidmodes[i]->vdisplay >= Y))
-                if ((vidmodes[i]->hdisplay <= *modeline_width)
-                    && (vidmodes[i]->vdisplay <= *modeline_height))
+                if ((vidmodes[i]->hdisplay <= modeline_width)
+                    && (vidmodes[i]->vdisplay <= modeline_height))
                 {
-                    *modeline_width = vidmodes[i]->hdisplay;
-                    *modeline_height = vidmodes[i]->vdisplay;
+                    modeline_width = vidmodes[i]->hdisplay;
+                    modeline_height = vidmodes[i]->vdisplay;
                     j = i;
                 }
 
         mp_msg(MSGT_VO, MSGL_INFO, MSGTR_SelectedVideoMode,
-               *modeline_width, *modeline_height, X, Y);
+               modeline_width, modeline_height, X, Y);
         XF86VidModeLockModeSwitch(mDisplay, mScreen, 0);
         XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
         XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[j]);
 
         // FIXME: all this is more of a hack than proper solution
-        X = (vo_screenwidth - *modeline_width) / 2;
-        Y = (vo_screenheight - *modeline_height) / 2;
+        X = (vo_screenwidth - modeline_width) / 2;
+        Y = (vo_screenheight - modeline_height) / 2;
         XF86VidModeSetViewPort(mDisplay, mScreen, X, Y);
         vo_dx = X;
         vo_dy = Y;
-        vo_dwidth = *modeline_width;
-        vo_dheight = *modeline_height;
-        aspect_save_screenres(*modeline_width, *modeline_height);
+        vo_dwidth = modeline_width;
+        vo_dheight = modeline_height;
+        aspect_save_screenres(modeline_width, modeline_height);
     }
 }
 
-void vo_vm_close(Display * dpy)
+void vo_vm_close(void)
 {
 #ifdef CONFIG_GUI
     if (vidmodes != NULL && vo_window != None)
@@ -1812,9 +1811,6 @@ void vo_vm_close(Display * dpy)
 #endif
     {
         int i, modecount;
-        int screen;
-
-        screen = DefaultScreen(dpy);
 
         free(vidmodes);
         vidmodes = NULL;
@@ -1830,8 +1826,8 @@ void vo_vm_close(Display * dpy)
                 break;
             }
 
-        XF86VidModeSwitchToMode(dpy, screen, vidmodes[i]);
-        XF86VidModeSwitchToMode(dpy, screen, vidmodes[i]);
+        XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]);
+        XF86VidModeSwitchToMode(mDisplay, mScreen, vidmodes[i]);
         free(vidmodes);
         vidmodes = NULL;
     }

Modified: trunk/libvo/x11_common.h
==============================================================================
--- trunk/libvo/x11_common.h	(original)
+++ trunk/libvo/x11_common.h	Sat Nov 15 19:56:25 2008
@@ -122,8 +122,8 @@ void saver_off( Display * );
 void saver_on( Display * );
 
 #ifdef CONFIG_XF86VM
-void vo_vm_switch(uint32_t, uint32_t, int*, int*);
-void vo_vm_close(Display*);
+void vo_vm_switch(void);
+void vo_vm_close(void);
 #endif
 
 void update_xinerama_info(void);



More information about the MPlayer-cvslog mailing list