From 06639dd72748e24822dab453a97a8fa3902adc6d Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Thu, 29 May 2014 12:27:46 +0300 Subject: [PATCH] waylandsink: remove the manual synchronization from pause/resume_rendering and use subsurface sync/desync Previously, in order to change the surface size we had to let the pipeline redraw it, which at first also involved re-negotiating caps, etc, so a synchronization with the pipeline was absolutely necessary. At the moment, we are using wl_viewport, which separates the surface size from the buffer size and it also allows us to commit a surface resize without attaching a new buffer, so it is enough to just do: gst_wayland_video_pause_rendering(): wl_subsurface_set_sync() gst_video_overlay_set_render_rectangle(): wl_subsurface_set_position() wl_viewport_set_destination() wl_surface_damage() wl_surface_commit() ... commit the parent surface ... gst_wayland_video_resume_rendering(): wl_subsurface_set_desync() This is enough to synchronize a surface resize and the pipeline can continue drawing independently. Now of course, the names pause/resume_rendering are bad. I will rename them in another commit. --- ext/wayland/gstwaylandsink.c | 34 ++++++++++++---------------------- ext/wayland/gstwaylandsink.h | 3 --- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index e2e412cd51..ecba7f0062 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -164,7 +164,6 @@ gst_wayland_sink_init (GstWaylandSink * sink) { g_mutex_init (&sink->display_lock); g_mutex_init (&sink->render_lock); - g_cond_init (&sink->render_cond); } static void @@ -230,7 +229,6 @@ gst_wayland_sink_finalize (GObject * object) g_mutex_clear (&sink->display_lock); g_mutex_clear (&sink->render_lock); - g_cond_clear (&sink->render_cond); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -665,10 +663,6 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) GST_LOG_OBJECT (sink, "render buffer %p", buffer); - /* surface is resizing - drop buffers until finished */ - if (sink->drawing_frozen) - goto done; - /* drop buffers until we get a frame callback */ if (g_atomic_int_get (&sink->redraw_pending) == TRUE) goto done; @@ -711,10 +705,6 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) gst_buffer_replace (&sink->last_buffer, to_render); render_last_buffer (sink); - /* notify _resume_rendering() in case it's waiting */ - sink->rendered = TRUE; - g_cond_broadcast (&sink->render_cond); - if (buffer != to_render) gst_buffer_unref (to_render); goto done; @@ -851,7 +841,13 @@ gst_wayland_sink_pause_rendering (GstWaylandVideo * video) g_return_if_fail (sink != NULL); g_mutex_lock (&sink->render_lock); - sink->drawing_frozen = TRUE; + if (!sink->window || !sink->window->subsurface) { + g_mutex_unlock (&sink->render_lock); + GST_INFO_OBJECT (sink, "pause_rendering called without window, ignoring"); + return; + } + + wl_subsurface_set_sync (sink->window->subsurface); g_mutex_unlock (&sink->render_lock); } @@ -864,19 +860,13 @@ gst_wayland_sink_resume_rendering (GstWaylandVideo * video) GST_DEBUG_OBJECT (sink, "resuming rendering"); g_mutex_lock (&sink->render_lock); - sink->drawing_frozen = FALSE; - - if (GST_STATE (sink) == GST_STATE_PLAYING) { - sink->rendered = FALSE; - while (sink->rendered == FALSE) - g_cond_wait (&sink->render_cond, &sink->render_lock); - GST_DEBUG_OBJECT (sink, "synchronized with render()"); - } else if (sink->window && sink->last_buffer && - g_atomic_int_get (&sink->redraw_pending) == FALSE) { - render_last_buffer (sink); - GST_DEBUG_OBJECT (sink, "last buffer redrawn"); + if (!sink->window || !sink->window->subsurface) { + g_mutex_unlock (&sink->render_lock); + GST_INFO_OBJECT (sink, "resume_rendering called without window, ignoring"); + return; } + wl_subsurface_set_desync (sink->window->subsurface); g_mutex_unlock (&sink->render_lock); } diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h index 1280f746be..85265e8da4 100644 --- a/ext/wayland/gstwaylandsink.h +++ b/ext/wayland/gstwaylandsink.h @@ -63,10 +63,7 @@ struct _GstWaylandSink gchar *display_name; gboolean redraw_pending; - gboolean drawing_frozen; - gboolean rendered; GMutex render_lock; - GCond render_cond; GstBuffer *last_buffer; };