diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2016-01-06 19:51:44 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-01-06 20:00:46 +0000 |
commit | 61e2f1eab1601b963b220f4d33ab869c9752eabc (patch) | |
tree | b689cdb9ce94f869cc30541d4d9f9785640953e0 /plugins | |
parent | 8c6c0bef884197808745e0fc9e9aa814b826a437 (diff) |
queue2: avoid calculating fill levels multiple times
Macro expansion means we might calculate the fill level once
for the check and then possibly again for the return value.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/elements/gstqueue2.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 9b37d66ab..35ac3bd0e 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -882,7 +882,7 @@ static gboolean get_buffering_percent (GstQueue2 * queue, gboolean * is_buffering, gint * percent) { - gint perc; + gint perc, perc2; if (queue->high_percent <= 0) { if (percent) @@ -912,12 +912,18 @@ get_buffering_percent (GstQueue2 * queue, gboolean * is_buffering, guint64 rb_size = queue->ring_buffer_max_size; perc = GET_PERCENT (bytes, rb_size); } - perc = MAX (perc, GET_PERCENT (time, 0)); - perc = MAX (perc, GET_PERCENT (buffers, 0)); + + perc2 = GET_PERCENT (time, 0); + perc = MAX (perc, perc2); + + perc2 = GET_PERCENT (buffers, 0); + perc = MAX (perc, perc2); /* also apply the rate estimate when we need to */ - if (queue->use_rate_estimate) - perc = MAX (perc, GET_PERCENT (rate_time, 0)); + if (queue->use_rate_estimate) { + perc2 = GET_PERCENT (rate_time, 0); + perc = MAX (perc, perc2); + } /* Don't get to 0% unless we're really empty */ if (queue->cur_level.bytes > 0) |