pad: Reset not-linked last flow return on reconfigure events upstream/main
authorSebastian Dröge <sebastian@centricular.com>
Tue, 31 Dec 2024 08:50:58 +0000 (10:50 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 2 Jan 2025 16:23:19 +0000 (16:23 +0000)
The pad might actually be linked now and we'd only find out by actually pushing
a buffer downstream again.

The last flow return is used by GstFlowCombiner to detect if all pads are not
linked, and not resetting this when re-linking creates a race condition when
switching between pads where all pads are temporarily considered not linked.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3836

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

subprojects/gstreamer/gst/gstpad.c

index 1df2fdc6231bc6df95d310a0f29d1754b14bb8b2..c4dbce6db117a6b6ce8d17b523083fc249b8c310 100644 (file)
@@ -5597,6 +5597,8 @@ gst_pad_push_event_unchecked (GstPad * pad, GstEvent * event,
         case GST_EVENT_RECONFIGURE:
           if (GST_PAD_IS_SINK (pad))
             GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE);
+          if (pad->ABI.abi.last_flowret == GST_FLOW_NOT_LINKED)
+            pad->ABI.abi.last_flowret = GST_FLOW_OK;
           break;
         default:
           break;
@@ -5948,9 +5950,6 @@ gst_pad_send_event_unchecked (GstPad * pad, GstEvent * event,
       if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
         goto flushing;
       break;
-    case GST_EVENT_RECONFIGURE:
-      if (GST_PAD_IS_SRC (pad))
-        GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE);
     default:
       GST_CAT_DEBUG_OBJECT (GST_CAT_EVENT, pad,
           "have event type %" GST_PTR_FORMAT, event);
@@ -5978,6 +5977,12 @@ gst_pad_send_event_unchecked (GstPad * pad, GstEvent * event,
           remove_event_by_type (pad, GST_EVENT_TAG);
           GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_EOS);
           break;
+        case GST_EVENT_RECONFIGURE:
+          if (GST_PAD_IS_SRC (pad))
+            GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_NEED_RECONFIGURE);
+          if (pad->ABI.abi.last_flowret == GST_FLOW_NOT_LINKED)
+            pad->ABI.abi.last_flowret = GST_FLOW_OK;
+          break;
         default:
           if (serialized) {
             /* Take the stream lock to check the EOS status and drop the event