# HG changeset patch # User reimar # Date 1226775385 0 # Node ID a4e2700e9381ca8313f6b8c36dec3e73be18cad5 # Parent 08a5ccceb21a1503c49634ae0445ceb0b69c992d Simplify vo_vm_switch and vo_vm_close, everyone was using the (almost) same boiler-plate code with them, just with different bugs. diff -r 08a5ccceb21a -r a4e2700e9381 libvo/vo_x11.c --- a/libvo/vo_x11.c Sat Nov 15 18:28:35 2008 +0000 +++ b/libvo/vo_x11.c Sat Nov 15 18:56:25 2008 +0000 @@ -377,17 +377,7 @@ #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 @@ freeMyXImage(); #ifdef CONFIG_XF86VM - vo_vm_close(mDisplay); + vo_vm_close(); #endif zoomFlag = 0; diff -r 08a5ccceb21a -r a4e2700e9381 libvo/vo_xv.c --- a/libvo/vo_xv.c Sat Nov 15 18:28:35 2008 +0000 +++ b/libvo/vo_xv.c Sat Nov 15 18:56:25 2008 +0000 @@ -232,17 +232,7 @@ #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 @@ 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(); diff -r 08a5ccceb21a -r a4e2700e9381 libvo/vo_xvmc.c --- a/libvo/vo_xvmc.c Sat Nov 15 18:28:35 2008 +0000 +++ b/libvo/vo_xvmc.c Sat Nov 15 18:56:25 2008 +0000 @@ -656,16 +656,7 @@ #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 @@ xvmc_free(); //from vo_xv #ifdef CONFIG_XF86VM - vo_vm_close(mDisplay); + vo_vm_close(); #endif vo_x11_uninit(); } diff -r 08a5ccceb21a -r a4e2700e9381 libvo/x11_common.c --- a/libvo/x11_common.c Sat Nov 15 18:28:35 2008 +0000 +++ b/libvo/x11_common.c Sat Nov 15 18:56:25 2008 +0000 @@ -1743,12 +1743,13 @@ } #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 @@ } 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 @@ 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 @@ #endif { int i, modecount; - int screen; - - screen = DefaultScreen(dpy); free(vidmodes); vidmodes = NULL; @@ -1830,8 +1826,8 @@ 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; } diff -r 08a5ccceb21a -r a4e2700e9381 libvo/x11_common.h --- a/libvo/x11_common.h Sat Nov 15 18:28:35 2008 +0000 +++ b/libvo/x11_common.h Sat Nov 15 18:56:25 2008 +0000 @@ -122,8 +122,8 @@ 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);