}
GST_MINI_OBJECT_CAST (mem)->dispose = NULL;
+ /* when mem are pushed available queue its allocator is unref,
+ * then now it is required to ref the allocator here because
+ * memory's finalize will unref it again */
+ gst_object_ref (mem->allocator);
gst_memory_unref (mem);
}
}
{
GstVaDmabufAllocator *self = GST_VA_DMABUF_ALLOCATOR (object);
+ gst_atomic_queue_unref (self->available_mems);
+ gst_clear_object (&self->display);
g_cond_clear (&self->buffer_cond);
G_OBJECT_CLASS (dmabuf_parent_class)->finalize (object);
if (self->surface_count != 0)
GST_WARNING_OBJECT (self, "Surfaces leaked: %d", self->surface_count);
- gst_atomic_queue_unref (self->available_mems);
-
- gst_clear_object (&self->display);
-
G_OBJECT_CLASS (dmabuf_parent_class)->dispose (object);
}
GST_OBJECT_UNLOCK (self);
+ /* Keep last in case we are holding on the last allocator ref */
+ gst_object_unref (mem->allocator);
/* don't call mini_object's free */
return FALSE;
GST_OBJECT_UNLOCK (self);
/* append them in reverse order */
- for (j = idx - 1; j >= 0; j--)
+ for (j = idx - 1; j >= 0; j--) {
+ gst_object_ref (mem[j]->allocator);
gst_buffer_append_memory (buffer, mem[j]);
+ }
GST_TRACE_OBJECT (self, "Prepared surface %#x in buffer %p", surface, buffer);
{
GstVaAllocator *self = GST_VA_ALLOCATOR (object);
+ gst_atomic_queue_unref (self->available_mems);
+ gst_clear_object (&self->display);
+ g_clear_pointer (&self->surface_formats, g_array_unref);
g_cond_clear (&self->buffer_cond);
G_OBJECT_CLASS (gst_va_allocator_parent_class)->finalize (object);
if (self->surface_count != 0)
GST_WARNING_OBJECT (self, "Surfaces leaked: %d", self->surface_count);
- gst_atomic_queue_unref (self->available_mems);
-
- gst_clear_object (&self->display);
- g_clear_pointer (&self->surface_formats, g_array_unref);
-
G_OBJECT_CLASS (gst_va_allocator_parent_class)->dispose (object);
}
GST_OBJECT_UNLOCK (self);
+ /* Keep last in case we are holding on the last allocator ref */
+ gst_object_unref (mem->allocator);
+
/* don't call mini_object's free */
return FALSE;
}
mem = gst_atomic_queue_pop (self->available_mems);
GST_OBJECT_UNLOCK (self);
+ gst_object_ref (mem->allocator);
surface = gst_va_memory_get_surface (mem);
gst_buffer_append_memory (buffer, mem);