* really keep track on how many samples were decoded last round (fix 10l)

* leave loop if more than 10 faad errors were detected since the last
  call of decode_audio


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16338 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
attila 2005-09-01 15:59:55 +00:00
parent 751ec931a7
commit 9315260e76
1 changed files with 7 additions and 4 deletions

View File

@ -206,12 +206,13 @@ static int control(sh_audio_t *sh,int cmd,void* arg, ...)
return CONTROL_UNKNOWN;
}
#define MAX_FAAD_ERRORS 10
static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
{
int j = 0, len = 0;
int j = 0, len = 0, last_dec_len = 1, errors = 0;
void *faac_sample_buffer;
while(len < minlen && len > 0) {
while(len < minlen && last_dec_len > 0 && errors < MAX_FAAD_ERRORS) {
/* update buffer for raw aac streams: */
if(!sh->codecdata_len)
@ -245,9 +246,10 @@ static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: error: %s, trying to resync!\n",
faacDecGetErrorMessage(faac_finfo.error));
j++;
errors++;
} else
break;
} while(j < FAAD_BUFFLEN);
} while(j < FAAD_BUFFLEN && errors < MAX_FAAD_ERRORS);
} else {
// packetized (.mp4) aac stream:
unsigned char* bufptr=NULL;
@ -267,7 +269,8 @@ static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FAAD: Successfully decoded frame (%d Bytes)!\n",
sh->samplesize*faac_finfo.samples);
memcpy(buf+len,faac_sample_buffer, sh->samplesize*faac_finfo.samples);
len += sh->samplesize*faac_finfo.samples;
last_dec_len = sh->samplesize*faac_finfo.samples;
len += last_dec_len;
//printf("FAAD: buffer: %d bytes consumed: %d \n", k, faac_finfo.bytesconsumed);
}
}