From d8a85e37931ce571f67eb704f8bf49abfe5c822a Mon Sep 17 00:00:00 2001 From: sergey radionov Date: Tue, 11 Feb 2025 11:52:05 +0700 Subject: [PATCH] v4l2: bufferpool: update buffer state after group release This fixes the state that lead to a flood of "newly allocated buffer %u is not free" warnings. Fixes #1185 #3184 #4037 Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c index 55ae3d8607..fc2d4bbe04 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c @@ -778,6 +778,17 @@ gst_v4l2_buffer_pool_streamoff (GstV4l2BufferPool * pool) } } +static void +gst_v4l2_buffer_pool_group_released (GstV4l2BufferPool * pool, + GstV4l2MemoryGroup * group) +{ + gint index = group->buffer.index; + + g_atomic_int_set (&pool->buffer_state[index], BUFFER_STATE_FREE); + + gst_v4l2_buffer_pool_resurrect_buffer (pool); +} + static gboolean gst_v4l2_buffer_pool_start (GstBufferPool * bpool) { @@ -941,7 +952,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool) pool->group_released_handler = g_signal_connect_swapped (pool->vallocator, "group-released", - G_CALLBACK (gst_v4l2_buffer_pool_resurrect_buffer), pool); + G_CALLBACK (gst_v4l2_buffer_pool_group_released), pool); ret = gst_v4l2_buffer_pool_streamon (pool); }