mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
basesink: improve position reporting without clock
When no base time or when sync is disabled, use the same logic as in paused to report position. The logic in PLAYING assumes we use the clock.
This commit is contained in:
parent
2253f8fa6f
commit
cf4334fbfb
1 changed files with 33 additions and 32 deletions
|
@ -4372,38 +4372,6 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
|
|||
rate = segment->rate * segment->applied_rate;
|
||||
latency = basesink->priv->latency;
|
||||
|
||||
if (oformat == GST_FORMAT_TIME) {
|
||||
gint64 start, stop;
|
||||
|
||||
start = basesink->priv->current_sstart;
|
||||
stop = basesink->priv->current_sstop;
|
||||
|
||||
if (in_paused) {
|
||||
/* in paused we use the last position as a lower bound */
|
||||
if (stop == -1 || segment->rate > 0.0)
|
||||
last = start;
|
||||
else
|
||||
last = stop;
|
||||
|
||||
GST_DEBUG_OBJECT (basesink, "in PAUSED using last %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (last));
|
||||
} else {
|
||||
/* in playing, use last stop time as upper bound */
|
||||
if (start == -1 || segment->rate > 0.0)
|
||||
last = stop;
|
||||
else
|
||||
last = start;
|
||||
|
||||
GST_DEBUG_OBJECT (basesink, "in PLAYING using last %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (last));
|
||||
}
|
||||
} else {
|
||||
/* convert last stop to stream time */
|
||||
last = gst_segment_to_stream_time (segment, oformat, segment->position);
|
||||
|
||||
GST_DEBUG_OBJECT (basesink, "in using last %" G_GINT64_FORMAT, last);
|
||||
}
|
||||
|
||||
if (in_paused) {
|
||||
/* in paused, use start_time */
|
||||
base_time = GST_ELEMENT_START_TIME (basesink);
|
||||
|
@ -4425,6 +4393,39 @@ gst_base_sink_get_position (GstBaseSink * basesink, GstFormat format,
|
|||
if (base_time == -1)
|
||||
last_seen = TRUE;
|
||||
|
||||
if (oformat == GST_FORMAT_TIME) {
|
||||
gint64 start, stop;
|
||||
|
||||
start = basesink->priv->current_sstart;
|
||||
stop = basesink->priv->current_sstop;
|
||||
|
||||
if (in_paused || last_seen) {
|
||||
/* in paused or when we don't use the clock, we use the last position
|
||||
* as a lower bound */
|
||||
if (stop == -1 || segment->rate > 0.0)
|
||||
last = start;
|
||||
else
|
||||
last = stop;
|
||||
|
||||
GST_DEBUG_OBJECT (basesink, "in PAUSED using last %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (last));
|
||||
} else {
|
||||
/* in playing, use last stop time as upper bound */
|
||||
if (start == -1 || segment->rate > 0.0)
|
||||
last = stop;
|
||||
else
|
||||
last = start;
|
||||
|
||||
GST_DEBUG_OBJECT (basesink, "in PLAYING using last %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (last));
|
||||
}
|
||||
} else {
|
||||
/* convert position to stream time */
|
||||
last = gst_segment_to_stream_time (segment, oformat, segment->position);
|
||||
|
||||
GST_DEBUG_OBJECT (basesink, "in using last %" G_GINT64_FORMAT, last);
|
||||
}
|
||||
|
||||
/* need to release the object lock before we can get the time,
|
||||
* a clock might take the LOCK of the provider, which could be
|
||||
* a basesink subclass. */
|
||||
|
|
Loading…
Reference in a new issue