summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-20 01:34:25 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-20 01:34:25 +0000
commitffd0ccfc3be26640d2bb237debc249e3c46b4bb8 (patch)
tree089783087ea4ec86295ece0f0ac2e56a35d6c8bd /src
parent61b9e2fc478f11aa4fe54ca7fe6995b145e0fa63 (diff)
git-svn-id: https://svn.musicpd.org/mpd/trunk@319 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/mp4_decode.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mp4_decode.c b/src/mp4_decode.c
index 16821b179..19b076845 100644
--- a/src/mp4_decode.c
+++ b/src/mp4_decode.c
@@ -189,7 +189,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
dur = mp4ff_get_sample_duration(mp4fh,track,sampleId);
offset = mp4ff_get_sample_offset(mp4fh,track,sampleId);
- dur-=offset;
if(sampleId>seekTableEnd) {
seekTable[sampleId] = time;
@@ -197,6 +196,8 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
}
if(sampleId==0) dur = 0;
+ if(offset>dur) dur = 0;
+ else dur-=offset;
time+=((float)dur)/scale;
if(dc->seek && time>dc->seekWhere) seekPositionFound = 1;
@@ -221,6 +222,16 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer,
mp4BufferSize);
if(mp4Buffer) free(mp4Buffer);
+ if(frameInfo.error > 0) {
+ eof = 1;
+ break;
+ }
+
+ if(dur+offset > frameInfo.samples) {
+ dur = frameInfo.samples;
+ offset = 0;
+ }
+
sampleCount = (unsigned long)(dur*channels);
if(sampleCount>0) initial =0;
@@ -228,9 +239,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
sampleBuffer+=offset*channels*2;
- printf("dur=%li offset=%li frameInfo.samples=%li\n",dur,offset,
- frameInfo.samples);
-
while(sampleBufferLen>0 && !dc->seek) {
size_t size = sampleBufferLen>CHUNK_SIZE-chunkLen ?
CHUNK_SIZE-chunkLen: