mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
segment: Allow stop == -1 in gst_segment_to_running_time() and rate < 0
If a segment has stop == -1, then gst_segment_to_running_time() would refuse to calculate a running time for negative rates, but gst_segment_do_seek() allows this scenario and uses a valid duration for calculations. Make the 2 functions consistent by using any configured duration to calculate a running time too in that case. https://bugzilla.gnome.org/show_bug.cgi?id=796559
This commit is contained in:
parent
5d115a5d64
commit
80015d69a7
2 changed files with 18 additions and 0 deletions
|
@ -758,6 +758,9 @@ gst_segment_to_running_time_full (const GstSegment * segment, GstFormat format,
|
||||||
} else {
|
} else {
|
||||||
stop = segment->stop;
|
stop = segment->stop;
|
||||||
|
|
||||||
|
if (stop == -1 && segment->duration != -1)
|
||||||
|
stop = segment->start + segment->duration;
|
||||||
|
|
||||||
/* cannot continue if no stop position set or invalid offset */
|
/* cannot continue if no stop position set or invalid offset */
|
||||||
g_return_val_if_fail (stop != -1, 0);
|
g_return_val_if_fail (stop != -1, 0);
|
||||||
g_return_val_if_fail (stop >= offset, 0);
|
g_return_val_if_fail (stop >= offset, 0);
|
||||||
|
|
|
@ -977,6 +977,21 @@ GST_START_TEST (segment_full)
|
||||||
fail_unless (gst_segment_position_from_running_time_full (&segment,
|
fail_unless (gst_segment_position_from_running_time_full (&segment,
|
||||||
GST_FORMAT_TIME, 75, &pos) == -1);
|
GST_FORMAT_TIME, 75, &pos) == -1);
|
||||||
fail_unless (pos == 300); /* Actually -300 */
|
fail_unless (pos == 300); /* Actually -300 */
|
||||||
|
|
||||||
|
/* Test for running time conversion with stop == -1, where
|
||||||
|
* calculations should use the duration instead */
|
||||||
|
segment.rate = -2.0;
|
||||||
|
segment.start = 100;
|
||||||
|
segment.offset = 0;
|
||||||
|
segment.stop = -1;
|
||||||
|
segment.duration = 200;
|
||||||
|
segment.position = 40;
|
||||||
|
segment.base = 100;
|
||||||
|
segment.time = 10000;
|
||||||
|
|
||||||
|
fail_unless (gst_segment_to_running_time_full (&segment, GST_FORMAT_TIME,
|
||||||
|
150, &rt) == 1);
|
||||||
|
fail_unless (rt == 175);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue