From 0563a254947a4e04b77c4e00dedc7dc8f0fef70a Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Tue, 5 Sep 2023 17:56:49 +0200 Subject: [PATCH] v4l2videoenc: unconditionally activate the OUTPUT pool If the v4l2videoenc receives an QUERY_ALLOCATION, it must not propose a currently used pool, because it cannot be sure that the allocation query came from exactly the same upstream element. The QUERY_ALLOCATION will not contain the internal OUTPUT pool. The upstream element (the basesrc) detects that the newly proposed pool differs from the old pool. It deactivates the old pool and switches to the new pool. If there was a format change, a new OUTPUT buffer pool will be allocated in gst_v4l2_object_set_format_full() and the CAPTURE task will be stopped to switch the format. If there hasn't been a format change, gst_v4l2_object_set_format_full() will not be called. The old pool will be kept and reused. Without a format change, the processing task continues running. This leads to the situation that the processing task is running, but the OUTPUT buffer pool (the old pool) is deactivated. Therefore, the encoder is not able to get buffers from the OUTPUT pool and encoding cannot continue. This situation can be triggered by sending a RECONFIGURE event without a format change. Resolve this situation by ensuring that the OUTPUT buffer pool is always activated when frames arrive at the encoder. Part-of: --- subprojects/gst-plugins-good/sys/v4l2/gstv4l2videoenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videoenc.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videoenc.c index f40d9790ac..a13f414033 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videoenc.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videoenc.c @@ -780,7 +780,9 @@ gst_v4l2_video_enc_handle_frame (GstVideoEncoder * encoder, ret = self->output_flow; goto drop; } + } + { /* Ensure input internal output pool is active */ GstBufferPool *opool = gst_v4l2_object_get_buffer_pool (self->v4l2output); if (!gst_buffer_pool_is_active (opool)) { @@ -819,7 +821,9 @@ gst_v4l2_video_enc_handle_frame (GstVideoEncoder * encoder, if (opool) gst_object_unref (opool); } + } + if (task_state == GST_TASK_STOPPED || task_state == GST_TASK_PAUSED) { { GstBufferPool *cpool = gst_v4l2_object_get_buffer_pool (self->v4l2capture);