]> git.tue.mpg.de Git - paraslash.git/commitdiff
flacdec: Only process a single flac audio frame.
authorAndre Noll <maan@systemlinux.org>
Sat, 7 Apr 2012 01:02:02 +0000 (03:02 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 3 Jun 2012 11:04:01 +0000 (13:04 +0200)
This removes the loop in flacdec_post_select() which makes the
flac decoder decode as much as possible, but may starve other
tasks. Removing the loop gives other tasks a chance to run, thereby
avoiding buffer underruns. It simplifies the code too.

Also, resetting the number of unconsumed input bytes to zero at
each scheduler iteration has always been a mistake, so remove it.

flacdec_filter.c

index cd086f45748b9f85155f624f40fa1c939daf7cae..e8baa6b4b35031205f4fb28d858a6c1593e7ae7e 100644 (file)
@@ -234,27 +234,25 @@ static void flacdec_post_select(__a_unused struct sched *s, struct task *t)
                ret = flacdec_init(fn);
                goto out;
        }
-       pfd->unconsumed = 0;
-       for (;;) {
-               if (output_queue_full(btrn)) {
-                       pfd->have_more = true;
-                       break;
-               }
-               pfd->have_more = false;
-               FLAC__StreamDecoderState state;
-               FLAC__stream_decoder_process_single(pfd->decoder);
-               state = FLAC__stream_decoder_get_state(pfd->decoder);
-               //PARA_CRIT_LOG("state: %s\n", FLAC__stream_decoder_get_resolved_state_string(pfd->decoder));
-               ret = -E_FLACDEC_EOF;
-               if (state == FLAC__STREAM_DECODER_END_OF_STREAM)
-                       goto out;
-               if (state == FLAC__STREAM_DECODER_ABORTED) {
-                       FLAC__stream_decoder_flush(pfd->decoder);
-                       fn->min_iqs = pfd->unconsumed + 1;
-                       break;
-               }
-               fn->min_iqs = 0;
+       if (output_queue_full(btrn)) {
+               pfd->have_more = true;
+               ret = 1;
+               goto out;
        }
+       pfd->have_more = false;
+       FLAC__StreamDecoderState state;
+       FLAC__stream_decoder_process_single(pfd->decoder);
+       state = FLAC__stream_decoder_get_state(pfd->decoder);
+       ret = -E_FLACDEC_EOF;
+       if (state == FLAC__STREAM_DECODER_END_OF_STREAM)
+               goto out;
+       if (state == FLAC__STREAM_DECODER_ABORTED) {
+               FLAC__stream_decoder_flush(pfd->decoder);
+               fn->min_iqs = pfd->unconsumed + 1;
+               ret = 1;
+               goto out;
+       }
+       fn->min_iqs = 0;
        ret = 1;
 out:
        t->error = ret;