v4l2: Keep ref to element in allocator/pool

Removes the FIXME/Question in the buffer pool and add a ref to the
element in the GstAllocator too. This ref is strictly required to keep
the GstV4l2Object structure around.
This commit is contained in:
Nicolas Dufresne 2017-07-24 16:13:56 -04:00
parent 33f508d508
commit 2ee90e2b39
2 changed files with 5 additions and 2 deletions

View file

@ -426,6 +426,7 @@ gst_v4l2_allocator_finalize (GObject * obj)
GST_LOG_OBJECT (obj, "called"); GST_LOG_OBJECT (obj, "called");
gst_atomic_queue_unref (allocator->free_queue); gst_atomic_queue_unref (allocator->free_queue);
gst_object_unref (allocator->obj->element);
G_OBJECT_CLASS (parent_class)->finalize (obj); G_OBJECT_CLASS (parent_class)->finalize (obj);
} }
@ -648,6 +649,9 @@ gst_v4l2_allocator_new (GstObject * parent, GstV4l2Object * v4l2object)
/* Save everything */ /* Save everything */
allocator->obj = v4l2object; allocator->obj = v4l2object;
/* Keep a ref on the elemnt so obj does not disapear */
gst_object_ref (allocator->obj->element);
flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, MMAP); flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, MMAP);
flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, USERPTR); flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, USERPTR);
flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, DMABUF); flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, DMABUF);

View file

@ -1521,8 +1521,7 @@ gst_v4l2_buffer_pool_finalize (GObject * object)
gst_poll_free (pool->poll); gst_poll_free (pool->poll);
/* FIXME Is this required to keep around ? /* This can't be done in dispose method because we must not set pointer
* This can't be done in dispose method because we must not set pointer
* to NULL as it is part of the v4l2object and dispose could be called * to NULL as it is part of the v4l2object and dispose could be called
* multiple times */ * multiple times */
gst_object_unref (pool->obj->element); gst_object_unref (pool->obj->element);