From c6fad99cade79e647ca46432e07278a7ef3fbef1 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 22 Nov 2008 21:37:34 +0100 Subject: [PATCH] Better error diagnostics for the mp3 decoder. --- mp3dec.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mp3dec.c b/mp3dec.c index 763ca37f..615a0640 100644 --- a/mp3dec.c +++ b/mp3dec.c @@ -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); -- 2.39.5