From a67b08cdd0204c0d9e960f7ca112503e054ce1bb Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Wed, 26 Feb 2014 16:11:29 +0200 Subject: [PATCH] waylandsink/waylandpool: ref the display instead of the sink to avoid cyclic references The reference to the sink is not really needed anyway in waylandpool, what matters basically is that the display is active as long as the pool is active, so we really want to reference the display object instead of the sink. --- ext/wayland/gstwaylandsink.c | 6 +++--- ext/wayland/waylandpool.c | 16 +++++++--------- ext/wayland/waylandpool.h | 8 ++++---- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index a4bc733..d4d89c6 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -241,7 +241,7 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) size = info.size; /* create a new pool for the new configuration */ - newpool = gst_wayland_buffer_pool_new (sink); + newpool = gst_wayland_buffer_pool_new (sink->display); if (!newpool) { GST_DEBUG_OBJECT (sink, "Failed to create new pool"); @@ -334,7 +334,7 @@ gst_wayland_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query) goto invalid_caps; GST_DEBUG_OBJECT (sink, "create new pool"); - pool = gst_wayland_buffer_pool_new (sink); + pool = gst_wayland_buffer_pool_new (sink->display); /* the normal size of a frame */ size = info.size; @@ -406,7 +406,7 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) meta = gst_buffer_get_wl_meta (buffer); - if (meta && meta->sink == sink) { + if (meta && meta->display == sink->display) { GST_LOG_OBJECT (sink, "buffer %p from our pool, writing directly", buffer); to_render = buffer; } else { diff --git a/ext/wayland/waylandpool.c b/ext/wayland/waylandpool.c index 577183b..38d201e 100644 --- a/ext/wayland/waylandpool.c +++ b/ext/wayland/waylandpool.c @@ -55,7 +55,7 @@ gst_wl_meta_api_get_type (void) static void gst_wl_meta_free (GstWlMeta * meta, GstBuffer * buffer) { - gst_object_unref (meta->sink); + g_object_unref (meta->display); munmap (meta->data, meta->size); wl_buffer_destroy (meta->wbuffer); } @@ -117,7 +117,7 @@ gst_wayland_buffer_pool_finalize (GObject * object) if (pool->wl_pool) gst_wayland_buffer_pool_stop (GST_BUFFER_POOL (pool)); - gst_object_unref (pool->sink); + g_object_unref (pool->display); G_OBJECT_CLASS (gst_wayland_buffer_pool_parent_class)->finalize (object); } @@ -201,9 +201,7 @@ gst_wayland_buffer_pool_start (GstBufferPool * pool) return FALSE; } - self->wl_pool = - wl_shm_create_pool (self->sink->display->shm, - fd, size); + self->wl_pool = wl_shm_create_pool (self->display->shm, fd, size); close (fd); self->size = size; @@ -263,7 +261,7 @@ gst_wayland_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, /* create buffer and its metadata object */ *buffer = gst_buffer_new (); meta = (GstWlMeta *) gst_buffer_add_meta (*buffer, GST_WL_META_INFO, NULL); - meta->sink = gst_object_ref (self->sink); + meta->display = g_object_ref (self->display); meta->wbuffer = wl_shm_pool_create_buffer (self->wl_pool, offset, width, height, stride, format); meta->data = data; @@ -285,13 +283,13 @@ no_buffer: } GstBufferPool * -gst_wayland_buffer_pool_new (GstWaylandSink * waylandsink) +gst_wayland_buffer_pool_new (GstWlDisplay * display) { GstWaylandBufferPool *pool; - g_return_val_if_fail (GST_IS_WAYLAND_SINK (waylandsink), NULL); + g_return_val_if_fail (GST_IS_WL_DISPLAY (display), NULL); pool = g_object_new (GST_TYPE_WAYLAND_BUFFER_POOL, NULL); - pool->sink = gst_object_ref (waylandsink); + pool->display = g_object_ref (display); return GST_BUFFER_POOL_CAST (pool); } diff --git a/ext/wayland/waylandpool.h b/ext/wayland/waylandpool.h index 2dd8534..5124e33 100644 --- a/ext/wayland/waylandpool.h +++ b/ext/wayland/waylandpool.h @@ -24,7 +24,7 @@ #include #include -#include "gstwaylandsink.h" +#include "wldisplay.h" G_BEGIN_DECLS @@ -42,7 +42,7 @@ const GstMetaInfo * gst_wl_meta_get_info (void); struct _GstWlMeta { GstMeta meta; - GstWaylandSink *sink; + GstWlDisplay *display; struct wl_buffer *wbuffer; void *data; @@ -61,7 +61,7 @@ typedef struct _GstWaylandBufferPoolClass GstWaylandBufferPoolClass; struct _GstWaylandBufferPool { GstBufferPool bufferpool; - GstWaylandSink *sink; + GstWlDisplay *display; /* external configuration */ GstVideoInfo info; @@ -80,7 +80,7 @@ struct _GstWaylandBufferPoolClass GType gst_wayland_buffer_pool_get_type (void); -GstBufferPool *gst_wayland_buffer_pool_new (GstWaylandSink * waylandsink); +GstBufferPool *gst_wayland_buffer_pool_new (GstWlDisplay * display); G_END_DECLS -- 2.7.4