Problem with GstQueryAllocation pool refcount
Edgar Thier
edgar.thier at theimagingsource.com
Tue Dec 6 09:31:19 UTC 2022
Hi,
I am encountering a problem with the reference count for my custom GstBufferPool.
What I am observing is that GstQuery increases the reference count but never seems to unref it.
My allocation function looks like this (simplified):
gboolean _device_allocation(GstBaseSrc* base_src, GstQuery* query)
{
// my_buffer_pool_new does:
// GstTcamBufferPool* pool =
// (GstTcamBufferPool*)g_object_new(GST_TYPE_MY_BUFFER_POOL, "name", name, NULL);
// g_object_ref_sink(pool);
GstBufferPool* pool = my_buffer_pool_new(GST_ELEMENT(self), caps);
GST_ERROR("Refcount: %d", pool->object.object.ref_count);
// Refcount: 1
GstStructure* config = gst_buffer_pool_get_config(pool);
gst_buffer_pool_config_set_params(config, caps, buffer_size, 10, 10);
gst_buffer_pool_set_config(pool, config);
gst_query_add_allocation_pool(query, pool, size, 10, 0);
GST_ERROR("Refcount: %d", pool->object.object.ref_count);
// Refcount: 2
// store pool pointer for later cleanup
...
return GST_BASE_SRC_CLASS(gst_tcam_mainsrc_parent_class)->decide_allocation(base_src, query);
}
It remains at two even when I reach state change paused->ready where I want to reset the pool:
_change_state(GstElement* element,
GstStateChange change)
{
....
case GST_STATE_CHANGE_PAUSED_TO_READY:
{
GstBufferPool* pool = ...;
if (pool)
{
gst_buffer_pool_set_active(pool, FALSE);
GST_ERROR("Freeing pool %d", pool->object.object.ref_count);
// Refcount: 2
gst_object_unref(pool);
pool = NULL;
// BufferPool not freed
}
...
Am I doing something wrong?
Do I need to execute additional steps or is this a bug with GstQuery?
Thanks,
Edgar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20221206/6dbab252/attachment-0001.htm>
More information about the gstreamer-devel
mailing list