X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mp3dec.c;h=93181ef1421c75879b26156f5ecdbb8103b71f3e;hp=c02432eee8fa82ed8a1ab633afebac47fccb89df;hb=6f58bbe94b49c0fb473bffebde598a3d26b051f3;hpb=607ac63646d7c31aa1792dcf1d9a60e498654376 diff --git a/mp3dec.c b/mp3dec.c index c02432ee..93181ef1 100644 --- a/mp3dec.c +++ b/mp3dec.c @@ -19,8 +19,8 @@ /** \file mp3dec.c paraslash's mp3 decoder */ #include "para.h" - #include "list.h" +#include "sched.h" #include "filter.h" #include "error.h" #include @@ -30,7 +30,7 @@ #define MP3_OUTBUF_SIZE 128 * 1024 /** \cond a helper macro */ -#define MAD_TO_SHORT(f) (f) >= MAD_F_ONE? SHRT_MAX :\ +#define MAD_TO_SHORT(f) (f) >= MAD_F_ONE? SHRT_MAX :\ (f) <= -MAD_F_ONE? -SHRT_MAX : (signed short) ((f) >> (MAD_F_FRACBITS - 15)) /** \endcond */ @@ -48,8 +48,6 @@ struct private_mp3dec_data { struct mad_synth synth; }; -/* TODO: Convert all input if possible */ -#define FRAME_HEADER_SIZE 4 static ssize_t mp3dec(char *inbuffer, size_t len, struct filter_node *fn) { int i, ret; @@ -62,11 +60,8 @@ static ssize_t mp3dec(char *inbuffer, size_t len, struct filter_node *fn) pmd->stream.error = 0; next_frame: ret = mad_header_decode(&pmd->frame.header, &pmd->stream); - if (ret < 0) { - if (!MAD_RECOVERABLE(pmd->stream.error)) - goto out; - return FRAME_HEADER_SIZE; - } + if (ret < 0) + goto out; fn->fc->samplerate = pmd->frame.header.samplerate; fn->fc->channels = MAD_NCHANNELS(&pmd->frame.header); ret = mad_frame_decode(&pmd->frame, &pmd->stream); @@ -98,8 +93,8 @@ next_frame: out: if (pmd->stream.next_frame) { /* we still have some data */ size_t off = pmd->stream.bufend - pmd->stream.next_frame; - PARA_DEBUG_LOG("converted %zd, rate: %u, returning %zd\n", len - off, - fn->fc->samplerate, copy - off); +// PARA_INFO_LOG("off: %zd, rate: %u, returning %zd\n", off, +// fn->fc->samplerate, copy - off); return copy - off; } return copy; @@ -131,6 +126,7 @@ static void mp3dec_open(struct filter_node *fn) fn->bufsize = MP3_OUTBUF_SIZE; fn->buf = para_calloc(fn->bufsize); } + /** * the init function of the mp3dec filter *