mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 15:36:42 +00:00
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:
parent
0948ce0478
commit
dfc20013cc
2 changed files with 38 additions and 0 deletions
|
@ -938,6 +938,9 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
|
||||||
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
|
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
|
if (pool->orphaned)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (pool, "stopping pool");
|
GST_DEBUG_OBJECT (pool, "stopping pool");
|
||||||
|
|
||||||
if (pool->group_released_handler > 0) {
|
if (pool->group_released_handler > 0) {
|
||||||
|
@ -970,6 +973,36 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
|
||||||
return ret;
|
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
|
static void
|
||||||
gst_v4l2_buffer_pool_flush_start (GstBufferPool * bpool)
|
gst_v4l2_buffer_pool_flush_start (GstBufferPool * bpool)
|
||||||
{
|
{
|
||||||
|
@ -1564,6 +1597,7 @@ gst_v4l2_buffer_pool_init (GstV4l2BufferPool * pool)
|
||||||
pool->can_poll_device = TRUE;
|
pool->can_poll_device = TRUE;
|
||||||
g_cond_init (&pool->empty_cond);
|
g_cond_init (&pool->empty_cond);
|
||||||
pool->empty = TRUE;
|
pool->empty = TRUE;
|
||||||
|
pool->orphaned = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -64,6 +64,8 @@ struct _GstV4l2BufferPool
|
||||||
gboolean empty;
|
gboolean empty;
|
||||||
GCond empty_cond;
|
GCond empty_cond;
|
||||||
|
|
||||||
|
gboolean orphaned;
|
||||||
|
|
||||||
GstV4l2Allocator *vallocator;
|
GstV4l2Allocator *vallocator;
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
GstAllocationParams params;
|
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_flush (GstBufferPool *pool);
|
||||||
|
|
||||||
|
gboolean gst_v4l2_buffer_pool_orphan (GstBufferPool ** pool);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /*__GST_V4L2_BUFFER_POOL_H__ */
|
#endif /*__GST_V4L2_BUFFER_POOL_H__ */
|
||||||
|
|
Loading…
Reference in a new issue