aboutsummaryrefslogtreecommitdiffstats
path: root/src/mp3_decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-18 14:58:47 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-18 14:58:47 +0000
commita2b6583db6da3e044f3718f660c7f9a1adf2bb10 (patch)
treee0b7ff075f86b61ea38dcdd44ed482ae8217ff79 /src/mp3_decode.c
parent3a5a75cf87c5b952a946224a37cf9c1c6ba45d7f (diff)
downloadmpd-a2b6583db6da3e044f3718f660c7f9a1adf2bb10.tar.gz
mpd-a2b6583db6da3e044f3718f660c7f9a1adf2bb10.tar.xz
mpd-a2b6583db6da3e044f3718f660c7f9a1adf2bb10.zip
fix some wackiness due to attempted search table
git-svn-id: https://svn.musicpd.org/mpd/trunk@1065 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/mp3_decode.c')
-rw-r--r--src/mp3_decode.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index 0658f3d41..116083eb5 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -181,8 +181,8 @@ int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
readed = 0;
while(readed == 0 && !inputStreamAtEOF(data->inStream)) {
- readed = readFromInputStream(data->inStream, readStart, 1,
- readSize);
+ readed = readFromInputStream(data->inStream, readStart,
+ (size_t)1, readSize);
}
if(readed<=0) return -1;
@@ -362,10 +362,16 @@ int decodeFirstFrame(mp3DecodeData * data) {
else {
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;
- if(data->totalTime < 0) data->totalTime = 0;
- data->maxFrames = data->totalTime/frameTime+FRAMES_CUSHION;
+ data->maxFrames =
+ data->totalTime/frameTime+FRAMES_CUSHION;
+ }
+ else {
+ data->maxFrames = FRAMES_CUSHION;
+ data->totalTime = 0;
+ }
}
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 int skip;
- if(data->currentFrame>=data->highestFrame &&
- data->highestFrame<data->maxFrames)
- {
+ if(data->currentFrame>=data->highestFrame) {
mad_timer_add(&data->timer,(data->frame).header.duration);
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;
if(data->stream.this_frame!=NULL) {
data->frameOffset[data->currentFrame]-=
@@ -431,7 +439,6 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
data->stream.bufend-data->stream.buffer;
}
data->times[data->currentFrame] = data->timer;
- data->highestFrame++;
}
else data->timer = data->times[data->currentFrame];
data->currentFrame++;