v4l2: videodec: Fix stalls on empty buffer
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 18 May 2023 15:58:51 +0000 (11:58 -0400)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 18 May 2023 16:18:12 +0000 (17:18 +0100)
Drivers may signal end of sequence using an empty buffer and LAST buffer
set, or just an empty buffer on certain legacy implementation. When this
occured, we'd send GST_V4L2_FLOW_LAST_BUFFER were the code expected
GST_FLOW_EOS. Stop abusing GST_FLOW_EOS and port all the code to the new
GST_V4L2_FLOW_LAST_BUFFER.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4671>

subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c
subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c
subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c

index 48d1bb8..f04bae1 100644 (file)
@@ -1399,7 +1399,7 @@ gst_v4l2_allocator_dqbuf (GstV4l2Allocator * allocator,
 error:
   if (errno == EPIPE) {
     GST_DEBUG_OBJECT (allocator, "broken pipe signals last buffer");
-    return GST_FLOW_EOS;
+    return GST_V4L2_FLOW_LAST_BUFFER;
   }
 
   GST_ERROR_OBJECT (allocator, "failed dequeuing a %s buffer: %s",
index cb7b0d9..f6c1ba6 100644 (file)
@@ -1258,7 +1258,7 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer,
   GST_LOG_OBJECT (pool, "dequeueing a buffer");
 
   res = gst_v4l2_allocator_dqbuf (pool->vallocator, &group);
-  if (res == GST_FLOW_EOS)
+  if (res == GST_V4L2_FLOW_LAST_BUFFER)
     goto eos;
   if (res != GST_FLOW_OK)
     goto dqbuf_failed;
@@ -1408,7 +1408,7 @@ poll_failed:
   }
 eos:
   {
-    return GST_FLOW_EOS;
+    return GST_V4L2_FLOW_LAST_BUFFER;
   }
 dqbuf_failed:
   {
@@ -2165,7 +2165,7 @@ buffer_truncated:
   }
 eos:
   {
-    GST_DEBUG_OBJECT (pool, "end of stream reached");
+    GST_DEBUG_OBJECT (pool, "end of sequence reached");
     gst_buffer_unref (*buf);
     *buf = NULL;
     return GST_V4L2_FLOW_LAST_BUFFER;
index 1c1a3f4..facaf65 100644 (file)
@@ -884,7 +884,7 @@ beach:
     return;
   }
 
-  if (ret == GST_FLOW_EOS) {
+  if (ret == GST_V4L2_FLOW_LAST_BUFFER) {
     GST_VIDEO_DECODER_STREAM_LOCK (decoder);
     if (self->draining) {
       self->draining = FALSE;