X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=flacdec_filter.c;h=363c73bb15d401c25217d88308b03c12df13aa6f;hp=cd086f45748b9f85155f624f40fa1c939daf7cae;hb=7dcaf56321189db230e0697f88ce9d9e225ea3ec;hpb=1e196821cc4fa9e1319557ce1100961be6795278 diff --git a/flacdec_filter.c b/flacdec_filter.c index cd086f45..363c73bb 100644 --- a/flacdec_filter.c +++ b/flacdec_filter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 Andre Noll + * Copyright (C) 2011-2013 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -216,7 +216,7 @@ static void flacdec_pre_select(struct sched *s, struct task *t) return sched_min_delay(s); } -static void flacdec_post_select(__a_unused struct sched *s, struct task *t) +static int flacdec_post_select(__a_unused struct sched *s, struct task *t) { struct filter_node *fn = container_of(t, struct filter_node, task); struct private_flacdec_data *pfd = fn->private_data; @@ -224,7 +224,7 @@ static void flacdec_post_select(__a_unused struct sched *s, struct task *t) int ret; if (output_queue_full(btrn)) - return; + return 0; ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL); if (ret < 0 && ret != -E_BTR_EOF) /* fatal error */ goto out; @@ -234,32 +234,30 @@ 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; if (ret < 0) - btr_remove_node(btrn); + btr_remove_node(&fn->btrn); + return ret; } static void flacdec_close(struct filter_node *fn) @@ -298,6 +296,7 @@ void flacdec_filter_init(struct filter *f) f->open = flacdec_open; f->close = flacdec_close; f->pre_select = flacdec_pre_select; - f->post_select = flacdec_post_select; + f->new_post_select = flacdec_post_select; + f->post_select = NULL; f->execute = flacdec_execute; }