[vlc-commits] XCB/XVideo: return correct number of adaptors (fixes #11235)

Rémi Denis-Courmont git at videolan.org
Wed Apr 23 18:07:56 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 23 19:07:28 2014 +0300| [9e9028cd476dc3eb3c7990d1d7cd256e9a2cf396] | committer: Rémi Denis-Courmont

XCB/XVideo: return correct number of adaptors (fixes #11235)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9e9028cd476dc3eb3c7990d1d7cd256e9a2cf396
---

 modules/video_output/xcb/xvideo.c |   32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index ec50ccb..2f3c16a 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -824,8 +824,6 @@ static void Manage (vout_display_t *vd)
 static int EnumAdaptors (vlc_object_t *obj, const char *var,
                          int64_t **vp, char ***tp)
 {
-    size_t n = 0;
-
     /* Connect to X */
     char *display = var_InheritString (obj, "x11-display");
     xcb_connection_t *conn;
@@ -834,7 +832,7 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var,
     conn = xcb_connect (display, &snum);
     free (display);
     if (xcb_connection_has_error (conn) /*== NULL*/)
-        goto error;
+        return -1;
 
     /* Find configured screen */
     const xcb_setup_t *setup = xcb_get_setup (conn);
@@ -849,33 +847,43 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var,
         }
         snum--;
     }
+
     if (scr == NULL)
-        goto error;
+    {
+        xcb_disconnect (conn);
+        return -1;
+    }
 
     xcb_xv_query_adaptors_reply_t *adaptors =
         xcb_xv_query_adaptors_reply (conn,
             xcb_xv_query_adaptors (conn, scr->root), NULL);
+    xcb_disconnect (conn);
     if (adaptors == NULL)
-        goto error;
+        return -1;
 
     xcb_xv_adaptor_info_iterator_t it;
+    size_t n = 0;
 
     for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
          it.rem > 0;
          xcb_xv_adaptor_info_next (&it))
-        n++;
+    {
+        const xcb_xv_adaptor_info_t *a = it.data;
+
+        if ((a->type & XCB_XV_TYPE_INPUT_MASK)
+         && (a->type & XCB_XV_TYPE_IMAGE_MASK))
+            n++;
+    }
 
     int64_t *values = xmalloc ((n + 1) * sizeof (*values));
     char **texts = xmalloc ((n + 1) * sizeof (*texts));
     *vp = values;
     *tp = texts;
-    n = 0;
 
     *(values++) = -1;
     *(texts++) = strdup (N_("Auto"));
-    n++;
 
-    for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
+    for (it = xcb_xv_query_adaptors_info_iterator (adaptors), n = -1;
          it.rem > 0;
          xcb_xv_adaptor_info_next (&it))
     {
@@ -887,12 +895,10 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var,
          || !(a->type & XCB_XV_TYPE_IMAGE_MASK))
             continue;
 
-        *(values++) = n - 2;
+        *(values++) = n;
         *(texts++) = strndup (xcb_xv_adaptor_info_name (a), a->name_size);
     }
     free (adaptors);
-error:
-    xcb_disconnect (conn);
     (void) obj; (void) var;
-    return n;
+    return values - *vp;
 }



More information about the vlc-commits mailing list