summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2023-04-21 13:30:43 -0400
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2023-05-02 14:42:43 +0000
commita7581dc4d6c21f4c677fa594b5abab9de9ead5c1 (patch)
treecfa4cc0d19e19336f57a2f8aac930330bf6b31d9
parent3864c12548e7380c4a3a9608ca3cdfd9d4b96a0a (diff)
downloadgstreamer-a7581dc4d6c21f4c677fa594b5abab9de9ead5c1.tar.gz
v4l2: bufferpool: Don't copy buffer when flushing
Threshold handling can race with flushing operation. This can lead to avoidable buffer copies. Simply check and return the flushing status. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4525>
-rw-r--r--subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c
index 814a3a9943..7d49c80b04 100644
--- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c
+++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c
@@ -1919,8 +1919,9 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf,
/* If we have no more buffer, and can allocate it time to do so */
if (num_queued == 0) {
if (GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, MMAP)) {
+ GST_DEBUG_OBJECT (pool, "Resurrect for empty queue");
ret = gst_v4l2_buffer_pool_resurrect_buffer (pool);
- if (ret == GST_FLOW_OK)
+ if (ret == GST_FLOW_OK || ret == GST_FLOW_FLUSHING)
goto done;
}
}
@@ -1930,8 +1931,9 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer ** buf,
GstBuffer *copy;
if (GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, MMAP)) {
+ GST_DEBUG_OBJECT (pool, "Resurrect for threshold");
ret = gst_v4l2_buffer_pool_resurrect_buffer (pool);
- if (ret == GST_FLOW_OK)
+ if (ret == GST_FLOW_OK || ret == GST_FLOW_FLUSHING)
goto done;
}