mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
v4l2bufferpool: Ensure we don't re-enqueue buffer during flush
This commit is contained in:
parent
01feadc2e7
commit
c7d735a596
2 changed files with 18 additions and 2 deletions
|
@ -595,6 +595,9 @@ start_streaming (GstV4l2BufferPool * pool)
|
||||||
{
|
{
|
||||||
GstV4l2Object *obj = pool->obj;
|
GstV4l2Object *obj = pool->obj;
|
||||||
|
|
||||||
|
if (pool->streaming)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
switch (obj->mode) {
|
switch (obj->mode) {
|
||||||
case GST_V4L2_IO_RW:
|
case GST_V4L2_IO_RW:
|
||||||
break;
|
break;
|
||||||
|
@ -608,9 +611,10 @@ start_streaming (GstV4l2BufferPool * pool)
|
||||||
if (!V4L2_TYPE_IS_OUTPUT (obj->type)) {
|
if (!V4L2_TYPE_IS_OUTPUT (obj->type)) {
|
||||||
GstBufferPool *bpool = GST_BUFFER_POOL (pool);
|
GstBufferPool *bpool = GST_BUFFER_POOL (pool);
|
||||||
GstBufferPoolAcquireParams params = { 0 };
|
GstBufferPoolAcquireParams params = { 0 };
|
||||||
|
gint n_to_q = pool->num_allocated - pool->num_queued;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
while (pool->num_queued < pool->num_allocated) {
|
while (n_to_q > 0) {
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
params.flags = GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT;
|
params.flags = GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT;
|
||||||
|
@ -621,7 +625,11 @@ start_streaming (GstV4l2BufferPool * pool)
|
||||||
goto requeue_failed;
|
goto requeue_failed;
|
||||||
|
|
||||||
gst_v4l2_buffer_pool_release_buffer (bpool, buf);
|
gst_v4l2_buffer_pool_release_buffer (bpool, buf);
|
||||||
|
n_to_q--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pool->num_allocated != pool->num_queued)
|
||||||
|
goto requeue_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (pool, "STREAMON");
|
GST_DEBUG_OBJECT (pool, "STREAMON");
|
||||||
|
@ -863,6 +871,8 @@ stop_streaming (GstV4l2BufferPool * pool)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool->flushing = TRUE;
|
||||||
|
|
||||||
switch (obj->mode) {
|
switch (obj->mode) {
|
||||||
case GST_V4L2_IO_RW:
|
case GST_V4L2_IO_RW:
|
||||||
break;
|
break;
|
||||||
|
@ -904,6 +914,7 @@ stop_streaming (GstV4l2BufferPool * pool)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool->flushing = FALSE;
|
||||||
pool->streaming = FALSE;
|
pool->streaming = FALSE;
|
||||||
|
|
||||||
if (pool->other_pool)
|
if (pool->other_pool)
|
||||||
|
@ -1275,7 +1286,11 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
|
||||||
case GST_V4L2_IO_USERPTR:
|
case GST_V4L2_IO_USERPTR:
|
||||||
case GST_V4L2_IO_DMABUF_IMPORT:
|
case GST_V4L2_IO_DMABUF_IMPORT:
|
||||||
{
|
{
|
||||||
if (gst_v4l2_is_buffer_valid (buffer, NULL)) {
|
if (pool->flushing) {
|
||||||
|
/* put back on outstanding list */
|
||||||
|
GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (bpool,
|
||||||
|
buffer);
|
||||||
|
} else if (gst_v4l2_is_buffer_valid (buffer, NULL)) {
|
||||||
/* queue back in the device */
|
/* queue back in the device */
|
||||||
if (pool->other_pool)
|
if (pool->other_pool)
|
||||||
gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL);
|
gst_v4l2_buffer_pool_prepare_buffer (pool, buffer, NULL);
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct _GstV4l2BufferPool
|
||||||
guint copy_threshold; /* when our pool runs lower, start handing out copies */
|
guint copy_threshold; /* when our pool runs lower, start handing out copies */
|
||||||
|
|
||||||
gboolean streaming;
|
gboolean streaming;
|
||||||
|
gboolean flushing;
|
||||||
|
|
||||||
GstBuffer *buffers[VIDEO_MAX_FRAME];
|
GstBuffer *buffers[VIDEO_MAX_FRAME];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue