From: Andre Noll Date: Fri, 30 Dec 2022 13:08:00 +0000 (+0100) Subject: Speed up mp3dec filter. X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=76f5f13b1216c4579eae6c9e1d142a6c929ee196;p=paraslash.git Speed up mp3dec filter. Avoid calling btr_get_input_queue_size() as this is potentially expensive (depending on the number of chunks in the input queue) and unnecessary. The user time of para_play for a ~4m long mp3 file on a very slow machine went down from 168s to 150s. Speedup: 11% --- diff --git a/mp3dec_filter.c b/mp3dec_filter.c index d40df85e..cf3e5d4b 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -79,12 +79,11 @@ static int mp3dec_post_monitor(__a_unused struct sched *s, void *context) int i, ret; struct private_mp3dec_data *pmd = fn->private_data; struct btr_node *btrn = fn->btrn; - size_t loaded = 0, len, iqs; + size_t loaded = 0, len; char *inbuffer, *outbuffer; next_buffer: pmd->stream.error = 0; - iqs = btr_get_input_queue_size(btrn); ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL); if (ret < 0) goto err; @@ -104,7 +103,7 @@ next_frame: if (ret < 0) { mp3dec_consume(btrn, &pmd->stream, len); if (pmd->stream.error == MAD_ERROR_BUFLEN) { - if (len == iqs && btr_no_parent(btrn)) { + if (fn->min_iqs > 0 && btr_no_parent(btrn)) { ret = -E_EOF; goto err; } @@ -128,7 +127,7 @@ decode: mad_stream_sync(&pmd->stream); if (pmd->stream.error == MAD_ERROR_BUFLEN) { ret = -E_EOF; - if (len == iqs && btr_no_parent(btrn)) + if (btr_no_parent(btrn)) goto err; fn->min_iqs += 100; ret = -E_MP3DEC_CORRUPT;