[vlc-devel] [PATCH] glx: Bind drawable to context before setting swap interval (fix #8738)

Francois Cartegnie fcvlcdev at free.fr
Thu May 30 15:38:57 CEST 2013


---
 modules/video_output/glx.c | 60 +++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 27 deletions(-)

diff --git a/modules/video_output/glx.c b/modules/video_output/glx.c
index 22bbcfa..7abdf83 100644
--- a/modules/video_output/glx.c
+++ b/modules/video_output/glx.c
@@ -50,6 +50,7 @@ vlc_module_end ()
 typedef struct vlc_gl_sys_t
 {
     Display *display;
+    int snum;
     GLXWindow win;
     GLXContext ctx;
 } vlc_gl_sys_t;
@@ -125,7 +126,7 @@ static int Open (vlc_object_t *obj)
     if (!XGetWindowAttributes (dpy, gl->surface->handle.xid, &wa))
         goto error;
 
-    const int snum = XScreenNumberOfScreen (wa.screen);
+    sys->snum = XScreenNumberOfScreen (wa.screen);
     const VisualID visual = XVisualIDFromVisual (wa.visual);
     static const int attr[] = {
         GLX_RED_SIZE, 5,
@@ -138,7 +139,7 @@ static int Open (vlc_object_t *obj)
     };
 
     int nelem;
-    GLXFBConfig *confs = glXChooseFBConfig (dpy, snum, attr, &nelem);
+    GLXFBConfig *confs = glXChooseFBConfig (dpy, sys->snum, attr, &nelem);
     if (confs == NULL)
     {
         msg_Err (obj, "cannot choose GLX frame buffer configurations");
@@ -184,31 +185,6 @@ static int Open (vlc_object_t *obj)
         goto error;
     }
 
-#ifdef GLX_ARB_get_proc_address
-    bool is_swap_interval_set = false;
-# ifdef GLX_SGI_swap_control
-    if (!is_swap_interval_set
-     && CheckGLXext (dpy, snum, "GLX_SGI_swap_control"))
-    {
-        PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
-            glXGetProcAddressARB ((const GLubyte *)"glXSwapIntervalSGI");
-        assert (SwapIntervalSGI != NULL);
-        is_swap_interval_set = !SwapIntervalSGI (1);
-    }
-# endif
-# ifdef GLX_EXT_swap_control
-    if (!is_swap_interval_set
-     && CheckGLXext (dpy, snum, "GLX_EXT_swap_control"))
-    {
-        PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
-            glXGetProcAddress ((const GLubyte *)"glXSwapIntervalEXT");
-        assert (SwapIntervalEXT != NULL);
-        SwapIntervalEXT (dpy, sys->win, 1);
-        is_swap_interval_set = true;
-    }
-# endif
-#endif
-
     /* Initialize OpenGL callbacks */
     gl->sys = sys;
     gl->makeCurrent = MakeCurrent;
@@ -242,6 +218,36 @@ static int MakeCurrent (vlc_gl_t *gl)
 
     if (!glXMakeContextCurrent (sys->display, sys->win, sys->win, sys->ctx))
         return VLC_EGENERIC;
+
+    PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
+        glXGetProcAddressARB ((const GLubyte *)"glXSwapIntervalSGI");
+    assert (SwapIntervalSGI != NULL);
+    SwapIntervalSGI (1);
+#ifdef GLX_ARB_get_proc_address
+    bool is_swap_interval_set = false;
+# ifdef GLX_SGI_swap_control
+    if (!is_swap_interval_set
+     && CheckGLXext (sys->display, sys->snum, "GLX_SGI_swap_control"))
+    {
+        PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
+            glXGetProcAddressARB ((const GLubyte *)"glXSwapIntervalSGI");
+        assert (SwapIntervalSGI != NULL);
+        is_swap_interval_set = !SwapIntervalSGI (1);
+    }
+# endif
+# ifdef GLX_EXT_swap_control
+    if (!is_swap_interval_set
+     && CheckGLXext (sys->display, sys->snum, "GLX_EXT_swap_control"))
+    {
+        PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
+            glXGetProcAddress ((const GLubyte *)"glXSwapIntervalEXT");
+        assert (SwapIntervalEXT != NULL);
+        SwapIntervalEXT (sys->display, sys->win, 1);
+        is_swap_interval_set = true;
+    }
+# endif
+#endif
+
     return VLC_SUCCESS;
 }
 
-- 
1.8.1.4




More information about the vlc-devel mailing list