[vlc-commits] XCB/XVideo: enumerate adaptors
Rémi Denis-Courmont
git at videolan.org
Sat Dec 15 10:18:01 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 30 19:37:06 2012 +0300| [6146d360328b9370e123cef570699b67e4b8445c] | committer: Rémi Denis-Courmont
XCB/XVideo: enumerate adaptors
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6146d360328b9370e123cef570699b67e4b8445c
---
modules/video_output/xcb/xvideo.c | 77 +++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index 32c966c..3cbe44d 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -52,6 +52,7 @@
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
+static int EnumAdaptors (vlc_object_t *, const char *, int64_t **, char ***);
/*
* Module descriptor
@@ -66,6 +67,7 @@ vlc_module_begin ()
add_integer ("xvideo-adaptor", -1,
ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true)
+ change_integer_cb (EnumAdaptors)
add_integer ("xvideo-format-id", 0,
FORMAT_TEXT, FORMAT_LONGTEXT, true)
add_obsolete_bool ("xvideo-shm") /* removed in 2.0.0 */
@@ -847,3 +849,78 @@ static void Manage (vout_display_t *vd)
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;
+}
More information about the vlc-commits
mailing list