]> git.sesse.net Git - vlc/blobdiff - modules/video_output/xcb/xvideo.c
XCB/XVideo: minor simplification
[vlc] / modules / video_output / xcb / xvideo.c
index 9335fba49f3c85e5e5f55ac08eb9af8872b0322b..c132e895dcccfa35ae23ed85613b440babafff16 100644 (file)
@@ -66,12 +66,10 @@ vlc_module_begin ()
                  ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true)
     add_bool ("x11-shm", true, NULL, SHM_TEXT, SHM_LONGTEXT, true)
         add_deprecated_alias ("xvideo-shm")
-    add_shortcut ("xcb-xv")
-    add_shortcut ("xv")
-    add_shortcut ("xvideo")
+    add_shortcut ("xcb-xv", "xv", "xvideo", "xid")
 vlc_module_end ()
 
-#define MAX_PICTURES (VOUT_MAX_PICTURES)
+#define MAX_PICTURES (128)
 
 struct vout_display_sys_t
 {
@@ -299,7 +297,7 @@ static int Open (vlc_object_t *obj)
     vout_display_t *vd = (vout_display_t *)obj;
     vout_display_sys_t *p_sys = malloc (sizeof (*p_sys));
 
-    if (!var_CreateGetBool (obj, "overlay"))
+    if (!var_InheritBool (obj, "overlay"))
         return VLC_EGENERIC;
     if (p_sys == NULL)
         return VLC_ENOMEM;
@@ -329,6 +327,7 @@ static int Open (vlc_object_t *obj)
     }
 
     p_sys->window = xcb_generate_id (conn);
+    xcb_pixmap_t pixmap = xcb_generate_id (conn);
 
     /* Cache adaptors infos */
     xcb_xv_query_adaptors_reply_t *adaptors =
@@ -337,15 +336,15 @@ static int Open (vlc_object_t *obj)
     if (adaptors == NULL)
         goto error;
 
-    int forced_adaptor = var_CreateGetInteger (obj, "xvideo-adaptor");
+    int forced_adaptor = var_InheritInteger (obj, "xvideo-adaptor");
 
     /* */
     video_format_t fmt = vd->fmt;
-    bool found_adaptor = false;
+    p_sys->port = 0;
 
     xcb_xv_adaptor_info_iterator_t it;
     for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
-         it.rem > 0 && !found_adaptor;
+         it.rem > 0;
          xcb_xv_adaptor_info_next (&it))
     {
         const xcb_xv_adaptor_info_t *a = it.data;
@@ -432,7 +431,8 @@ static int Open (vlc_object_t *obj)
                  p_sys->port = port;
                  goto grabbed_port;
              }
-             msg_Dbg (vd, "cannot grab port %"PRIu32, port);
+             msg_Dbg (vd, "cannot grab port %"PRIu32": Xv error %"PRIu8, port,
+                      result);
         }
         continue; /* No usable port */
 
@@ -451,18 +451,37 @@ static int Open (vlc_object_t *obj)
         xcb_xv_format_t *f = xcb_xv_adaptor_info_formats (a);
         for (uint_fast16_t i = a->num_formats; i > 0; i--, f++)
         {
-            if (f->depth != depth)
+            if (f->depth != screen->root_depth)
                 continue; /* this would fail anyway */
 
-            const uint32_t mask =
+            uint32_t mask =
+                XCB_CW_BACK_PIXMAP |
+                XCB_CW_BACK_PIXEL |
+                XCB_CW_BORDER_PIXMAP |
+                XCB_CW_BORDER_PIXEL |
+                XCB_CW_EVENT_MASK |
+                XCB_CW_COLORMAP;
+            const uint32_t list[] = {
+                /* XCB_CW_BACK_PIXMAP */
+                pixmap,
+                /* XCB_CW_BACK_PIXEL */
+                screen->black_pixel,
+                /* XCB_CW_BORDER_PIXMAP */
+                pixmap,
+                /* XCB_CW_BORDER_PIXEL */
+                screen->black_pixel,
                 /* XCB_CW_EVENT_MASK */
-                XCB_EVENT_MASK_VISIBILITY_CHANGE;
+                XCB_EVENT_MASK_VISIBILITY_CHANGE,
+                /* XCB_CW_COLORMAP */
+                screen->default_colormap,
+            };
+
             xcb_void_cookie_t c;
 
+            xcb_create_pixmap (conn, f->depth, pixmap, screen->root, 1, 1);
             c = xcb_create_window_checked (conn, f->depth, p_sys->window,
                  p_sys->embed->handle.xid, 0, 0, 1, 1, 0,
-                 XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual,
-                 XCB_CW_EVENT_MASK, &mask);
+                 XCB_WINDOW_CLASS_INPUT_OUTPUT, f->visual, mask, list);
 
             if (!CheckError (vd, conn, "cannot create X11 window", c))
             {
@@ -473,15 +492,15 @@ static int Open (vlc_object_t *obj)
             }
         }
         xcb_xv_ungrab_port (conn, p_sys->port, XCB_CURRENT_TIME);
+        p_sys->port = 0;
         msg_Dbg (vd, "no usable X11 visual");
         continue; /* No workable XVideo format (visual/depth) */
 
     created_window:
-        found_adaptor = true;
         break;
     }
     free (adaptors);
-    if (!found_adaptor)
+    if (!p_sys->port)
     {
         msg_Err (vd, "no available XVideo adaptor");
         goto error;
@@ -520,6 +539,7 @@ static int Open (vlc_object_t *obj)
     /* */
     vout_display_info_t info = vd->info;
     info.has_pictures_invalid = false;
+    info.has_event_thread = true;
 
     /* Setup vout_display_t once everything is fine */
     vd->fmt = fmt;
@@ -532,10 +552,13 @@ static int Open (vlc_object_t *obj)
     vd->manage = Manage;
 
     /* */
-    vout_display_SendEventFullscreen (vd, false);
+    bool is_fullscreen = vd->cfg->is_fullscreen;
+    if (is_fullscreen && vout_window_SetFullScreen (p_sys->embed, true))
+        is_fullscreen = false;
+    vout_display_SendEventFullscreen (vd, is_fullscreen);
     unsigned width, height;
     if (!GetWindowSize (p_sys->embed, conn, &width, &height))
-        vout_display_SendEventDisplaySize (vd, width, height, false);
+        vout_display_SendEventDisplaySize (vd, width, height, is_fullscreen);
 
     return VLC_SUCCESS;
 
@@ -583,7 +606,6 @@ static void Close (vlc_object_t *obj)
 static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
 {
     vout_display_sys_t *p_sys = vd->sys;
-    (void)requested_count;
 
     if (!p_sys->pool)
     {
@@ -597,8 +619,10 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
 
         unsigned count;
         picture_t *pic_array[MAX_PICTURES];
-        for (count = 0; count < MAX_PICTURES; count++)
+        for (count = 0; count < requested_count; count++)
         {
+            if (count >= MAX_PICTURES)
+                break;
             picture_resource_t *res = &p_sys->resource[count];
 
             for (int i = 0; i < __MIN (p_sys->att->num_planes, PICTURE_PLANE_MAX); i++)