Commit 6146d360 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

XCB/XVideo: enumerate adaptors

parent 45ab9b93
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
static int Open (vlc_object_t *); static int Open (vlc_object_t *);
static void Close (vlc_object_t *); static void Close (vlc_object_t *);
static int EnumAdaptors (vlc_object_t *, const char *, int64_t **, char ***);
/* /*
* Module descriptor * Module descriptor
...@@ -66,6 +67,7 @@ vlc_module_begin () ...@@ -66,6 +67,7 @@ vlc_module_begin ()
add_integer ("xvideo-adaptor", -1, add_integer ("xvideo-adaptor", -1,
ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true) ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true)
change_integer_cb (EnumAdaptors)
add_integer ("xvideo-format-id", 0, add_integer ("xvideo-format-id", 0,
FORMAT_TEXT, FORMAT_LONGTEXT, true) FORMAT_TEXT, FORMAT_LONGTEXT, true)
add_obsolete_bool ("xvideo-shm") /* removed in 2.0.0 */ add_obsolete_bool ("xvideo-shm") /* removed in 2.0.0 */
...@@ -847,3 +849,78 @@ static void Manage (vout_display_t *vd) ...@@ -847,3 +849,78 @@ static void Manage (vout_display_t *vd)
ManageEvent (vd, p_sys->conn, &p_sys->visible); ManageEvent (vd, p_sys->conn, &p_sys->visible);
} }
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;
int snum;
conn = xcb_connect (display, &snum);
free (display);
if (xcb_connection_has_error (conn) /*== NULL*/)
goto error;
/* Find configured screen */
const xcb_setup_t *setup = xcb_get_setup (conn);
const xcb_screen_t *scr = NULL;
for (xcb_screen_iterator_t i = xcb_setup_roots_iterator (setup);
i.rem > 0; xcb_screen_next (&i))
{
if (snum == 0)
{
scr = i.data;
break;
}
snum--;
}
if (scr == NULL)
goto error;
xcb_xv_query_adaptors_reply_t *adaptors =
xcb_xv_query_adaptors_reply (conn,
xcb_xv_query_adaptors (conn, scr->root), NULL);
if (adaptors == NULL)
goto error;
xcb_xv_adaptor_info_iterator_t it;
for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
it.rem > 0;
xcb_xv_adaptor_info_next (&it))
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);
it.rem > 0;
xcb_xv_adaptor_info_next (&it))
{
const xcb_xv_adaptor_info_t *a = it.data;
n++;
if (!(a->type & XCB_XV_TYPE_INPUT_MASK)
|| !(a->type & XCB_XV_TYPE_IMAGE_MASK))
continue;
*(values++) = n - 2;
*(texts++) = strndup (xcb_xv_adaptor_info_name (a), a->name_size);
}
free (adaptors);
error:
xcb_disconnect (conn);
(void) obj; (void) var;
return n;
}
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