waylandsink: release frame callback when destroyed

We would use a frame callback from the surface to indicate
that last buffer is rendered, but when we destroy the surface
and that callback is not back yet, it may cause the wayland event
queue crash.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1729>
This commit is contained in:
Randy Li 2020-10-29 06:13:05 +00:00 committed by GStreamer Merge Bot
parent 639fb6ac15
commit 6d8133e41e
3 changed files with 7 additions and 0 deletions

View file

@ -637,6 +637,7 @@ frame_redraw_callback (void *data, struct wl_callback *callback, uint32_t time)
g_mutex_lock (&sink->render_lock); g_mutex_lock (&sink->render_lock);
sink->redraw_pending = FALSE; sink->redraw_pending = FALSE;
sink->window->callback = NULL;
g_mutex_unlock (&sink->render_lock); g_mutex_unlock (&sink->render_lock);
wl_callback_destroy (callback); wl_callback_destroy (callback);
@ -660,6 +661,7 @@ render_last_buffer (GstWaylandSink * sink, gboolean redraw)
sink->redraw_pending = TRUE; sink->redraw_pending = TRUE;
callback = wl_surface_frame (surface); callback = wl_surface_frame (surface);
sink->window->callback = callback;
wl_callback_add_listener (callback, &frame_callback_listener, sink); wl_callback_add_listener (callback, &frame_callback_listener, sink);
if (G_UNLIKELY (sink->video_info_changed && !redraw)) { if (G_UNLIKELY (sink->video_info_changed && !redraw)) {

View file

@ -157,6 +157,9 @@ gst_wl_window_finalize (GObject * gobject)
{ {
GstWlWindow *self = GST_WL_WINDOW (gobject); GstWlWindow *self = GST_WL_WINDOW (gobject);
if (self->callback)
wl_callback_destroy (self->callback);
if (self->wl_shell_surface) if (self->wl_shell_surface)
wl_shell_surface_destroy (self->wl_shell_surface); wl_shell_surface_destroy (self->wl_shell_surface);
@ -197,6 +200,7 @@ gst_wl_window_new_internal (GstWlDisplay * display, GMutex * render_lock)
window->render_lock = render_lock; window->render_lock = render_lock;
g_cond_init (&window->configure_cond); g_cond_init (&window->configure_cond);
window->callback = NULL;
window->area_surface = wl_compositor_create_surface (display->compositor); window->area_surface = wl_compositor_create_surface (display->compositor);
window->video_surface = wl_compositor_create_surface (display->compositor); window->video_surface = wl_compositor_create_surface (display->compositor);

View file

@ -55,6 +55,7 @@ struct _GstWlWindow
struct wl_shell_surface *wl_shell_surface; struct wl_shell_surface *wl_shell_surface;
struct xdg_surface *xdg_surface; struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel; struct xdg_toplevel *xdg_toplevel;
struct wl_callback *callback;
gboolean configured; gboolean configured;
GCond configure_cond; GCond configure_cond;
GMutex configure_mutex; GMutex configure_mutex;