mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
wayland: sync() when destroy()
Before pushing a the new frame, the render() method calls sync() to flush the pending frames. Nonetheless, the last pushed frame never gets rendered, leading to a memory leak too. This patch calls sync() in the destroy() to flush the pending frames before destroying the window. Also a is_cancelled flag is added. This flag tells to not flush the event queue again since the method failed previously or were cancelled by the user. https://bugzilla.gnome.org/show_bug.cgi?id=749078
This commit is contained in:
parent
11b9260b6c
commit
70eff01d36
1 changed files with 17 additions and 1 deletions
|
@ -109,6 +109,7 @@ struct _GstVaapiWindowWaylandPrivate
|
|||
guint is_shown:1;
|
||||
guint fullscreen_on_show:1;
|
||||
guint use_vpp:1;
|
||||
guint is_cancelled:1;
|
||||
volatile guint num_frames_pending;
|
||||
};
|
||||
|
||||
|
@ -160,6 +161,9 @@ gst_vaapi_window_wayland_sync (GstVaapiWindow * window)
|
|||
struct wl_display *const wl_display =
|
||||
GST_VAAPI_OBJECT_NATIVE_DISPLAY (window);
|
||||
|
||||
if (priv->is_cancelled)
|
||||
return FALSE;
|
||||
|
||||
if (priv->pollfd.fd < 0) {
|
||||
priv->pollfd.fd = wl_display_get_fd (wl_display);
|
||||
gst_poll_add_fd (priv->poll, &priv->pollfd);
|
||||
|
@ -182,6 +186,7 @@ gst_vaapi_window_wayland_sync (GstVaapiWindow * window)
|
|||
goto again;
|
||||
if (saved_errno == EBUSY) { /* closing */
|
||||
wl_display_cancel_read (wl_display);
|
||||
priv->is_cancelled = TRUE;
|
||||
break;
|
||||
}
|
||||
goto error;
|
||||
|
@ -195,6 +200,7 @@ gst_vaapi_window_wayland_sync (GstVaapiWindow * window)
|
|||
return TRUE;
|
||||
|
||||
error:
|
||||
priv->is_cancelled = TRUE;
|
||||
GST_ERROR ("Error on dispatching events: %s", g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -304,6 +310,9 @@ gst_vaapi_window_wayland_destroy (GstVaapiWindow * window)
|
|||
GstVaapiWindowWaylandPrivate *const priv =
|
||||
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
|
||||
|
||||
/* Wait for the last frame to complete redraw */
|
||||
gst_vaapi_window_wayland_sync (window);
|
||||
|
||||
if (priv->last_frame) {
|
||||
frame_state_free (priv->last_frame);
|
||||
priv->last_frame = NULL;
|
||||
|
@ -507,8 +516,15 @@ gst_vaapi_window_wayland_render (GstVaapiWindow * window,
|
|||
}
|
||||
|
||||
/* Wait for the previous frame to complete redraw */
|
||||
if (!gst_vaapi_window_wayland_sync (window))
|
||||
if (!gst_vaapi_window_wayland_sync (window)) {
|
||||
wl_buffer_destroy (buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->is_cancelled) {
|
||||
wl_buffer_destroy (buffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
frame = frame_state_new (window);
|
||||
if (!frame)
|
||||
|
|
Loading…
Reference in a new issue