diff options
-rw-r--r-- | libs/gst/base/gstbaseparse.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 67e380a25..f95c3aa91 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -3148,22 +3148,24 @@ gst_base_parse_query (GstPad * pad, GstQuery * query) GST_DEBUG_OBJECT (parse, "position query"); gst_query_parse_position (query, &format, NULL); - GST_OBJECT_LOCK (parse); - if (format == GST_FORMAT_BYTES) { - dest_value = parse->priv->offset; - res = TRUE; - } else if (format == parse->segment.format && - GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) { - dest_value = parse->segment.last_stop; - res = TRUE; - } - GST_OBJECT_UNLOCK (parse); - - if (res) - gst_query_set_position (query, format, dest_value); - else { - res = gst_pad_query_default (pad, query); - if (!res) { + /* try upstream first */ + res = gst_pad_query_default (pad, query); + if (!res) { + /* Fall back on interpreting segment */ + GST_OBJECT_LOCK (parse); + if (format == GST_FORMAT_BYTES) { + dest_value = parse->priv->offset; + res = TRUE; + } else if (format == parse->segment.format && + GST_CLOCK_TIME_IS_VALID (parse->segment.last_stop)) { + dest_value = gst_segment_to_stream_time (&parse->segment, + parse->segment.format, parse->segment.last_stop); + res = TRUE; + } + GST_OBJECT_UNLOCK (parse); + if (res) + gst_query_set_position (query, format, dest_value); + else { /* no precise result, upstream no idea either, then best estimate */ /* priv->offset is updated in both PUSH/PULL modes */ res = gst_base_parse_convert (parse, |