fix bug that prevented crosffading/gapless from working for mp4

git-svn-id: https://svn.musicpd.org/mpd/trunk@282 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-03-19 01:24:20 +00:00
parent b87cc3c164
commit cbfcd23d83
2 changed files with 32 additions and 33 deletions

View File

@ -186,10 +186,7 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
time = seekTable[sampleId];
}
if((dur=mp4ff_get_sample_duration(mp4fh,track,sampleId))==0) {
eof = 1;
break;
}
dur = mp4ff_get_sample_duration(mp4fh,track,sampleId);
if(sampleId>seekTableEnd) {
seekTable[sampleId] = time;
@ -215,7 +212,7 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
&mp4BufferSize) == 0)
{
eof = 1;
break;
continue;
}
sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer,
@ -238,33 +235,30 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
{
usleep(10000);
}
if(dc->stop) {
eof = 1;
break;
}
else if(dc->seek) break;
if(dc->stop) eof = 1;
else if(!dc->seek) {
sampleBufferLen-=size;
memcpy(cb->chunks+cb->end*CHUNK_SIZE+chunkLen,
sampleBuffer,size);
cb->times[cb->end] = time;
sampleBuffer+=size;
chunkLen+=size;
if(chunkLen>=CHUNK_SIZE) {
cb->chunkSize[cb->end] = CHUNK_SIZE;
++cb->end;
sampleBufferLen-=size;
memcpy(cb->chunks+cb->end*CHUNK_SIZE+chunkLen,
sampleBuffer,size);
cb->times[cb->end] = time;
sampleBuffer+=size;
chunkLen+=size;
if(chunkLen>=CHUNK_SIZE) {
cb->chunkSize[cb->end] = CHUNK_SIZE;
++cb->end;
if(cb->end>=buffered_chunks) {
cb->end = 0;
cb->wrap = 1;
if(cb->end>=buffered_chunks) {
cb->end = 0;
cb->wrap = 1;
}
chunkLen = 0;
}
chunkLen = 0;
}
}
}
if(!dc->stop && !dc->seek && chunkLen) {
cb->chunkSize[cb->end] = CHUNK_SIZE;
if(!dc->stop && !dc->seek && chunkLen>0) {
cb->chunkSize[cb->end] = chunkLen;
++cb->end;
if(cb->end>=buffered_chunks) {
@ -274,6 +268,12 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
chunkLen = 0;
}
free(seekTable);
faacDecClose(decoder);
mp4ff_close(mp4fh);
fclose(fh);
free(mp4cb);
if(dc->seek) dc->seek = 0;
if(dc->stop) {
@ -282,12 +282,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
}
else dc->state = DECODE_STATE_STOP;
free(seekTable);
faacDecClose(decoder);
mp4ff_close(mp4fh);
fclose(fh);
free(mp4cb);
return 0;
}

View File

@ -334,6 +334,11 @@ int queueSong(char * utf8file) {
else if(isWave(utf8file,NULL)) {
pc->decodeType = DECODE_TYPE_AUDIOFILE;
}
#endif
#ifdef HAVE_AUDIOFILE
else if(isMp4(utf8file,NULL)) {
pc->decodeType = DECODE_TYPE_MP4;
}
#endif
else return -1;
pc->queueState = PLAYER_QUEUE_FULL;