X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=mp3dec_filter.c;h=ccb1553b820357e13f2cafe2c0e8a7e0502ac8fd;hb=refs%2Fheads%2Fnext;hp=b053aaa8f3fd33171aca682fe53dd85906bcca11;hpb=8d106ca317a2c42f35a86ba244f843688f6939e6;p=paraslash.git diff --git a/mp3dec_filter.c b/mp3dec_filter.c index b053aaa8..d4d4712f 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2005 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2005 Andre Noll , see file COPYING. */ /** \file mp3dec_filter.c Paraslash's mp3 decoder. */ @@ -77,18 +73,17 @@ static void mp3dec_close(struct filter_node *fn) #define MP3DEC_MAX_FRAME 8192 -static int mp3dec_post_select(__a_unused struct sched *s, void *context) +static int mp3dec_post_monitor(__a_unused struct sched *s, void *context) { struct filter_node *fn = 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; @@ -97,7 +92,7 @@ next_buffer: btr_merge(btrn, fn->min_iqs); len = btr_next_buffer(btrn, &inbuffer); /* - * Decode at most 8K in one go to give the post_select() functions of + * Decode at most 8K in one go to give the post_monitor() functions of * other buffer tree nodes a chance to run. This is necessary to avoid * buffer underruns on slow machines. */ @@ -108,8 +103,8 @@ 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)) { - ret = -E_MP3DEC_EOF; + if (fn->min_iqs > 0 && btr_no_parent(btrn)) { + ret = -E_EOF; goto err; } fn->min_iqs += 100; @@ -131,8 +126,8 @@ decode: goto err; mad_stream_sync(&pmd->stream); if (pmd->stream.error == MAD_ERROR_BUFLEN) { - ret = -E_MP3DEC_EOF; - if (len == iqs && btr_no_parent(btrn)) + ret = -E_EOF; + if (btr_no_parent(btrn)) goto err; fn->min_iqs += 100; ret = -E_MP3DEC_CORRUPT; @@ -148,7 +143,7 @@ decode: } fn->min_iqs = 0; mad_synth_frame(&pmd->synth, &pmd->frame); - outbuffer = para_malloc(pmd->synth.pcm.length * 2 * pmd->channels); + outbuffer = arr_alloc(pmd->synth.pcm.length, 2 * pmd->channels); loaded = 0; for (i = 0; i < pmd->synth.pcm.length; i++) { int sample = MAD_TO_SHORT(pmd->synth.pcm.samples[0][i]); @@ -170,7 +165,7 @@ err: static void mp3dec_open(struct filter_node *fn) { - struct private_mp3dec_data *pmd = para_calloc(sizeof(*pmd)); + struct private_mp3dec_data *pmd = zalloc(sizeof(*pmd)); fn->private_data = pmd; mad_stream_init(&pmd->stream); @@ -180,7 +175,8 @@ static void mp3dec_open(struct filter_node *fn) mad_stream_options(&pmd->stream, MAD_OPTION_IGNORECRC); } -static int mp3dec_execute(struct btr_node *btrn, const char *cmd, char **result) +static int mp3dec_execute(const struct btr_node *btrn, const char *cmd, + char **result) { struct filter_node *fn = btr_context(btrn); struct private_mp3dec_data *pmd = fn->private_data; @@ -191,7 +187,7 @@ static int mp3dec_execute(struct btr_node *btrn, const char *cmd, char **result) const struct filter lsg_filter_cmd_com_mp3dec_user_data = { .open = mp3dec_open, .close = mp3dec_close, - .pre_select = generic_filter_pre_select, - .post_select = mp3dec_post_select, + .pre_monitor = generic_filter_pre_monitor, + .post_monitor = mp3dec_post_monitor, .execute = mp3dec_execute, };