[MPlayer-dev-eng] [PATCH][RESEND] XV page flipping sync

Joey Parrish joey at nicewarrior.org
Wed Jun 23 18:18:52 CEST 2004


On Tue, Jun 22, 2004 at 10:42:09AM +0200, Diego Biurrun wrote:
> Reimar Döffinger writes:
> > > 01:44 <@KotH> DonDiego: whether it catches all XFlush calls
> > > 01:44 <@KotH> DonDiego: if he is right, then there should be no XFlush in the x11 code
> > 
> > My theory was always that the XFlush is rather useless. Am I correct? 
> > Should they be removed as well? (The problem described in the original 
> > mail can't happen here, as XSync is called as well).
> 
> Been talking to Attila on IRC again:
> 
> 02:50 <@KotH> DonDiego: imho, the patch should be extended to
>               xv/x11/x11_common, then it's ok to apply
> 02:51 <@KotH> DonDiego: and to answer reimars question: according to the
>               manpages, doing xflush+xsync is useless, xsync alone is enough
> 
> So could somebody extend this patch?

Okay, the first patch removes XFlush whenever it's redundant with XSync
calls.  The second patch removes all XFlush everywhere.  I know little
of X, but I feel like the first one is probably safe and the second one
is probably wrong.  I leave it to somebody else to apply.

Patches actually attached this time.  :)

--Joey

-- 
"Indeed do many things come to pass."
  HBT; The Book of Predictions, Chap. 19
-------------- next part --------------
diff -ur main.cvs/libvo/vo_3dfx.c main.dev/libvo/vo_3dfx.c
--- main.cvs/libvo/vo_3dfx.c	2003-10-03 17:33:06.000000000 -0500
+++ main.dev/libvo/vo_3dfx.c	2004-06-23 11:13:13.000000000 -0500
@@ -204,7 +204,6 @@
 
 	XSelectInput(display, mywindow, NoEventMask);
 
-	XFlush(display);
 	XSync(display, False);
 
 	return 0;
diff -ur main.cvs/libvo/vo_dxr3.c main.dev/libvo/vo_dxr3.c
--- main.cvs/libvo/vo_dxr3.c	2003-11-30 10:36:10.000000000 -0600
+++ main.dev/libvo/vo_dxr3.c	2004-06-23 11:13:19.000000000 -0500
@@ -632,7 +632,6 @@
 			XSetStandardProperties(mDisplay, vo_window, "DXR3 Overlay", "DXR3 Overlay", None, NULL, 0, &hint);
 			XSetWMNormalHints(mDisplay, vo_window, &hint);
 			XMapWindow(mDisplay, vo_window);
-			XFlush(mDisplay);
 			XSync(mDisplay, False);
 		}
 		
diff -ur main.cvs/libvo/vo_gl.c main.dev/libvo/vo_gl.c
--- main.cvs/libvo/vo_gl.c	2004-06-06 15:59:11.000000000 -0500
+++ main.dev/libvo/vo_gl.c	2004-06-23 11:13:23.000000000 -0500
@@ -228,7 +228,6 @@
     wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
     glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
 
-	XFlush(mDisplay);
 	XSync(mDisplay, False);
 
 	vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
diff -ur main.cvs/libvo/vo_gl2.c main.dev/libvo/vo_gl2.c
--- main.cvs/libvo/vo_gl2.c	2004-06-06 15:59:11.000000000 -0500
+++ main.dev/libvo/vo_gl2.c	2004-06-23 11:13:30.000000000 -0500
@@ -728,7 +728,6 @@
 
         glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
 
-	XFlush(mDisplay);
 	XSync(mDisplay, False);
 
 	//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
@@ -768,7 +767,6 @@
     return -1;
   }
   glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
-  XFlush(mDisplay);
   XSync(mDisplay, False);
 
   if (glXGetConfig(mDisplay,vinfo,GLX_RED_SIZE, &r_sz) != 0) r_sz = 0;
diff -ur main.cvs/libvo/vo_x11.c main.dev/libvo/vo_x11.c
--- main.cvs/libvo/vo_x11.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_x11.c	2004-06-23 11:13:34.000000000 -0500
@@ -425,7 +425,6 @@
                                   vo_dwidth, vo_dheight);
         }
 
-        XFlush(mDisplay);
         XSync(mDisplay, False);
 
         // we cannot grab mouse events on root window :(
diff -ur main.cvs/libvo/vo_xmga.c main.dev/libvo/vo_xmga.c
--- main.cvs/libvo/vo_xmga.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_xmga.c	2004-06-23 11:13:40.000000000 -0500
@@ -277,7 +277,6 @@
     if (vo_ontop)
         vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
 
-    XFlush(mDisplay);
     XSync(mDisplay, False);
 
     ioctl(f, MGA_VID_ON, 0);
diff -ur main.cvs/libvo/vo_xover.c main.dev/libvo/vo_xover.c
--- main.cvs/libvo/vo_xover.c	2003-11-30 10:36:10.000000000 -0600
+++ main.dev/libvo/vo_xover.c	2004-06-23 11:13:55.000000000 -0500
@@ -347,7 +347,6 @@
 
   set_window(1);
 
-  XFlush(mDisplay);
   XSync(mDisplay, False);
 
   panscan_calc();
diff -ur main.cvs/libvo/vo_xv.c main.dev/libvo/vo_xv.c
--- main.cvs/libvo/vo_xv.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_xv.c	2004-06-23 11:12:32.000000000 -0500
@@ -348,7 +348,6 @@
         if (vo_gc != None)
             XFreeGC(mDisplay, vo_gc);
         vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
-        XFlush(mDisplay);
         XSync(mDisplay, False);
 #ifdef HAVE_XF86VM
         if (vm)
@@ -514,7 +513,6 @@
     }
     XFree(xvimage[foo]);
 
-    XFlush(mDisplay);
     XSync(mDisplay, False);
     return;
 }
@@ -595,12 +593,9 @@
                    (vo_fs ? vo_dheight - 1 : vo_dheight) + vo_panscan_y);
     }
     if (num_buffers > 1)
-    {
         current_buf =
             vo_directrendering ? 0 : ((current_buf + 1) % num_buffers);
-        XFlush(mDisplay);
-    } else
-        XSync(mDisplay, False);
+    XSync(mDisplay, False);
     return;
 }
 
diff -ur main.cvs/libvo/vo_xvidix.c main.dev/libvo/vo_xvidix.c
--- main.cvs/libvo/vo_xvidix.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_xvidix.c	2004-06-23 11:14:00.000000000 -0500
@@ -411,7 +411,6 @@
 
     set_window(1);
 
-    XFlush(mDisplay);
     XSync(mDisplay, False);
 
     panscan_calc();
diff -ur main.cvs/libvo/vo_xvmc.c main.dev/libvo/vo_xvmc.c
--- main.cvs/libvo/vo_xvmc.c	2003-11-30 10:36:10.000000000 -0600
+++ main.dev/libvo/vo_xvmc.c	2004-06-23 11:14:13.000000000 -0500
@@ -189,7 +189,6 @@
    }
    XFree(xvimage);
 
-   XFlush( mDisplay );
    XSync(mDisplay, False);
    return;
 }
@@ -762,7 +761,6 @@
 
       if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc );
       vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv);
-      XFlush(mDisplay);
       XSync(mDisplay, False);
 #ifdef HAVE_XF86VM
       if ( vm )
-------------- next part --------------
diff -ur main.cvs/libvo/vo_3dfx.c main.dev/libvo/vo_3dfx.c
--- main.cvs/libvo/vo_3dfx.c	2003-10-03 17:33:06.000000000 -0500
+++ main.dev/libvo/vo_3dfx.c	2004-06-23 11:13:13.000000000 -0500
@@ -204,7 +204,6 @@
 
 	XSelectInput(display, mywindow, NoEventMask);
 
-	XFlush(display);
 	XSync(display, False);
 
 	return 0;
diff -ur main.cvs/libvo/vo_dxr3.c main.dev/libvo/vo_dxr3.c
--- main.cvs/libvo/vo_dxr3.c	2003-11-30 10:36:10.000000000 -0600
+++ main.dev/libvo/vo_dxr3.c	2004-06-23 11:13:19.000000000 -0500
@@ -632,7 +632,6 @@
 			XSetStandardProperties(mDisplay, vo_window, "DXR3 Overlay", "DXR3 Overlay", None, NULL, 0, &hint);
 			XSetWMNormalHints(mDisplay, vo_window, &hint);
 			XMapWindow(mDisplay, vo_window);
-			XFlush(mDisplay);
 			XSync(mDisplay, False);
 		}
 		
diff -ur main.cvs/libvo/vo_gl.c main.dev/libvo/vo_gl.c
--- main.cvs/libvo/vo_gl.c	2004-06-06 15:59:11.000000000 -0500
+++ main.dev/libvo/vo_gl.c	2004-06-23 11:13:23.000000000 -0500
@@ -228,7 +228,6 @@
     wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
     glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
 
-	XFlush(mDisplay);
 	XSync(mDisplay, False);
 
 	vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
diff -ur main.cvs/libvo/vo_gl2.c main.dev/libvo/vo_gl2.c
--- main.cvs/libvo/vo_gl2.c	2004-06-06 15:59:11.000000000 -0500
+++ main.dev/libvo/vo_gl2.c	2004-06-23 11:13:30.000000000 -0500
@@ -728,7 +728,6 @@
 
         glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
 
-	XFlush(mDisplay);
 	XSync(mDisplay, False);
 
 	//XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
@@ -768,7 +767,6 @@
     return -1;
   }
   glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
-  XFlush(mDisplay);
   XSync(mDisplay, False);
 
   if (glXGetConfig(mDisplay,vinfo,GLX_RED_SIZE, &r_sz) != 0) r_sz = 0;
diff -ur main.cvs/libvo/vo_x11.c main.dev/libvo/vo_x11.c
--- main.cvs/libvo/vo_x11.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_x11.c	2004-06-23 11:13:34.000000000 -0500
@@ -425,7 +425,6 @@
                                   vo_dwidth, vo_dheight);
         }
 
-        XFlush(mDisplay);
         XSync(mDisplay, False);
 
         // we cannot grab mouse events on root window :(
diff -ur main.cvs/libvo/vo_xmga.c main.dev/libvo/vo_xmga.c
--- main.cvs/libvo/vo_xmga.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_xmga.c	2004-06-23 11:18:54.000000000 -0500
@@ -81,7 +81,6 @@
     XSetForeground(mDisplay, vo_gc, colorkey);
     XFillRectangle(mDisplay, vo_window, vo_gc, drwX, drwY, drwWidth,
                    (vo_fs ? drwHeight - 1 : drwHeight));
-    XFlush(mDisplay);
 }
 
 static void check_events(void)
@@ -277,7 +276,6 @@
     if (vo_ontop)
         vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
 
-    XFlush(mDisplay);
     XSync(mDisplay, False);
 
     ioctl(f, MGA_VID_ON, 0);
diff -ur main.cvs/libvo/vo_xover.c main.dev/libvo/vo_xover.c
--- main.cvs/libvo/vo_xover.c	2003-11-30 10:36:10.000000000 -0600
+++ main.dev/libvo/vo_xover.c	2004-06-23 11:18:57.000000000 -0500
@@ -195,9 +195,6 @@
 
   if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
 
-  /* flush, update drawable */
-  XFlush(mDisplay);
-
   return;
 }
 
@@ -347,7 +344,6 @@
 
   set_window(1);
 
-  XFlush(mDisplay);
   XSync(mDisplay, False);
 
   panscan_calc();
diff -ur main.cvs/libvo/vo_xv.c main.dev/libvo/vo_xv.c
--- main.cvs/libvo/vo_xv.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_xv.c	2004-06-23 11:19:01.000000000 -0500
@@ -348,7 +348,6 @@
         if (vo_gc != None)
             XFreeGC(mDisplay, vo_gc);
         vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
-        XFlush(mDisplay);
         XSync(mDisplay, False);
 #ifdef HAVE_XF86VM
         if (vm)
@@ -514,7 +513,6 @@
     }
     XFree(xvimage[foo]);
 
-    XFlush(mDisplay);
     XSync(mDisplay, False);
     return;
 }
@@ -532,7 +530,6 @@
         {
             e |= VO_EVENT_EXPOSE;
             XClearWindow(mDisplay, vo_window);
-            XFlush(mDisplay);
         }
 
         XGetGeometry(mDisplay, vo_window, &mRoot, &drwX, &drwY, &vo_dwidth,
@@ -595,12 +592,9 @@
                    (vo_fs ? vo_dheight - 1 : vo_dheight) + vo_panscan_y);
     }
     if (num_buffers > 1)
-    {
         current_buf =
             vo_directrendering ? 0 : ((current_buf + 1) % num_buffers);
-        XFlush(mDisplay);
-    } else
-        XSync(mDisplay, False);
+    XSync(mDisplay, False);
     return;
 }
 
diff -ur main.cvs/libvo/vo_xvidix.c main.dev/libvo/vo_xvidix.c
--- main.cvs/libvo/vo_xvidix.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/vo_xvidix.c	2004-06-23 11:19:04.000000000 -0500
@@ -217,8 +217,6 @@
         XFillRectangle(mDisplay, vo_window, vo_gc, drwX, drwY, drwWidth,
                        (vo_fs ? drwHeight - 1 : drwHeight));
     }
-    /* flush, update drawable */
-    XFlush(mDisplay);
 
     return;
 }
@@ -411,7 +409,6 @@
 
     set_window(1);
 
-    XFlush(mDisplay);
     XSync(mDisplay, False);
 
     panscan_calc();
diff -ur main.cvs/libvo/vo_xvmc.c main.dev/libvo/vo_xvmc.c
--- main.cvs/libvo/vo_xvmc.c	2003-11-30 10:36:10.000000000 -0600
+++ main.dev/libvo/vo_xvmc.c	2004-06-23 11:19:15.000000000 -0500
@@ -189,7 +189,6 @@
    }
    XFree(xvimage);
 
-   XFlush( mDisplay );
    XSync(mDisplay, False);
    return;
 }
@@ -249,7 +248,6 @@
       XSetForeground( mDisplay,vo_gc,keycolor );
       XFillRectangle( mDisplay,vo_window,vo_gc,x,y,w,h);
    }
-   XFlush( mDisplay );
 }
 
 
@@ -762,7 +760,6 @@
 
       if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc );
       vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv);
-      XFlush(mDisplay);
       XSync(mDisplay, False);
 #ifdef HAVE_XF86VM
       if ( vm )
@@ -1428,7 +1425,6 @@
             if(old_y != vo_panscan_y)
             {
                XClearWindow(mDisplay, vo_window);
-               XFlush(mDisplay);
             }
          }
          return VO_TRUE;
diff -ur main.cvs/libvo/x11_common.c main.dev/libvo/x11_common.c
--- main.cvs/libvo/x11_common.c	2004-06-23 11:08:16.000000000 -0500
+++ main.dev/libvo/x11_common.c	2004-06-23 11:19:22.000000000 -0500
@@ -1248,7 +1248,6 @@
                        left_ov, left_ov2, img_height);
     }
 
-    XFlush(mDisplay);
 }
 
 void vo_x11_clearwindow(Display * mDisplay, Window vo_window)
@@ -1258,7 +1257,6 @@
     XFillRectangle(mDisplay, vo_window, f_gc, 0, 0, vo_screenwidth,
                    vo_screenheight);
     //
-    XFlush(mDisplay);
 }
 
 
@@ -1461,7 +1459,6 @@
 #endif
     XMapRaised(mDisplay, vo_window);
     XRaiseWindow(mDisplay, vo_window);
-    XFlush(mDisplay);
 }
 
 void vo_x11_ontop(void)
@@ -2047,7 +2044,6 @@
     }
 
     XStoreColors(mDisplay, cmap, cols, cm_size);
-    XFlush(mDisplay);
     return VO_TRUE;
 }
 


More information about the MPlayer-dev-eng mailing list