]> git.tue.mpg.de Git - paraslash.git/commitdiff
Speed up mp3dec filter.
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 30 Dec 2022 13:08:00 +0000 (14:08 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 8 May 2024 17:45:52 +0000 (19:45 +0200)
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%

mp3dec_filter.c

index d40df85edbe24b9dc54f01fc9305a1575c022507..cf3e5d4be6fcf267dcb497c24c7975a88c1df1c4 100644 (file)
@@ -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;