fix some wackiness due to attempted search table

git-svn-id: https://svn.musicpd.org/mpd/trunk@1065 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-05-18 14:58:47 +00:00
parent 3a5a75cf87
commit a2b6583db6

View File

@ -181,8 +181,8 @@ int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
readed = 0; readed = 0;
while(readed == 0 && !inputStreamAtEOF(data->inStream)) { while(readed == 0 && !inputStreamAtEOF(data->inStream)) {
readed = readFromInputStream(data->inStream, readStart, 1, readed = readFromInputStream(data->inStream, readStart,
readSize); (size_t)1, readSize);
} }
if(readed<=0) return -1; if(readed<=0) return -1;
@ -362,10 +362,16 @@ int decodeFirstFrame(mp3DecodeData * data) {
else { else {
offset-= data->stream.bufend-data->stream.buffer; offset-= data->stream.bufend-data->stream.buffer;
} }
data->totalTime = ((data->inStream->size-offset)*8.0)/ if(data->inStream->size >= offset) {
data->totalTime = ((data->inStream->size-offset)*8.0)/
(data->frame).header.bitrate; (data->frame).header.bitrate;
if(data->totalTime < 0) data->totalTime = 0; data->maxFrames =
data->maxFrames = data->totalTime/frameTime+FRAMES_CUSHION; data->totalTime/frameTime+FRAMES_CUSHION;
}
else {
data->maxFrames = FRAMES_CUSHION;
data->totalTime = 0;
}
} }
data->frameOffset = malloc(sizeof(long)*data->maxFrames); data->frameOffset = malloc(sizeof(long)*data->maxFrames);
@ -415,11 +421,13 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
static struct audio_dither dither; static struct audio_dither dither;
static int skip; static int skip;
if(data->currentFrame>=data->highestFrame && if(data->currentFrame>=data->highestFrame) {
data->highestFrame<data->maxFrames)
{
mad_timer_add(&data->timer,(data->frame).header.duration); mad_timer_add(&data->timer,(data->frame).header.duration);
data->bitRate = (data->frame).header.bitrate; data->bitRate = (data->frame).header.bitrate;
if(data->currentFrame>=data->maxFrames) {
data->currentFrame = data->maxFrames - 1;
}
else data->highestFrame++;
data->frameOffset[data->currentFrame] = data->inStream->offset; data->frameOffset[data->currentFrame] = data->inStream->offset;
if(data->stream.this_frame!=NULL) { if(data->stream.this_frame!=NULL) {
data->frameOffset[data->currentFrame]-= data->frameOffset[data->currentFrame]-=
@ -431,7 +439,6 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
data->stream.bufend-data->stream.buffer; data->stream.bufend-data->stream.buffer;
} }
data->times[data->currentFrame] = data->timer; data->times[data->currentFrame] = data->timer;
data->highestFrame++;
} }
else data->timer = data->times[data->currentFrame]; else data->timer = data->times[data->currentFrame];
data->currentFrame++; data->currentFrame++;