diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2015-08-15 16:39:40 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2015-08-15 18:41:31 +0100 |
commit | bc1fb2d8b06d99e0c9a95e156d9aa13cf9487243 (patch) | |
tree | 99a4ae855fd20131de6df2e2fc7072e145e2d220 | |
parent | 1176fbf6dc96f705a8c15c4dba5ecd33cc8d8d39 (diff) |
baseparse: minor code simplification
Use gst_pad_peer_query_duration() and remove a few
unnecessary levels of indentation. Rest of code might
looks a bit questionable, but leave it as is for now.
-rw-r--r-- | libs/gst/base/gstbaseparse.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index df201abab..395b43b18 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -1543,41 +1543,30 @@ no_duration_bytes: } static void -gst_base_parse_update_duration (GstBaseParse * baseparse) +gst_base_parse_update_duration (GstBaseParse * parse) { - GstPad *peer; - GstBaseParse *parse; - - parse = GST_BASE_PARSE (baseparse); + gint64 ptot, dest_value; - peer = gst_pad_get_peer (parse->sinkpad); - if (peer) { - gboolean qres = FALSE; - gint64 ptot, dest_value; + if (!gst_pad_peer_query_duration (parse->sinkpad, GST_FORMAT_BYTES, &ptot)) + return; - qres = gst_pad_query_duration (peer, GST_FORMAT_BYTES, &ptot); - gst_object_unref (GST_OBJECT (peer)); - if (qres) { - if (gst_base_parse_convert (parse, GST_FORMAT_BYTES, ptot, - GST_FORMAT_TIME, &dest_value)) { + if (!gst_base_parse_convert (parse, GST_FORMAT_BYTES, ptot, + GST_FORMAT_TIME, &dest_value)) + return; - /* inform if duration changed, but try to avoid spamming */ - parse->priv->estimated_drift += - dest_value - parse->priv->estimated_duration; + /* inform if duration changed, but try to avoid spamming */ + parse->priv->estimated_drift += dest_value - parse->priv->estimated_duration; - parse->priv->estimated_duration = dest_value; - GST_LOG_OBJECT (parse, - "updated estimated duration to %" GST_TIME_FORMAT, - GST_TIME_ARGS (dest_value)); - - if (parse->priv->estimated_drift > GST_SECOND || - parse->priv->estimated_drift < -GST_SECOND) { - gst_element_post_message (GST_ELEMENT (parse), - gst_message_new_duration_changed (GST_OBJECT (parse))); - parse->priv->estimated_drift = 0; - } - } - } + parse->priv->estimated_duration = dest_value; + GST_LOG_OBJECT (parse, + "updated estimated duration to %" GST_TIME_FORMAT, + GST_TIME_ARGS (dest_value)); + + if (parse->priv->estimated_drift > GST_SECOND || + parse->priv->estimated_drift < -GST_SECOND) { + gst_element_post_message (GST_ELEMENT (parse), + gst_message_new_duration_changed (GST_OBJECT (parse))); + parse->priv->estimated_drift = 0; } } |