3 * @brief X C Bindings video output module for VLC media player
5 /*****************************************************************************
6 * Copyright © 2009 Rémi Denis-Courmont
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
35 #include <vlc_common.h>
36 #include <vlc_plugin.h>
37 #include <vlc_vout_display.h>
38 #include <vlc_picture_pool.h>
39 #include <vlc_dialog.h>
44 #define ADAPTOR_TEXT N_("XVideo adaptor number")
45 #define ADAPTOR_LONGTEXT N_( \
46 "XVideo hardware adaptor to use. By default, VLC will " \
47 "use the first functional adaptor.")
49 #define FORMAT_TEXT N_("XVideo format id")
50 #define FORMAT_LONGTEXT N_( \
51 "XVideo image format id to use. By default, VLC will " \
52 "try to use the best match for the video being played.")
54 static int Open (vlc_object_t *);
55 static void Close (vlc_object_t *);
56 static int EnumAdaptors (vlc_object_t *, const char *, int64_t **, char ***);
62 set_shortname (N_("XVideo"))
63 set_description (N_("XVideo output (XCB)"))
64 set_category (CAT_VIDEO)
65 set_subcategory (SUBCAT_VIDEO_VOUT)
66 set_capability ("vout display", 200)
67 set_callbacks (Open, Close)
69 add_integer ("xvideo-adaptor", -1,
70 ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true)
71 change_integer_cb (EnumAdaptors)
72 add_integer ("xvideo-format-id", 0,
73 FORMAT_TEXT, FORMAT_LONGTEXT, true)
74 add_obsolete_bool ("xvideo-shm") /* removed in 2.0.0 */
75 add_shortcut ("xcb-xv", "xv", "xvideo", "xid")
78 #define MAX_PICTURES (128)
80 struct vout_display_sys_t
82 xcb_connection_t *conn;
83 vout_window_t *embed;/* VLC window */
85 xcb_cursor_t cursor; /* blank cursor */
86 xcb_window_t window; /* drawable X window */
87 xcb_gcontext_t gc; /* context to put images */
88 xcb_xv_port_t port; /* XVideo port */
89 uint32_t id; /* XVideo format */
90 uint16_t width; /* display width */
91 uint16_t height; /* display height */
92 uint32_t data_size; /* picture byte size (for non-SHM) */
93 bool swap_uv; /* U/V pointer must be swapped in a picture */
94 bool shm; /* whether to use MIT-SHM */
95 bool visible; /* whether it makes sense to draw at all */
97 xcb_xv_query_image_attributes_reply_t *att;
98 picture_pool_t *pool; /* picture pool */
101 static picture_pool_t *Pool (vout_display_t *, unsigned);
102 static void Display (vout_display_t *, picture_t *, subpicture_t *subpicture);
103 static int Control (vout_display_t *, int, va_list);
104 static void Manage (vout_display_t *);
107 * Check that the X server supports the XVideo extension.
109 static bool CheckXVideo (vout_display_t *vd, xcb_connection_t *conn)
111 xcb_xv_query_extension_reply_t *r;
112 xcb_xv_query_extension_cookie_t ck = xcb_xv_query_extension (conn);
115 /* We need XVideo 2.2 for PutImage */
116 r = xcb_xv_query_extension_reply (conn, ck, NULL);
118 msg_Dbg (vd, "XVideo extension not available");
121 msg_Dbg (vd, "XVideo extension v%"PRIu8".%"PRIu8" unknown",
125 msg_Dbg (vd, "XVideo extension v%"PRIu8".%"PRIu8" too old",
129 msg_Dbg (vd, "using XVideo extension v%"PRIu8".%"PRIu8,
137 static vlc_fourcc_t ParseFormat (vlc_object_t *obj,
138 const xcb_xv_image_format_info_t *restrict f)
142 case XCB_XV_IMAGE_FORMAT_INFO_TYPE_RGB:
143 switch (f->num_planes)
146 switch (popcount (f->red_mask | f->green_mask | f->blue_mask))
149 if (f->bpp == 32 && f->depth == 32)
150 return VLC_CODEC_RGBA;
151 if (f->bpp == 32 && f->depth == 24)
152 return VLC_CODEC_RGB32;
153 if (f->bpp == 24 && f->depth == 24)
154 return VLC_CODEC_RGB24;
157 if (f->byte_order != ORDER)
158 return 0; /* Mixed endian! */
159 if (f->bpp == 16 && f->depth == 16)
160 return VLC_CODEC_RGB16;
163 if (f->byte_order != ORDER)
164 return 0; /* Mixed endian! */
165 if (f->bpp == 16 && f->depth == 16)
166 return VLC_CODEC_RGBT;
167 if (f->bpp == 16 && f->depth == 15)
168 return VLC_CODEC_RGB15;
171 if (f->bpp == 16 && f->depth == 16)
172 return VLC_CODEC_RGBA16;
173 if (f->bpp == 16 && f->depth == 12)
174 return VLC_CODEC_RGB12;
176 if (f->bpp == 8 && f->depth == 8)
177 return VLC_CODEC_RGB8;
182 msg_Err (obj, "unknown XVideo RGB format %"PRIx32" (%.4s)",
184 msg_Dbg (obj, " %"PRIu8" planes, %"PRIu8" bits/pixel, "
185 "depth %"PRIu8, f->num_planes, f->bpp, f->depth);
188 case XCB_XV_IMAGE_FORMAT_INFO_TYPE_YUV:
189 if (f->u_sample_bits != f->v_sample_bits
190 || f->vhorz_u_period != f->vhorz_v_period
191 || f->vvert_u_period != f->vvert_v_period
192 || f->y_sample_bits != 8 || f->u_sample_bits != 8
193 || f->vhorz_y_period != 1 || f->vvert_y_period != 1)
195 switch (f->num_planes)
201 if (f->vhorz_u_period == 1 && f->vvert_u_period == 1)
202 return VLC_CODEC_I444;
205 if (f->vhorz_u_period == 2 && f->vvert_u_period == 1)
207 if (!strcmp ((const char *)f->vcomp_order, "YUYV"))
208 return VLC_CODEC_YUYV;
209 if (!strcmp ((const char *)f->vcomp_order, "UYVY"))
210 return VLC_CODEC_UYVY;
219 if (f->vhorz_u_period == 2 && f->vvert_u_period == 2)
221 if (!strcmp ((const char *)f->vcomp_order, "YVU"))
222 return VLC_CODEC_YV12;
223 if (!strcmp ((const char *)f->vcomp_order, "YUV"))
224 return VLC_CODEC_I420;
230 msg_Err (obj, "unknown XVideo YUV format %"PRIx32" (%.4s)", f->id,
232 msg_Dbg (obj, " %"PRIu8" planes, %"PRIu32" bits/pixel, "
233 "%"PRIu32"/%"PRIu32"/%"PRIu32" bits/sample", f->num_planes,
234 f->bpp, f->y_sample_bits, f->u_sample_bits, f->v_sample_bits);
235 msg_Dbg (obj, " period: %"PRIu32"/%"PRIu32"/%"PRIu32"x"
236 "%"PRIu32"/%"PRIu32"/%"PRIu32,
237 f->vhorz_y_period, f->vhorz_u_period, f->vhorz_v_period,
238 f->vvert_y_period, f->vvert_u_period, f->vvert_v_period);
239 msg_Warn (obj, " order: %.32s", f->vcomp_order);
245 static bool BetterFormat (vlc_fourcc_t a, const vlc_fourcc_t *tab,
248 for (unsigned i = 0, max = *rankp; i < max && tab[i] != 0; i++)
257 static xcb_xv_query_image_attributes_reply_t *
258 FindFormat (vlc_object_t *obj, xcb_connection_t *conn, video_format_t *fmt,
259 const xcb_xv_adaptor_info_t *a, uint32_t *idp)
261 /* Order chromas by preference */
263 const vlc_fourcc_t *chromav = tab;
265 vlc_fourcc_t chroma = var_InheritInteger (obj, "xvideo-format-id");
266 if (chroma != 0) /* Forced chroma */
271 else if (vlc_fourcc_IsYUV (fmt->i_chroma)) /* YUV chroma */
273 chromav = vlc_fourcc_GetYUVFallback (fmt->i_chroma);
275 else /* RGB chroma */
277 tab[0] = fmt->i_chroma;
278 tab[1] = VLC_CODEC_RGB32;
279 tab[2] = VLC_CODEC_RGB24;
280 tab[3] = VLC_CODEC_RGB16;
281 tab[4] = VLC_CODEC_RGB15;
282 tab[5] = VLC_CODEC_YUYV;
286 /* Get available image formats */
287 xcb_xv_list_image_formats_reply_t *list =
288 xcb_xv_list_image_formats_reply (conn,
289 xcb_xv_list_image_formats (conn, a->base_id), NULL);
293 /* Check available XVideo chromas */
294 xcb_xv_query_image_attributes_reply_t *attr = NULL;
295 unsigned rank = UINT_MAX;
297 for (const xcb_xv_image_format_info_t *f =
298 xcb_xv_list_image_formats_format (list),
300 f + xcb_xv_list_image_formats_format_length (list);
304 chroma = ParseFormat (obj, f);
309 if ((chroma == VLC_CODEC_I420 || chroma == VLC_CODEC_YV12)
311 && !memcmp ("OMAP", xcb_xv_adaptor_info_name (a), 4))
313 msg_Dbg (obj, "skipping slow I420 format");
314 continue; /* OMAP framebuffer sucks at YUV 4:2:0 */
317 if (!BetterFormat (chroma, chromav, &rank))
320 /* VLC pads scanline to 16 pixels internally */
321 unsigned width = fmt->i_width;
322 unsigned height = fmt->i_height;
323 xcb_xv_query_image_attributes_reply_t *i;
324 i = xcb_xv_query_image_attributes_reply (conn,
325 xcb_xv_query_image_attributes (conn, a->base_id, f->id,
326 width, height), NULL);
330 if (i->width != width || i->height != height)
332 msg_Warn (obj, "incompatible size %ux%u -> %"PRIu32"x%"PRIu32,
333 fmt->i_width, fmt->i_height,
334 i->width, i->height);
335 var_Create (obj->p_libvlc, "xvideo-res-error", VLC_VAR_BOOL);
336 if (!var_GetBool (obj->p_libvlc, "xvideo-res-error"))
338 dialog_FatalWait (obj, _("Video acceleration not available"),
339 _("The XVideo rendering acceleration driver does not "
340 "support the required resolution of %ux%u pixels but "
341 "%"PRIu32"x%"PRIu32" pixels instead.\n"
342 "Acceleration will thus be disabled. Performance may "
343 "be degraded severely if the resolution is large."),
344 width, height, i->width, i->height);
345 var_SetBool (obj->p_libvlc, "xvideo-res-error", true);
351 fmt->i_chroma = chroma;
352 if (f->type == XCB_XV_IMAGE_FORMAT_INFO_TYPE_RGB)
354 fmt->i_rmask = f->red_mask;
355 fmt->i_gmask = f->green_mask;
356 fmt->i_bmask = f->blue_mask;
362 break; /* shortcut for perfect match */
371 * Probe the X server.
373 static int Open (vlc_object_t *obj)
375 vout_display_t *vd = (vout_display_t *)obj;
376 vout_display_sys_t *p_sys;
378 if (!var_InheritBool (obj, "overlay"))
380 p_sys = malloc (sizeof (*p_sys));
387 xcb_connection_t *conn;
388 const xcb_screen_t *screen;
389 uint16_t width, height;
390 p_sys->embed = XCB_parent_Create (vd, &conn, &screen, &width, &height);
391 if (p_sys->embed == NULL)
401 if (!CheckXVideo (vd, conn))
403 msg_Warn (vd, "Please enable XVideo 2.2 for faster video display");
407 p_sys->window = xcb_generate_id (conn);
408 xcb_pixmap_t pixmap = xcb_generate_id (conn);
410 /* Cache adaptors infos */
411 xcb_xv_query_adaptors_reply_t *adaptors =
412 xcb_xv_query_adaptors_reply (conn,
413 xcb_xv_query_adaptors (conn, p_sys->embed->handle.xid), NULL);
414 if (adaptors == NULL)
417 int adaptor_selected = var_InheritInteger (obj, "xvideo-adaptor");
418 int adaptor_current = -1;
422 vout_display_place_t place;
425 vout_display_PlacePicture (&place, &vd->source, vd->cfg, false);
426 p_sys->width = place.width;
427 p_sys->height = place.height;
429 xcb_xv_adaptor_info_iterator_t it;
430 for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
432 xcb_xv_adaptor_info_next (&it))
434 const xcb_xv_adaptor_info_t *a = it.data;
437 if (adaptor_selected != -1 && adaptor_selected != adaptor_current)
439 if (!(a->type & XCB_XV_TYPE_INPUT_MASK)
440 || !(a->type & XCB_XV_TYPE_IMAGE_MASK))
443 /* Look for an image format */
446 p_sys->att = FindFormat (obj, conn, &fmt, a, &p_sys->id);
447 if (p_sys->att == NULL) /* No acceptable image formats */
451 for (unsigned i = 0; i < a->num_ports; i++)
453 xcb_xv_port_t port = a->base_id + i;
454 xcb_xv_grab_port_reply_t *gr =
455 xcb_xv_grab_port_reply (conn,
456 xcb_xv_grab_port (conn, port, XCB_CURRENT_TIME), NULL);
457 uint8_t result = gr ? gr->result : 0xff;
465 msg_Dbg (vd, "cannot grab port %"PRIu32": Xv error %"PRIu8, port,
468 continue; /* No usable port */
471 /* Found port - initialize selected format */
472 msg_Dbg (vd, "using adaptor %.*s", (int)a->name_size,
473 xcb_xv_adaptor_info_name (a));
474 msg_Dbg (vd, "using port %"PRIu32, p_sys->port);
475 msg_Dbg (vd, "using image format 0x%"PRIx32, p_sys->id);
477 /* Look for an X11 visual, create a window */
478 xcb_xv_format_t *f = xcb_xv_adaptor_info_formats (a);
479 for (uint_fast16_t i = a->num_formats; i > 0; i--, f++)
481 if (f->depth != screen->root_depth)
482 continue; /* this would fail anyway */
487 XCB_CW_BORDER_PIXMAP |
488 XCB_CW_BORDER_PIXEL |
491 const uint32_t list[] = {
492 /* XCB_CW_BACK_PIXMAP */
494 /* XCB_CW_BACK_PIXEL */
496 /* XCB_CW_BORDER_PIXMAP */
498 /* XCB_CW_BORDER_PIXEL */
500 /* XCB_CW_EVENT_MASK */
501 XCB_EVENT_MASK_VISIBILITY_CHANGE,
502 /* XCB_CW_COLORMAP */
503 screen->default_colormap,
507 xcb_create_pixmap (conn, f->depth, pixmap, screen->root, 1, 1);
508 c = xcb_create_window_checked (conn, f->depth, p_sys->window,
509 p_sys->embed->handle.xid, place.x, place.y,
510 place.width, place.height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
511 f->visual, mask, list);
512 xcb_map_window (conn, p_sys->window);
514 if (!XCB_error_Check (vd, conn, "cannot create X11 window", c))
516 msg_Dbg (vd, "using X11 visual ID 0x%"PRIx32
517 " (depth: %"PRIu8")", f->visual, f->depth);
518 msg_Dbg (vd, "using X11 window 0x%08"PRIx32, p_sys->window);
522 xcb_xv_ungrab_port (conn, p_sys->port, XCB_CURRENT_TIME);
524 msg_Dbg (vd, "no usable X11 visual");
525 continue; /* No workable XVideo format (visual/depth) */
533 msg_Err (vd, "no available XVideo adaptor");
537 /* Create graphic context */
538 p_sys->gc = xcb_generate_id (conn);
539 xcb_create_gc (conn, p_sys->gc, p_sys->window, 0, NULL);
540 msg_Dbg (vd, "using X11 graphic context 0x%08"PRIx32, p_sys->gc);
542 /* Disable color keying if applicable */
544 xcb_intern_atom_reply_t *r =
545 xcb_intern_atom_reply (conn,
546 xcb_intern_atom (conn, 1, 21, "XV_AUTOPAINT_COLORKEY"), NULL);
547 if (r != NULL && r->atom != 0)
548 xcb_xv_set_port_attribute(conn, p_sys->port, r->atom, 1);
553 p_sys->cursor = XCB_cursor_Create (conn, screen);
555 p_sys->shm = XCB_shm_Check (obj, conn);
556 p_sys->visible = false;
559 vout_display_info_t info = vd->info;
560 info.has_pictures_invalid = false;
561 info.has_event_thread = true;
563 /* Setup vout_display_t once everything is fine */
564 p_sys->swap_uv = vlc_fourcc_AreUVPlanesSwapped (fmt.i_chroma,
567 fmt.i_chroma = vd->fmt.i_chroma;
573 vd->display = Display;
574 vd->control = Control;
578 bool is_fullscreen = vd->cfg->is_fullscreen;
579 if (is_fullscreen && vout_window_SetFullScreen (p_sys->embed, true))
580 is_fullscreen = false;
581 vout_display_SendEventFullscreen (vd, is_fullscreen);
582 vout_display_SendEventDisplaySize (vd, width, height, is_fullscreen);
593 * Disconnect from the X server.
595 static void Close (vlc_object_t *obj)
597 vout_display_t *vd = (vout_display_t *)obj;
598 vout_display_sys_t *p_sys = vd->sys;
601 picture_pool_Delete (p_sys->pool);
603 /* show the default cursor */
604 xcb_change_window_attributes (p_sys->conn, p_sys->embed->handle.xid, XCB_CW_CURSOR,
605 &(uint32_t) { XCB_CURSOR_NONE });
606 xcb_flush (p_sys->conn);
609 xcb_disconnect (p_sys->conn);
610 vout_display_DeleteWindow (vd, p_sys->embed);
614 static void PoolAlloc (vout_display_t *vd, unsigned requested_count)
616 vout_display_sys_t *p_sys = vd->sys;
618 const uint32_t *pitches= xcb_xv_query_image_attributes_pitches (p_sys->att);
619 const uint32_t *offsets= xcb_xv_query_image_attributes_offsets (p_sys->att);
620 const unsigned num_planes= __MIN(p_sys->att->num_planes, PICTURE_PLANE_MAX);
621 p_sys->data_size = p_sys->att->data_size;
623 picture_resource_t res = { NULL };
624 for (unsigned i = 0; i < num_planes; i++)
627 data_size = (i < num_planes - 1) ? offsets[i+1] : p_sys->data_size;
629 res.p[i].i_lines = (data_size - offsets[i]) / pitches[i];
630 res.p[i].i_pitch = pitches[i];
633 picture_t *pic_array[MAX_PICTURES];
634 requested_count = __MIN(requested_count, MAX_PICTURES);
637 for (count = 0; count < requested_count; count++)
639 xcb_shm_seg_t seg = p_sys->shm ? xcb_generate_id (p_sys->conn) : 0;
641 if (XCB_picture_Alloc (vd, &res, p_sys->data_size, p_sys->conn, seg))
644 /* Allocate further planes as specified by XVideo */
645 /* We assume that offsets[0] is zero */
646 for (unsigned i = 1; i < num_planes; i++)
647 res.p[i].p_pixels = res.p[0].p_pixels + offsets[i];
650 { /* YVU: swap U and V planes */
651 uint8_t *buf = res.p[2].p_pixels;
652 res.p[2].p_pixels = res.p[1].p_pixels;
653 res.p[1].p_pixels = buf;
656 pic_array[count] = XCB_picture_NewFromResource (&vd->fmt, &res);
657 if (unlikely(pic_array[count] == NULL))
664 p_sys->pool = picture_pool_New (count, pic_array);
665 /* TODO release picture resources if NULL */
666 xcb_flush (p_sys->conn);
670 * Return a direct buffer
672 static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
674 vout_display_sys_t *p_sys = vd->sys;
677 PoolAlloc (vd, requested_count);
683 * Sends an image to the X server.
685 static void Display (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
687 vout_display_sys_t *p_sys = vd->sys;
688 xcb_shm_seg_t segment = XCB_picture_GetSegment(pic);
689 xcb_void_cookie_t ck;
694 ck = xcb_xv_shm_put_image_checked (p_sys->conn, p_sys->port,
695 p_sys->window, p_sys->gc, segment, p_sys->id, 0,
696 /* Src: */ vd->source.i_x_offset,
697 vd->source.i_y_offset,
698 vd->source.i_visible_width,
699 vd->source.i_visible_height,
700 /* Dst: */ 0, 0, p_sys->width, p_sys->height,
701 /* Memory: */ pic->p->i_pitch / pic->p->i_pixel_pitch,
702 pic->p->i_lines, false);
704 ck = xcb_xv_put_image_checked (p_sys->conn, p_sys->port, p_sys->window,
705 p_sys->gc, p_sys->id,
706 vd->source.i_x_offset,
707 vd->source.i_y_offset,
708 vd->source.i_visible_width,
709 vd->source.i_visible_height,
710 0, 0, p_sys->width, p_sys->height,
711 pic->p->i_pitch / pic->p->i_pixel_pitch,
713 p_sys->data_size, pic->p->p_pixels);
715 /* Wait for reply. See x11.c for rationale. */
716 xcb_generic_error_t *e = xcb_request_check (p_sys->conn, ck);
719 msg_Dbg (vd, "%s: X11 error %d", "cannot put image", e->error_code);
723 picture_Release (pic);
727 static int Control (vout_display_t *vd, int query, va_list ap)
729 vout_display_sys_t *p_sys = vd->sys;
733 case VOUT_DISPLAY_CHANGE_FULLSCREEN:
735 const vout_display_cfg_t *c = va_arg (ap, const vout_display_cfg_t *);
736 return vout_window_SetFullScreen (p_sys->embed, c->is_fullscreen);
739 case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
740 case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
741 case VOUT_DISPLAY_CHANGE_ZOOM:
742 case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
743 case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
745 const vout_display_cfg_t *cfg;
746 const video_format_t *source;
748 if (query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT
749 || query == VOUT_DISPLAY_CHANGE_SOURCE_CROP)
751 source = (const video_format_t *)va_arg (ap, const video_format_t *);
756 source = &vd->source;
757 cfg = (const vout_display_cfg_t*)va_arg (ap, const vout_display_cfg_t *);
760 if (query == VOUT_DISPLAY_CHANGE_DISPLAY_SIZE && va_arg (ap, int))
762 vout_window_SetSize (p_sys->embed,
763 cfg->display.width, cfg->display.height);
764 return VLC_EGENERIC; /* Always fail. See x11.c for rationale. */
767 vout_display_place_t place;
768 vout_display_PlacePicture (&place, source, cfg, false);
769 p_sys->width = place.width;
770 p_sys->height = place.height;
772 /* Move the picture within the window */
773 const uint32_t values[] = { place.x, place.y,
774 place.width, place.height, };
775 xcb_configure_window (p_sys->conn, p_sys->window,
776 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y
777 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
779 xcb_flush (p_sys->conn);
782 case VOUT_DISPLAY_CHANGE_WINDOW_STATE:
784 unsigned state = va_arg (ap, unsigned);
785 return vout_window_SetState (p_sys->embed, state);
788 /* Hide the mouse. It will be send when
789 * vout_display_t::info.b_hide_mouse is false */
790 case VOUT_DISPLAY_HIDE_MOUSE:
791 xcb_change_window_attributes (p_sys->conn, p_sys->embed->handle.xid,
792 XCB_CW_CURSOR, &(uint32_t){ p_sys->cursor });
793 xcb_flush (p_sys->conn);
795 case VOUT_DISPLAY_RESET_PICTURES:
798 msg_Err (vd, "Unknown request in XCB vout display");
803 static void Manage (vout_display_t *vd)
805 vout_display_sys_t *p_sys = vd->sys;
807 XCB_Manage (vd, p_sys->conn, &p_sys->visible);
810 static int EnumAdaptors (vlc_object_t *obj, const char *var,
811 int64_t **vp, char ***tp)
816 char *display = var_InheritString (obj, "x11-display");
817 xcb_connection_t *conn;
820 conn = xcb_connect (display, &snum);
822 if (xcb_connection_has_error (conn) /*== NULL*/)
825 /* Find configured screen */
826 const xcb_setup_t *setup = xcb_get_setup (conn);
827 const xcb_screen_t *scr = NULL;
828 for (xcb_screen_iterator_t i = xcb_setup_roots_iterator (setup);
829 i.rem > 0; xcb_screen_next (&i))
841 xcb_xv_query_adaptors_reply_t *adaptors =
842 xcb_xv_query_adaptors_reply (conn,
843 xcb_xv_query_adaptors (conn, scr->root), NULL);
844 if (adaptors == NULL)
847 xcb_xv_adaptor_info_iterator_t it;
849 for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
851 xcb_xv_adaptor_info_next (&it))
854 int64_t *values = xmalloc ((n + 1) * sizeof (*values));
855 char **texts = xmalloc ((n + 1) * sizeof (*texts));
861 *(texts++) = strdup (N_("Auto"));
864 for (it = xcb_xv_query_adaptors_info_iterator (adaptors);
866 xcb_xv_adaptor_info_next (&it))
868 const xcb_xv_adaptor_info_t *a = it.data;
872 if (!(a->type & XCB_XV_TYPE_INPUT_MASK)
873 || !(a->type & XCB_XV_TYPE_IMAGE_MASK))
877 *(texts++) = strndup (xcb_xv_adaptor_info_name (a), a->name_size);
881 xcb_disconnect (conn);
882 (void) obj; (void) var;