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
This commit is contained in:
Sebastian Dröge 2016-09-20 15:12:22 -04:00
parent 0ba25ad43b
commit 0c151f6bb2

View file

@ -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);
}