fix a bug, due to not resetting decodeType in playerSeek when the file to

seek isn't the same as the current playing file

git-svn-id: https://svn.musicpd.org/mpd/trunk@409 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-03-23 01:12:30 +00:00
parent 4b4438853c
commit 0783a2bde1
3 changed files with 61 additions and 65 deletions

View File

@ -173,7 +173,7 @@ void initAacBuffer(FILE * fp, AacBuffer * b, float * length,
if(retFileread) *retFileread = fileread;
if(retTagsize) *retTagsize = tagsize;
if(!length) return;
if(length==NULL) return;
if((b->buffer[0] == 0xFF) && ((b->buffer[1] & 0xF6) == 0xF0)) {
adtsParse(b, length);
@ -308,12 +308,13 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
time = 0.0;
advanceAacBuffer(&b,bread);
while(!eof) {
fillAacBuffer(&b);
do {
if(dc->seek) {
dc->seekError = 1;
dc->seek = 0;
if(b.bytesIntoBuffer==0) {
eof = 1;
break;
}
sampleBuffer = faacDecDecode(decoder,&frameInfo,b.buffer,
@ -348,7 +349,7 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
sampleBufferLen = sampleCount*2;
while(sampleBufferLen>0 && !dc->seek) {
while(sampleBufferLen>0) {
size_t size = sampleBufferLen>CHUNK_SIZE-chunkLen ?
CHUNK_SIZE-chunkLen:
sampleBufferLen;
@ -357,11 +358,15 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
{
usleep(10000);
}
if(dc->stop) {
if(dc->seek) {
dc->seekError = 1;
dc->seek = 0;
}
else if(dc->stop) {
eof = 1;
break;
}
else if(!dc->seek) {
else {
sampleBufferLen-=size;
memcpy(cb->chunks+cb->end*CHUNK_SIZE+chunkLen,
sampleBuffer,size);
@ -381,10 +386,6 @@ int aac_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) {
}
}
}
fillAacBuffer(&b);
if(b.bytesIntoBuffer==0) eof = 1;
} while (!eof);
faacDecClose(decoder);

View File

@ -128,12 +128,12 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
return -1;
}
pc->totalTime = cb->totalTime;
pc->elapsedTime = 0;
pc->bitRate = 0;
pc->sampleRate = af->sampleRate;
pc->bits = af->bits;
pc->channels = af->channels;
pc->totalTime = cb->totalTime;
return 0;
}
@ -147,10 +147,11 @@ void decodeSeek(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
strcmp(dc->file,pc->file)!=0)
{
stopDecode(dc);
cb->begin = 0;
cb->end = 0;
cb->wrap = 0;
dc->error = 0;
dc->start = 1;
dc->error = 0;
waitOnDecode(pc,af,dc,cb);
}
if(*decode_pid>0 && dc->state==DECODE_STATE_DECODE) {

View File

@ -149,9 +149,31 @@ int playerInit() {
return 0;
}
int playerGetDecodeType(char * utf8file) {
if(0);
#ifdef HAVE_MAD
if(isMp3(utf8file,NULL)) return DECODE_TYPE_MP3;
#endif
#ifdef HAVE_OGG
if(isOgg(utf8file,NULL)) return DECODE_TYPE_OGG;
#endif
#ifdef HAVE_FLAC
if(isFlac(utf8file,NULL)) return DECODE_TYPE_FLAC;
#endif
#ifdef HAVE_AUDIOFILE
if(isWave(utf8file,NULL)) return DECODE_TYPE_AUDIOFILE;
#endif
#ifdef HAVE_FAAD
if(isAac(utf8file,NULL)) return DECODE_TYPE_AAC;
if(isMp4(utf8file,NULL)) return DECODE_TYPE_MP4;
#endif
return -1;
}
int playerPlay(FILE * fp, char * utf8file) {
PlayerControl * pc = &(getPlayerData()->playerControl);
if(fp==NULL) fp = stderr;
int decodeType;
if(playerStop(fp)<0) return -1;
@ -164,28 +186,13 @@ int playerPlay(FILE * fp, char * utf8file) {
}
}
if(0);
#ifdef HAVE_MAD
else if(isMp3(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP3;
#endif
#ifdef HAVE_OGG
else if(isOgg(utf8file,NULL)) pc->decodeType = DECODE_TYPE_OGG;
#endif
#ifdef HAVE_FLAC
else if(isFlac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_FLAC;
#endif
#ifdef HAVE_AUDIOFILE
else if(isWave(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AUDIOFILE;
#endif
#ifdef HAVE_FAAD
else if(isAac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AAC;
else if(isMp4(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP4;
#endif
else {
decodeType = playerGetDecodeType(utf8file);
if(decodeType < 0) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_UNKTYPE;
return 0;
}
pc->decodeType = decodeType;
strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
@ -315,36 +322,15 @@ void playerCloseAudio() {
int queueSong(char * utf8file) {
PlayerControl * pc = &(getPlayerData()->playerControl);
int decodeType;
if(pc->queueState==PLAYER_QUEUE_BLANK) {
strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
if(0);
#ifdef HAVE_MAD
else if(isMp3(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP3;
#endif
#ifdef HAVE_OGG
else if(isOgg(utf8file,NULL)) pc->decodeType = DECODE_TYPE_OGG;
#endif
#ifdef HAVE_FLAC
else if(isFlac(utf8file,NULL)) {
pc->decodeType = DECODE_TYPE_FLAC;
}
#endif
#ifdef HAVE_AUDIOFILE
else if(isWave(utf8file,NULL)) {
pc->decodeType = DECODE_TYPE_AUDIOFILE;
}
#endif
#ifdef HAVE_AUDIOFILE
else if(isAac(utf8file,NULL)) {
pc->decodeType = DECODE_TYPE_AAC;
}
else if(isMp4(utf8file,NULL)) {
pc->decodeType = DECODE_TYPE_MP4;
}
#endif
else return -1;
decodeType = playerGetDecodeType(utf8file);
if(decodeType < 0) return -1;
pc->decodeType = decodeType;
pc->queueState = PLAYER_QUEUE_FULL;
return 0;
}
@ -387,6 +373,7 @@ void playerQueueUnlock() {
int playerSeek(FILE * fp, char * utf8file, float time) {
PlayerControl * pc = &(getPlayerData()->playerControl);
char * file;
int decodeType;
if(pc->state==PLAYER_STATE_STOP) {
myfprintf(fp,"%s player not currently playing\n",
@ -395,10 +382,17 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
}
file = rmp2amp(utf8ToFsCharset(utf8file));
if(strcmp(pc->file,file)!=0) strncpy(pc->file,file,MAXPATHLEN);
/*if(playerStop(fp)<0) return -1;
if(playerPlay(stderr,file)<0) return -1;*/
/*}*/
if(strcmp(pc->file,file)!=0) {
decodeType = playerGetDecodeType(utf8file);
if(decodeType < 0) {
printf("%s unknown file type: %s\n",
COMMAND_RESPOND_ERROR, utf8file);
return -1;
}
pc->decodeType = decodeType;
strncpy(pc->file,file,MAXPATHLEN);
}
if(pc->error==PLAYER_ERROR_NOERROR) {
pc->seekWhere = time;