]> git.sesse.net Git - vlc/commitdiff
Split MIT-SHM check out of GetWindow
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 10 Dec 2009 21:11:51 +0000 (23:11 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 10 Dec 2009 21:29:12 +0000 (23:29 +0200)
modules/video_output/xcb/common.c
modules/video_output/xcb/x11.c
modules/video_output/xcb/xcb_vlc.h
modules/video_output/xcb/xvideo.c

index e538e65639c74ee682da0c43cabe515d39074148..c4ab50d45c68152923162095af063945db5be7f8 100644 (file)
@@ -86,14 +86,12 @@ static xcb_connection_t *Connect (vlc_object_t *obj, const char *display)
 
 /**
  * Create a VLC video X window object, connect to the corresponding X server,
- * find the corresponding X server screen,
- * and probe the MIT-SHM extension.
+ * find the corresponding X server screen.
  */
 vout_window_t *GetWindow (vout_display_t *vd,
                           xcb_connection_t **restrict pconn,
                           const xcb_screen_t **restrict pscreen,
-                          uint8_t *restrict pdepth,
-                          bool *restrict pshm)
+                          uint8_t *restrict pdepth)
 {
     /* Get window */
     xcb_window_t root;
@@ -166,27 +164,8 @@ vout_window_t *GetWindow (vout_display_t *vd,
     }
     msg_Dbg (vd, "using screen 0x%"PRIx32, root);
 
-    /* Check MIT-SHM shared memory support */
-    bool shm = var_CreateGetBool (vd, "x11-shm") > 0;
-    if (shm)
-    {
-        xcb_shm_query_version_cookie_t ck;
-        xcb_shm_query_version_reply_t *r;
-
-        ck = xcb_shm_query_version (conn);
-        r = xcb_shm_query_version_reply (conn, ck, NULL);
-        if (!r)
-        {
-            msg_Err (vd, "shared memory (MIT-SHM) not available");
-            msg_Warn (vd, "display will be slow");
-            shm = false;
-        }
-        free (r);
-    }
-
     *pconn = conn;
     *pscreen = screen;
-    *pshm = shm;
     return wnd;
 
 error:
@@ -213,6 +192,28 @@ int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
     return 0;
 }
 
+/** Check MIT-SHM shared memory support */
+void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm)
+{
+    bool shm = var_CreateGetBool (obj, "x11-shm") > 0;
+    if (shm)
+    {
+        xcb_shm_query_version_cookie_t ck;
+        xcb_shm_query_version_reply_t *r;
+
+        ck = xcb_shm_query_version (conn);
+        r = xcb_shm_query_version_reply (conn, ck, NULL);
+        if (!r)
+        {
+            msg_Err (obj, "shared memory (MIT-SHM) not available");
+            msg_Warn (obj, "display will be slow");
+            shm = false;
+        }
+        free (r);
+    }
+    *pshm = shm;
+}
+
 /**
  * Create a blank cursor.
  * Note that the pixmaps are leaked (until the X disconnection). Hence, this
index d1b3e3b40afecc314dd0e3397221680e0b8ce57a..13b9c0ba56c6cc106f6dfd1f0a4a7f365d615dbb 100644 (file)
@@ -105,8 +105,7 @@ static int Open (vlc_object_t *obj)
 
     /* Get window, connect to X server */
     const xcb_screen_t *scr;
-    p_sys->embed = GetWindow (vd, &p_sys->conn, &scr, &p_sys->depth,
-                              &p_sys->shm);
+    p_sys->embed = GetWindow (vd, &p_sys->conn, &scr, &p_sys->depth);
     if (p_sys->embed == NULL)
     {
         free (p_sys);
@@ -272,6 +271,8 @@ static int Open (vlc_object_t *obj)
 
     p_sys->visible = false;
 
+    CheckSHM (obj, p_sys->conn, &p_sys->shm);
+
     /* */
     vout_display_info_t info = vd->info;
     info.has_pictures_invalid = true;
index 96babf7b7e68acd8c9a5a2f203b13a7e24709f84..f74473866d96e6da339c0619499d3b457cdde9fc 100644 (file)
@@ -41,10 +41,10 @@ int ProcessKeyEvent (key_handler_t *, xcb_generic_event_t *);
 struct vout_window_t *GetWindow (vout_display_t *obj,
                                  xcb_connection_t **restrict pconn,
                                  const xcb_screen_t **restrict pscreen,
-                                 uint8_t *restrict pdepth,
-                                 bool *restrict pshm);
+                                 uint8_t *restrict pdepth);
 int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
                    unsigned *restrict width, unsigned *restrict height);
+void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm);
 xcb_cursor_t CreateBlankCursor (xcb_connection_t *, const xcb_screen_t *);
 
 int CheckError (vout_display_t *, xcb_connection_t *conn,
index 6bb8873bcf700db47713d4956cc228cd94956c65..e8798d5dc0a7fa790615c32b3d4194e74f1f60ba 100644 (file)
@@ -301,7 +301,7 @@ static int Open (vlc_object_t *obj)
     xcb_connection_t *conn;
     const xcb_screen_t *screen;
     uint8_t depth;
-    p_sys->embed = GetWindow (vd, &conn, &screen, &depth, &p_sys->shm);
+    p_sys->embed = GetWindow (vd, &conn, &screen, &depth);
     if (p_sys->embed == NULL)
     {
         free (p_sys);
@@ -501,7 +501,7 @@ static int Open (vlc_object_t *obj)
     /* Create cursor */
     p_sys->cursor = CreateBlankCursor (conn, screen);
 
-    /* */
+    CheckSHM (obj, conn, &p_sys->shm);
 
     /* */
     vout_display_info_t info = vd->info;