streamsynchronizer: check reset-time when handling FLUSH_STOP

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4749>
This commit is contained in:
Guillaume Desmottes 2023-05-31 16:26:45 +02:00
parent c2d8f4f729
commit b3d27da397

View file

@ -581,12 +581,19 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
GstSyncStream *stream; GstSyncStream *stream;
GList *l; GList *l;
GstClockTime new_group_start_time = 0; GstClockTime new_group_start_time = 0;
gboolean reset_time;
gst_event_parse_flush_stop (event, &reset_time);
GST_STREAM_SYNCHRONIZER_LOCK (self); GST_STREAM_SYNCHRONIZER_LOCK (self);
stream = gst_streamsync_pad_get_stream (pad); stream = gst_streamsync_pad_get_stream (pad);
if (reset_time) {
GST_DEBUG_OBJECT (pad, "Resetting segment for stream %d", GST_DEBUG_OBJECT (pad, "Resetting segment for stream %d",
stream->stream_number); stream->stream_number);
gst_segment_init (&stream->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&stream->segment, GST_FORMAT_UNDEFINED);
}
stream->is_eos = FALSE; stream->is_eos = FALSE;
stream->eos_sent = FALSE; stream->eos_sent = FALSE;
@ -594,6 +601,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
stream->wait = FALSE; stream->wait = FALSE;
g_cond_broadcast (&stream->stream_finish_cond); g_cond_broadcast (&stream->stream_finish_cond);
if (reset_time) {
for (l = self->streams; l; l = l->next) { for (l = self->streams; l; l = l->next) {
GstSyncStream *ostream = l->data; GstSyncStream *ostream = l->data;
GstClockTime start_running_time; GstClockTime start_running_time;
@ -611,7 +619,8 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
gst_segment_to_running_time (&ostream->segment, gst_segment_to_running_time (&ostream->segment,
GST_FORMAT_TIME, ostream->segment.stop); 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);
} }
} }
@ -620,6 +629,7 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent,
GST_TIME_FORMAT, GST_TIME_ARGS (self->group_start_time), GST_TIME_FORMAT, GST_TIME_ARGS (self->group_start_time),
GST_TIME_ARGS (new_group_start_time)); GST_TIME_ARGS (new_group_start_time));
self->group_start_time = new_group_start_time; self->group_start_time = new_group_start_time;
}
gst_syncstream_unref (stream); gst_syncstream_unref (stream);
GST_STREAM_SYNCHRONIZER_UNLOCK (self); GST_STREAM_SYNCHRONIZER_UNLOCK (self);