From: Wim Taymans Date: Fri, 9 Apr 2010 10:35:47 +0000 (+0200) Subject: queue2: when EOS we know the duration X-Git-Tag: RELEASE-0.10.29~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db172aaa6fa60707716270389b675d0ef560d82e;p=platform%2Fupstream%2Fgstreamer.git queue2: when EOS we know the duration When we are EOS, we don't need to do an upstream query for the duration in bytes because we already know it is the offset of the last written byte. --- diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 9cfed25..403cff6 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -2003,7 +2003,7 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) gint64 estimated_total, buffering_left; GstFormat peer_fmt; gint64 duration; - gboolean peer_res, is_buffering; + gboolean peer_res, is_buffering, is_eos; gdouble byte_in_rate, byte_out_rate; /* we need a current download region */ @@ -2014,12 +2014,19 @@ gst_queue2_handle_src_query (GstPad * pad, GstQuery * query) byte_in_rate = queue->byte_in_rate; byte_out_rate = queue->byte_out_rate; is_buffering = queue->is_buffering; + is_eos = queue->is_eos; percent = queue->buffering_percent; - /* get duration of upstream in bytes */ - peer_fmt = GST_FORMAT_BYTES; - peer_res = gst_pad_query_peer_duration (queue->sinkpad, &peer_fmt, - &duration); + if (is_eos) { + /* we're EOS, we know the duration in bytes now */ + peer_res = TRUE; + duration = writing_pos; + } else { + /* get duration of upstream in bytes */ + peer_fmt = GST_FORMAT_BYTES; + peer_res = gst_pad_query_peer_duration (queue->sinkpad, &peer_fmt, + &duration); + } /* calculate remaining and total download time */ if (peer_res && byte_in_rate > 0.0) {