X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mp3dec.c;h=599d8a90928d6fdeb9c2d2cd418df707c3620fb3;hp=16599411820313eae492a604fb58d09b1221b752;hb=89a0e510df07bc7210ca9e73381763fdd183df75;hpb=1f31b52b6816ce2716a3755a1896f77744fa167b diff --git a/mp3dec.c b/mp3dec.c index 16599411..599d8a90 100644 --- a/mp3dec.c +++ b/mp3dec.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Andre Noll + * Copyright (C) 2005-2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -43,15 +43,25 @@ 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 (ret < 0) { + if (pmd->stream.error != MAD_ERROR_BUFLEN && + pmd->stream.error != MAD_ERROR_LOSTSYNC) + PARA_DEBUG_LOG("header decode: %s\n", + mad_stream_errorstr(&pmd->stream)); 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); if (ret) { - if (MAD_RECOVERABLE(pmd->stream.error) || pmd->stream.error == MAD_ERROR_BUFLEN) + if (MAD_RECOVERABLE(pmd->stream.error) || + pmd->stream.error == MAD_ERROR_BUFLEN) { + PARA_DEBUG_LOG("frame decode: %s\n", + mad_stream_errorstr(&pmd->stream)); goto out; - PARA_ERROR_LOG("fatal: ret = %d, loaded = %zd\n", ret, fn->loaded); + } + PARA_ERROR_LOG("frame decode: %s\n", + mad_stream_errorstr(&pmd->stream)); return -E_MAD_FRAME_DECODE; } mad_synth_frame(&pmd->synth, &pmd->frame); @@ -98,9 +108,9 @@ static void mp3dec_close(struct filter_node *fn) static void mp3dec_open(struct filter_node *fn) { - fn->private_data = para_calloc(sizeof(struct private_mp3dec_data)); - struct private_mp3dec_data *pmd = fn->private_data; + struct private_mp3dec_data *pmd = para_calloc(sizeof(*pmd)); + fn->private_data = pmd; mad_stream_init(&pmd->stream); mad_frame_init(&pmd->frame); mad_synth_init(&pmd->synth); @@ -116,7 +126,7 @@ static void mp3dec_open(struct filter_node *fn) * * \sa filter::init. */ -void mp3dec_init(struct filter *f) +void mp3dec_filter_init(struct filter *f) { f->open = mp3dec_open; f->convert = mp3dec;