diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-03-04 20:45:49 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-03-04 20:45:49 +0000 |
commit | 4893e94dae7ee3a2c126df6e82f732223becefce (patch) | |
tree | 3e76b98631862dab38f80d76c2ab4fe3ba1ba2ca /src | |
parent | 0d22fa6e64ab7586c7f2ff51d66c098d6d50922b (diff) | |
download | mpd-4893e94dae7ee3a2c126df6e82f732223becefce.tar.gz mpd-4893e94dae7ee3a2c126df6e82f732223becefce.tar.xz mpd-4893e94dae7ee3a2c126df6e82f732223becefce.zip |
git-svn-id: https://svn.musicpd.org/mpd/trunk@194 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/mp3_decode.c | 26 | ||||
-rw-r--r-- | src/pcm_utils.c | 8 |
2 files changed, 23 insertions, 11 deletions
diff --git a/src/mp3_decode.c b/src/mp3_decode.c index 5defdcf30..e417e0a04 100644 --- a/src/mp3_decode.c +++ b/src/mp3_decode.c @@ -38,6 +38,7 @@ #define READ_BUFFER_SIZE 40960 +#define DECODE_SKIP -3 #define DECODE_BREAK -2 #define DECODE_CONT -1 #define DECODE_OK 0 @@ -180,6 +181,7 @@ int decodeNextFrameHeader(mp3DecodeData * data) { } } if(mad_header_decode(&data->frame.header,&data->stream)) { + if((data->stream).error==MAD_ERROR_LOSTSYNC) return DECODE_SKIP; if(MAD_RECOVERABLE((data->stream).error)) return DECODE_CONT; else { if((data->stream).error==MAD_ERROR_BUFLEN) return DECODE_CONT; @@ -204,6 +206,7 @@ int decodeNextFrame(mp3DecodeData * data) { } } if(mad_frame_decode(&data->frame,&data->stream)) { + if((data->stream).error==MAD_ERROR_LOSTSYNC) return DECODE_SKIP; if(MAD_RECOVERABLE((data->stream).error)) return DECODE_CONT; else { if((data->stream).error==MAD_ERROR_BUFLEN) return DECODE_CONT; @@ -282,14 +285,23 @@ int decodeFirstFrame(mp3DecodeData * data) { struct stat filestat; struct xing xing; int ret; + int skip; memset(&xing,0,sizeof(struct xing)); xing.flags = 0; - while((ret = decodeNextFrameHeader(data))==DECODE_CONT); - if(ret!=DECODE_OK) return -1; - while((ret = decodeNextFrame(data))==DECODE_CONT); - if(ret!=DECODE_OK) return -1; + skip = 0; + while(1) { + printf("HERE 1\n"); + while((ret = decodeNextFrameHeader(data))==DECODE_CONT); + if(ret==DECODE_SKIP) skip = 1; + if(ret==DECODE_BREAK) return -1; + while((ret = decodeNextFrame(data))==DECODE_CONT); + if(ret==DECODE_BREAK) return -1; + if(ret==DECODE_SKIP) skip = 1; + else if(skip && ret==DECODE_OK) skip = 0; + else if(!skip && ret==DECODE_OK) break; + } if(parse_xing(&xing,data->stream.anc_ptr,data->stream.anc_bitlen)) { if(xing.flags & XING_FRAMES) { @@ -464,9 +476,11 @@ int mp3Read(mp3DecodeData * data, Buffer * cb, DecoderControl * dc) { } if(data->muteFrame) { - while((ret=decodeNextFrameHeader(data))==DECODE_CONT); + while((ret=decodeNextFrameHeader(data))==DECODE_CONT || + ret==DECODE_SKIP); } - else while((ret=decodeNextFrame(data))==DECODE_CONT); + else while((ret=decodeNextFrame(data))==DECODE_CONT || + ret==DECODE_SKIP); return ret; } diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 6f92969ac..e7d767972 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -96,8 +96,7 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1, switch(format->bits) { case 16: while(bufferSize1>0 && bufferSize2>0) { - temp32 = *buffer16_1; - temp32+= *buffer16_2; + temp32 = *buffer16_1+*buffer16_2; *buffer16_1 = temp32>32767 ? 32767 : (temp32<-32768 ? -32768 : temp32); buffer16_1++; @@ -105,12 +104,11 @@ void pcm_add(char * buffer1, char * buffer2, size_t bufferSize1, bufferSize1-=2; bufferSize2-=2; } - if(bufferSize2>0) memcpy(buffer8_1,buffer8_2,bufferSize2); + if(bufferSize2>0) memcpy(buffer16_1,buffer16_2,bufferSize2); break; case 8: while(bufferSize1>0 && bufferSize2>0) { - temp32 = *buffer8_1; - temp32+= *buffer8_2; + temp32 = *buffer8_1+*buffer8_2; *buffer8_1 = temp32>127 ? 127 : (temp32<-128 ? -128 : temp32); buffer8_1++; |