From 9315260e76cabc94fc16bc44e44359c6adc4c1db Mon Sep 17 00:00:00 2001 From: attila Date: Thu, 1 Sep 2005 15:59:55 +0000 Subject: [PATCH] * 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 --- libmpcodecs/ad_faad.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libmpcodecs/ad_faad.c b/libmpcodecs/ad_faad.c index 909ffa7ed5..d405c1e7ef 100644 --- a/libmpcodecs/ad_faad.c +++ b/libmpcodecs/ad_faad.c @@ -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); } }