mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
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.
This commit is contained in:
parent
253eafd4ef
commit
a67b08cdd0
3 changed files with 14 additions and 16 deletions
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <gst/video/video.h>
|
||||
#include <gst/video/gstvideometa.h>
|
||||
|
||||
#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
|
||||
|
||||
|
|
Loading…
Reference in a new issue