[vlc-devel] commit: XCB_x11: wait until picture is displayed ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Sep 2 18:24:35 CEST 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Sep 2 19:22:26 2009 +0300| [e7b9d1611256fc4ca6573a6b08c2f22f017429fb] | committer: Rémi Denis-Courmont
XCB_x11: wait until picture is displayed
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7b9d1611256fc4ca6573a6b08c2f22f017429fb
---
modules/video_output/xcb/x11.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index c9b4078..3c93a1b 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -389,9 +389,10 @@ static void Display (vout_display_t *vd, picture_t *pic)
{
vout_display_sys_t *p_sys = vd->sys;
xcb_shm_seg_t segment = pic->p_sys->segment;
+ xcb_void_cookie_t ck;
if (segment != 0)
- xcb_shm_put_image (p_sys->conn, p_sys->window, p_sys->gc,
+ ck = xcb_shm_put_image_checked (p_sys->conn, p_sys->window, p_sys->gc,
/* real width */ pic->p->i_pitch / pic->p->i_pixel_pitch,
/* real height */ pic->p->i_lines,
/* x */ vd->fmt.i_x_offset,
@@ -405,13 +406,23 @@ static void Display (vout_display_t *vd, picture_t *pic)
const size_t offset = vd->fmt.i_y_offset * pic->p->i_pitch;
const unsigned lines = pic->p->i_lines - vd->fmt.i_y_offset;
- xcb_put_image (p_sys->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
+ ck = xcb_put_image_checked (p_sys->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
p_sys->window, p_sys->gc,
pic->p->i_pitch / pic->p->i_pixel_pitch,
lines, -vd->fmt.i_x_offset, 0, 0, p_sys->depth,
pic->p->i_pitch * lines, pic->p->p_pixels + offset);
}
- xcb_flush (p_sys->conn);
+
+ /* Wait for reply. This makes sure that the X server gets CPU time to
+ * display the picture. xcb_flush() is *not* sufficient: especially with
+ * shared memory the PUT requests are so short that many of them can fit in
+ * X11 socket output buffer before the kernel preempts VLC. */
+ xcb_generic_error_t *e = xcb_request_check (p_sys->conn, ck);
+ if (e != NULL)
+ {
+ msg_Dbg (vd, "%s: X11 error %d", "cannot put image", e->error_code);
+ free (e);
+ }
/* FIXME might be WAY better to wait in some case (be carefull with
* VOUT_DISPLAY_RESET_PICTURES if done) + does not work with
More information about the vlc-devel
mailing list