mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
bufferpool: Deactivate pool and get rid of references to other objects from dispose instead of finalize
During dispose the pool will still have a reference count of 1 and all API on it can still be safely called. Subclasses will have already freed their own data before finalize is called but would nonetheless be called into again via the pool deactivation. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1661>
This commit is contained in:
parent
4345814e31
commit
f288f7043f
1 changed files with 19 additions and 3 deletions
|
@ -112,6 +112,7 @@ struct _GstBufferPoolPrivate
|
|||
GstAllocationParams params;
|
||||
};
|
||||
|
||||
static void gst_buffer_pool_dispose (GObject * object);
|
||||
static void gst_buffer_pool_finalize (GObject * object);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GstBufferPool, gst_buffer_pool, GST_TYPE_OBJECT);
|
||||
|
@ -133,6 +134,7 @@ gst_buffer_pool_class_init (GstBufferPoolClass * klass)
|
|||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
|
||||
gobject_class->dispose = gst_buffer_pool_dispose;
|
||||
gobject_class->finalize = gst_buffer_pool_finalize;
|
||||
|
||||
klass->start = default_start;
|
||||
|
@ -177,6 +179,23 @@ gst_buffer_pool_init (GstBufferPool * pool)
|
|||
GST_DEBUG_OBJECT (pool, "created");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_buffer_pool_dispose (GObject * object)
|
||||
{
|
||||
GstBufferPool *pool;
|
||||
GstBufferPoolPrivate *priv;
|
||||
|
||||
pool = GST_BUFFER_POOL_CAST (object);
|
||||
priv = pool->priv;
|
||||
|
||||
GST_DEBUG_OBJECT (pool, "%p dispose", pool);
|
||||
|
||||
gst_buffer_pool_set_active (pool, FALSE);
|
||||
gst_clear_object (&priv->allocator);
|
||||
|
||||
G_OBJECT_CLASS (gst_buffer_pool_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_buffer_pool_finalize (GObject * object)
|
||||
{
|
||||
|
@ -188,13 +207,10 @@ gst_buffer_pool_finalize (GObject * object)
|
|||
|
||||
GST_DEBUG_OBJECT (pool, "%p finalize", pool);
|
||||
|
||||
gst_buffer_pool_set_active (pool, FALSE);
|
||||
gst_atomic_queue_unref (priv->queue);
|
||||
gst_poll_free (priv->poll);
|
||||
gst_structure_free (priv->config);
|
||||
g_rec_mutex_clear (&priv->rec_lock);
|
||||
if (priv->allocator)
|
||||
gst_object_unref (priv->allocator);
|
||||
|
||||
G_OBJECT_CLASS (gst_buffer_pool_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue