Commit 9e9028cd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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

parent 40c8c1a7
...@@ -824,8 +824,6 @@ static void Manage (vout_display_t *vd) ...@@ -824,8 +824,6 @@ static void Manage (vout_display_t *vd)
static int EnumAdaptors (vlc_object_t *obj, const char *var, static int EnumAdaptors (vlc_object_t *obj, const char *var,
int64_t **vp, char ***tp) int64_t **vp, char ***tp)
{ {
size_t n = 0;
/* Connect to X */ /* Connect to X */
char *display = var_InheritString (obj, "x11-display"); char *display = var_InheritString (obj, "x11-display");
xcb_connection_t *conn; xcb_connection_t *conn;
...@@ -834,7 +832,7 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var, ...@@ -834,7 +832,7 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var,
conn = xcb_connect (display, &snum); conn = xcb_connect (display, &snum);
free (display); free (display);
if (xcb_connection_has_error (conn) /*== NULL*/) if (xcb_connection_has_error (conn) /*== NULL*/)
goto error; return -1;
/* Find configured screen */ /* Find configured screen */
const xcb_setup_t *setup = xcb_get_setup (conn); const xcb_setup_t *setup = xcb_get_setup (conn);
...@@ -849,33 +847,43 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var, ...@@ -849,33 +847,43 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var,
} }
snum--; snum--;
} }
if (scr == NULL) if (scr == NULL)
goto error; {
xcb_disconnect (conn);
return -1;
}
xcb_xv_query_adaptors_reply_t *adaptors = xcb_xv_query_adaptors_reply_t *adaptors =
xcb_xv_query_adaptors_reply (conn, xcb_xv_query_adaptors_reply (conn,
xcb_xv_query_adaptors (conn, scr->root), NULL); xcb_xv_query_adaptors (conn, scr->root), NULL);
xcb_disconnect (conn);
if (adaptors == NULL) if (adaptors == NULL)
goto error; return -1;
xcb_xv_adaptor_info_iterator_t it; xcb_xv_adaptor_info_iterator_t it;
size_t n = 0;
for (it = xcb_xv_query_adaptors_info_iterator (adaptors); for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
it.rem > 0; it.rem > 0;
xcb_xv_adaptor_info_next (&it)) 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)); int64_t *values = xmalloc ((n + 1) * sizeof (*values));
char **texts = xmalloc ((n + 1) * sizeof (*texts)); char **texts = xmalloc ((n + 1) * sizeof (*texts));
*vp = values; *vp = values;
*tp = texts; *tp = texts;
n = 0;
*(values++) = -1; *(values++) = -1;
*(texts++) = strdup (N_("Auto")); *(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; it.rem > 0;
xcb_xv_adaptor_info_next (&it)) xcb_xv_adaptor_info_next (&it))
{ {
...@@ -887,12 +895,10 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var, ...@@ -887,12 +895,10 @@ static int EnumAdaptors (vlc_object_t *obj, const char *var,
|| !(a->type & XCB_XV_TYPE_IMAGE_MASK)) || !(a->type & XCB_XV_TYPE_IMAGE_MASK))
continue; continue;
*(values++) = n - 2; *(values++) = n;
*(texts++) = strndup (xcb_xv_adaptor_info_name (a), a->name_size); *(texts++) = strndup (xcb_xv_adaptor_info_name (a), a->name_size);
} }
free (adaptors); free (adaptors);
error:
xcb_disconnect (conn);
(void) obj; (void) var; (void) obj; (void) var;
return n; return values - *vp;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment