streamsynchronizer: check reset-time when handling FLUSH_STOP
authorGuillaume Desmottes <guillaume.desmottes@onestream.live>
Wed, 31 May 2023 14:26:45 +0000 (16:26 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 1 Jun 2023 11:15:00 +0000 (11:15 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4755>

subprojects/gst-plugins-base/gst/playback/gststreamsynchronizer.c

index 4c3786b..08e5cc2 100644 (file)
@@ -581,12 +581,19 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
       GstSyncStream *stream;
       GList *l;
       GstClockTime new_group_start_time = 0;
+      gboolean reset_time;
+
+      gst_event_parse_flush_stop (event, &reset_time);
 
       GST_STREAM_SYNCHRONIZER_LOCK (self);
+
       stream = gst_streamsync_pad_get_stream (pad);
-      GST_DEBUG_OBJECT (pad, "Resetting segment for stream %d",
-          stream->stream_number);
-      gst_segment_init (&stream->segment, GST_FORMAT_UNDEFINED);
+
+      if (reset_time) {
+        GST_DEBUG_OBJECT (pad, "Resetting segment for stream %d",
+            stream->stream_number);
+        gst_segment_init (&stream->segment, GST_FORMAT_UNDEFINED);
+      }
 
       stream->is_eos = FALSE;
       stream->eos_sent = FALSE;
@@ -594,32 +601,35 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
       stream->wait = FALSE;
       g_cond_broadcast (&stream->stream_finish_cond);
 
-      for (l = self->streams; l; l = l->next) {
-        GstSyncStream *ostream = l->data;
-        GstClockTime start_running_time;
+      if (reset_time) {
+        for (l = self->streams; l; l = l->next) {
+          GstSyncStream *ostream = l->data;
+          GstClockTime start_running_time;
 
-        if (ostream == stream || ostream->flushing)
-          continue;
+          if (ostream == stream || ostream->flushing)
+            continue;
 
-        if (ostream->segment.format == GST_FORMAT_TIME) {
-          if (ostream->segment.rate > 0)
-            start_running_time =
-                gst_segment_to_running_time (&ostream->segment,
-                GST_FORMAT_TIME, ostream->segment.start);
-          else
-            start_running_time =
-                gst_segment_to_running_time (&ostream->segment,
-                GST_FORMAT_TIME, ostream->segment.stop);
+          if (ostream->segment.format == GST_FORMAT_TIME) {
+            if (ostream->segment.rate > 0)
+              start_running_time =
+                  gst_segment_to_running_time (&ostream->segment,
+                  GST_FORMAT_TIME, ostream->segment.start);
+            else
+              start_running_time =
+                  gst_segment_to_running_time (&ostream->segment,
+                  GST_FORMAT_TIME, ostream->segment.stop);
 
-          new_group_start_time = MAX (new_group_start_time, start_running_time);
+            new_group_start_time =
+                MAX (new_group_start_time, start_running_time);
+          }
         }
-      }
 
-      GST_DEBUG_OBJECT (pad,
-          "Updating group start time from %" GST_TIME_FORMAT " to %"
-          GST_TIME_FORMAT, GST_TIME_ARGS (self->group_start_time),
-          GST_TIME_ARGS (new_group_start_time));
-      self->group_start_time = new_group_start_time;
+        GST_DEBUG_OBJECT (pad,
+            "Updating group start time from %" GST_TIME_FORMAT " to %"
+            GST_TIME_FORMAT, GST_TIME_ARGS (self->group_start_time),
+            GST_TIME_ARGS (new_group_start_time));
+        self->group_start_time = new_group_start_time;
+      }
 
       gst_syncstream_unref (stream);
       GST_STREAM_SYNCHRONIZER_UNLOCK (self);