diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2006-08-23 13:20:24 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2006-08-23 13:20:24 +0000 |
commit | 103dd654f0d9357f9da66593525958476ee26f85 (patch) | |
tree | c391fcff929f08a31b2666ea3dd2f943b1051af5 /src/inputPlugins | |
parent | 67de7ea1162f55b2a6d59d536827a66574bbebcd (diff) | |
download | mpd-103dd654f0d9357f9da66593525958476ee26f85.tar.gz mpd-103dd654f0d9357f9da66593525958476ee26f85.tar.xz mpd-103dd654f0d9357f9da66593525958476ee26f85.zip |
Skip layer 2 frames in mp3s and vice versa. Also drop support for layer 1, since it hasn't been tested.
git-svn-id: https://svn.musicpd.org/mpd/trunk@4669 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 780a326ae..073cad009 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -145,6 +145,7 @@ typedef struct _mp3DecodeData { unsigned long bitRate; InputStream *inStream; struct audio_dither dither; + enum mad_layer layer; } mp3DecodeData; static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) @@ -167,6 +168,7 @@ static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) data->decodedFirstFrame = 0; data->flush = 1; data->inStream = inStream; + data->layer = 0; memset(&(data->dither), 0, sizeof(struct audio_dither)); mad_stream_init(&data->stream); @@ -352,6 +354,8 @@ fail: static int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag, ReplayGainInfo ** replayGainInfo) { + enum mad_layer layer; + if ((data->stream).buffer == NULL || (data->stream).error == MAD_ERROR_BUFLEN) { if (fillMp3InputBuffer(data) < 0) { @@ -395,9 +399,17 @@ static int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag, } } } - if ((data->frame.header.layer != MAD_LAYER_III) && - (data->frame.header.layer != MAD_LAYER_II) && - (data->frame.header.layer != MAD_LAYER_I)) { + + layer = data->frame.header.layer; + if (!data->layer) { + if (layer != MAD_LAYER_II && layer != MAD_LAYER_III) { + /* Only layer 2 and 3 have been tested to work */ + DEBUG("MPEG audio file is not layer 2 or 3\n"); + return DECODE_BREAK; + } + data->layer = layer; + } else if (layer != data->layer) { + /* Don't decode frames with a different layer than the first */ return DECODE_SKIP; } |