mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:06:17 +00:00
v4l2bufferpool: Fix copy threshold implementation
We cannot allocate new buffer in acquire, otherwise the base class is not aware and get confused. Instead, copy in _process(). This leads to crash on finalize. Fixes regression, see https://bugzilla.gnome.org/show_bug.cgi?id=732912
This commit is contained in:
parent
bf96c9c545
commit
d7876e5597
1 changed files with 26 additions and 24 deletions
|
@ -1171,27 +1171,6 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
|
||||||
ret = gst_v4l2_buffer_pool_dqbuf (pool, buffer);
|
ret = gst_v4l2_buffer_pool_dqbuf (pool, buffer);
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* start copying buffers when we are running low on buffers */
|
|
||||||
if (g_atomic_int_get (&pool->num_queued) < pool->copy_threshold) {
|
|
||||||
GstBuffer *copy;
|
|
||||||
|
|
||||||
if (GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, MMAP)) {
|
|
||||||
if (pclass->acquire_buffer (bpool, ©, params) == GST_FLOW_OK) {
|
|
||||||
gst_v4l2_buffer_pool_release_buffer (bpool, copy);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy the buffer */
|
|
||||||
copy = gst_buffer_copy_region (*buffer,
|
|
||||||
GST_BUFFER_COPY_ALL | GST_BUFFER_COPY_DEEP, 0, -1);
|
|
||||||
GST_LOG_OBJECT (pool, "copy buffer %p->%p", *buffer, copy);
|
|
||||||
|
|
||||||
/* and requeue so that we can continue capturing */
|
|
||||||
gst_v4l2_buffer_pool_release_buffer (bpool, *buffer);
|
|
||||||
*buffer = copy;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_V4L2_IO_USERPTR:
|
case GST_V4L2_IO_USERPTR:
|
||||||
|
@ -1580,9 +1559,32 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf)
|
||||||
if ((*buf)->pool == bpool) {
|
if ((*buf)->pool == bpool) {
|
||||||
if (gst_buffer_get_size (*buf) == 0)
|
if (gst_buffer_get_size (*buf) == 0)
|
||||||
goto eos;
|
goto eos;
|
||||||
else
|
|
||||||
/* nothing, data was inside the buffer when we did _acquire() */
|
/* start copying buffers when we are running low on buffers */
|
||||||
goto done;
|
if (g_atomic_int_get (&pool->num_queued) < pool->copy_threshold) {
|
||||||
|
GstBuffer *copy;
|
||||||
|
|
||||||
|
if (GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, MMAP)) {
|
||||||
|
|
||||||
|
if (gst_buffer_pool_acquire_buffer (bpool, ©,
|
||||||
|
NULL) == GST_FLOW_OK) {
|
||||||
|
gst_v4l2_buffer_pool_release_buffer (bpool, copy);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the buffer */
|
||||||
|
copy = gst_buffer_copy_region (*buf,
|
||||||
|
GST_BUFFER_COPY_ALL | GST_BUFFER_COPY_DEEP, 0, -1);
|
||||||
|
GST_LOG_OBJECT (pool, "copy buffer %p->%p", *buf, copy);
|
||||||
|
|
||||||
|
/* and requeue so that we can continue capturing */
|
||||||
|
gst_buffer_unref (*buf);
|
||||||
|
*buf = copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* nothing, data was inside the buffer when we did _acquire() */
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* buffer not from our pool, grab a frame and copy it into the target */
|
/* buffer not from our pool, grab a frame and copy it into the target */
|
||||||
|
|
Loading…
Reference in a new issue