v4l2bufferpool: support orphaning

Now that the v4l2allocator allows orphaning the V4L2 buffer queue, add
support for orphaning in the v4l2bufferpool. gst_v4l2_buffer_pool_orphan
can be used as a replacement for gst_v4l2_buffer_pool_stop, without
having to wait for buffers to be returned to the pool.
This commit is contained in:
Philipp Zabel 2019-01-24 16:12:13 +01:00 committed by Nicolas Dufresne
parent 0948ce0478
commit dfc20013cc
2 changed files with 38 additions and 0 deletions

View file

@ -938,6 +938,9 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
gboolean ret;
if (pool->orphaned)
return TRUE;
GST_DEBUG_OBJECT (pool, "stopping pool");
if (pool->group_released_handler > 0) {
@ -970,6 +973,36 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
return ret;
}
gboolean
gst_v4l2_buffer_pool_orphan (GstBufferPool ** bpool)
{
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (*bpool);
gboolean ret;
if (!GST_V4L2_ALLOCATOR_CAN_ORPHAN_BUFS (pool->vallocator))
return FALSE;
if (g_getenv ("GST_V4L2_FORCE_DRAIN"))
return FALSE;
GST_DEBUG_OBJECT (pool, "orphaning pool");
gst_buffer_pool_set_active (*bpool, FALSE);
/*
* If the buffer pool has outstanding buffers, it will not be stopped
* by the base class when set inactive. Stop it manually and mark it
* as orphaned
*/
ret = gst_v4l2_buffer_pool_stop (*bpool);
if (!ret)
gst_v4l2_allocator_orphan (pool->vallocator);
pool->orphaned = TRUE;
gst_object_unref (*bpool);
*bpool = NULL;
return ret;
}
static void
gst_v4l2_buffer_pool_flush_start (GstBufferPool * bpool)
{
@ -1564,6 +1597,7 @@ gst_v4l2_buffer_pool_init (GstV4l2BufferPool * pool)
pool->can_poll_device = TRUE;
g_cond_init (&pool->empty_cond);
pool->empty = TRUE;
pool->orphaned = FALSE;
}
static void

View file

@ -64,6 +64,8 @@ struct _GstV4l2BufferPool
gboolean empty;
GCond empty_cond;
gboolean orphaned;
GstV4l2Allocator *vallocator;
GstAllocator *allocator;
GstAllocationParams params;
@ -109,6 +111,8 @@ void gst_v4l2_buffer_pool_copy_at_threshold (GstV4l2BufferPool *
gboolean gst_v4l2_buffer_pool_flush (GstBufferPool *pool);
gboolean gst_v4l2_buffer_pool_orphan (GstBufferPool ** pool);
G_END_DECLS
#endif /*__GST_V4L2_BUFFER_POOL_H__ */