From 0c151f6bb27b3261a0a813720bbcb1fa9e9c7279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 20 Sep 2016 15:12:22 -0400 Subject: [PATCH] streamsynchronizer: Correctly calculate group start times in reverse playback mode We have to calculate from the segment.stop, not the segment.start, as playback goes from stop to start. This fix works around another race condition in streamsynchronizer in my testcase. See https://bugzilla.gnome.org/show_bug.cgi?id=771479 --- gst/playback/gststreamsynchronizer.c | 36 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c index b26ee70409..ac77266ba5 100644 --- a/gst/playback/gststreamsynchronizer.c +++ b/gst/playback/gststreamsynchronizer.c @@ -373,18 +373,31 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent, ostream->wait = FALSE; if (ostream->segment.format == GST_FORMAT_TIME) { - stop_running_time = - gst_segment_to_running_time (&ostream->segment, - GST_FORMAT_TIME, ostream->segment.stop); + if (ostream->segment.rate > 0) + stop_running_time = + gst_segment_to_running_time (&ostream->segment, + GST_FORMAT_TIME, ostream->segment.stop); + else + stop_running_time = + gst_segment_to_running_time (&ostream->segment, + GST_FORMAT_TIME, ostream->segment.start); + position_running_time = gst_segment_to_running_time (&ostream->segment, GST_FORMAT_TIME, ostream->segment.position); position_running_time = MAX (position_running_time, stop_running_time); - position_running_time -= - gst_segment_to_running_time (&ostream->segment, - GST_FORMAT_TIME, ostream->segment.start); + + if (ostream->segment.rate > 0) + position_running_time -= + gst_segment_to_running_time (&ostream->segment, + GST_FORMAT_TIME, ostream->segment.start); + else + position_running_time -= + gst_segment_to_running_time (&ostream->segment, + GST_FORMAT_TIME, ostream->segment.stop); + position_running_time = MAX (0, position_running_time); position = MAX (position, position_running_time); @@ -497,9 +510,14 @@ gst_stream_synchronizer_sink_event (GstPad * pad, GstObject * parent, continue; if (ostream->segment.format == GST_FORMAT_TIME) { - start_running_time = - gst_segment_to_running_time (&ostream->segment, - GST_FORMAT_TIME, ostream->segment.start); + 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); }