From 23c6053b947f72962aec98f77da37b72d54fad9f Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 23 Jan 2013 10:10:35 +0100 Subject: [PATCH] wayland: fix frame_redraw callback. The redraw callback needs to be attached to the surface prior to the commit. Otherwise, the callback notifies the next surface repaint, which is not the desired behaviour. i.e. we want to be notified for the surface we have just filled. Another isse was the redraw_pending was reset before the actual completion of the frame redraw callback function, thus causing concurrency issues. e.g. the callback could have been called again, but with a NULL buffer. --- gst-libs/gst/vaapi/gstvaapiwindow_wayland.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c index c22c678793..850dae40f4 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c @@ -208,10 +208,10 @@ frame_redraw_callback(void *data, struct wl_callback *callback, uint32_t time) { GstVaapiWindowWaylandPrivate * const priv = data; - priv->redraw_pending = FALSE; wl_buffer_destroy(priv->buffer); priv->buffer = NULL; wl_callback_destroy(callback); + priv->redraw_pending = FALSE; } static const struct wl_callback_listener frame_callback_listener = { @@ -292,14 +292,13 @@ gst_vaapi_window_wayland_render( priv->opaque_region = NULL; } - wl_surface_commit(priv->surface); - - wl_display_flush(wl_display); priv->redraw_pending = TRUE; priv->buffer = buffer; - callback = wl_surface_frame(priv->surface); wl_callback_add_listener(callback, &frame_callback_listener, priv); + + wl_surface_commit(priv->surface); + wl_display_flush(wl_display); GST_VAAPI_OBJECT_UNLOCK_DISPLAY(window); return TRUE; }