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:
parent
b87cc3c164
commit
cbfcd23d83
|
@ -186,10 +186,7 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
time = seekTable[sampleId];
|
time = seekTable[sampleId];
|
||||||
}
|
}
|
||||||
|
|
||||||
if((dur=mp4ff_get_sample_duration(mp4fh,track,sampleId))==0) {
|
dur = mp4ff_get_sample_duration(mp4fh,track,sampleId);
|
||||||
eof = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sampleId>seekTableEnd) {
|
if(sampleId>seekTableEnd) {
|
||||||
seekTable[sampleId] = time;
|
seekTable[sampleId] = time;
|
||||||
|
@ -215,7 +212,7 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
&mp4BufferSize) == 0)
|
&mp4BufferSize) == 0)
|
||||||
{
|
{
|
||||||
eof = 1;
|
eof = 1;
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer,
|
sampleBuffer = faacDecDecode(decoder,&frameInfo,mp4Buffer,
|
||||||
|
@ -238,33 +235,30 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
{
|
{
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
if(dc->stop) {
|
if(dc->stop) eof = 1;
|
||||||
eof = 1;
|
else if(!dc->seek) {
|
||||||
break;
|
sampleBufferLen-=size;
|
||||||
}
|
memcpy(cb->chunks+cb->end*CHUNK_SIZE+chunkLen,
|
||||||
else if(dc->seek) break;
|
sampleBuffer,size);
|
||||||
|
cb->times[cb->end] = time;
|
||||||
sampleBufferLen-=size;
|
sampleBuffer+=size;
|
||||||
memcpy(cb->chunks+cb->end*CHUNK_SIZE+chunkLen,
|
chunkLen+=size;
|
||||||
sampleBuffer,size);
|
if(chunkLen>=CHUNK_SIZE) {
|
||||||
cb->times[cb->end] = time;
|
cb->chunkSize[cb->end] = CHUNK_SIZE;
|
||||||
sampleBuffer+=size;
|
++cb->end;
|
||||||
chunkLen+=size;
|
|
||||||
if(chunkLen>=CHUNK_SIZE) {
|
if(cb->end>=buffered_chunks) {
|
||||||
cb->chunkSize[cb->end] = CHUNK_SIZE;
|
cb->end = 0;
|
||||||
++cb->end;
|
cb->wrap = 1;
|
||||||
|
}
|
||||||
if(cb->end>=buffered_chunks) {
|
chunkLen = 0;
|
||||||
cb->end = 0;
|
|
||||||
cb->wrap = 1;
|
|
||||||
}
|
}
|
||||||
chunkLen = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dc->stop && !dc->seek && chunkLen) {
|
if(!dc->stop && !dc->seek && chunkLen>0) {
|
||||||
cb->chunkSize[cb->end] = CHUNK_SIZE;
|
cb->chunkSize[cb->end] = chunkLen;
|
||||||
++cb->end;
|
++cb->end;
|
||||||
|
|
||||||
if(cb->end>=buffered_chunks) {
|
if(cb->end>=buffered_chunks) {
|
||||||
|
@ -274,6 +268,12 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
chunkLen = 0;
|
chunkLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(seekTable);
|
||||||
|
faacDecClose(decoder);
|
||||||
|
mp4ff_close(mp4fh);
|
||||||
|
fclose(fh);
|
||||||
|
free(mp4cb);
|
||||||
|
|
||||||
if(dc->seek) dc->seek = 0;
|
if(dc->seek) dc->seek = 0;
|
||||||
|
|
||||||
if(dc->stop) {
|
if(dc->stop) {
|
||||||
|
@ -282,12 +282,6 @@ int mp4_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
|
||||||
}
|
}
|
||||||
else dc->state = DECODE_STATE_STOP;
|
else dc->state = DECODE_STATE_STOP;
|
||||||
|
|
||||||
free(seekTable);
|
|
||||||
faacDecClose(decoder);
|
|
||||||
mp4ff_close(mp4fh);
|
|
||||||
fclose(fh);
|
|
||||||
free(mp4cb);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,11 @@ int queueSong(char * utf8file) {
|
||||||
else if(isWave(utf8file,NULL)) {
|
else if(isWave(utf8file,NULL)) {
|
||||||
pc->decodeType = DECODE_TYPE_AUDIOFILE;
|
pc->decodeType = DECODE_TYPE_AUDIOFILE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_AUDIOFILE
|
||||||
|
else if(isMp4(utf8file,NULL)) {
|
||||||
|
pc->decodeType = DECODE_TYPE_MP4;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
else return -1;
|
else return -1;
|
||||||
pc->queueState = PLAYER_QUEUE_FULL;
|
pc->queueState = PLAYER_QUEUE_FULL;
|
||||||
|
|
Loading…
Reference in New Issue