diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-05-03 16:52:57 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-05-03 16:52:57 +0300 |
commit | 0321d683b4b970fd1025f8613c6a0ce9fcc98716 (patch) | |
tree | b11901084ca9f8d5e1167a966b34ecb474af3064 /libmpcodecs | |
parent | 78dca643015fb5ff23e68bd5032a55cafba8b31f (diff) | |
download | mpv-0321d683b4b970fd1025f8613c6a0ce9fcc98716.tar.bz2 mpv-0321d683b4b970fd1025f8613c6a0ce9fcc98716.tar.xz |
ad_ffmpeg: return failure from init() if initial decode fails
The init() method in ad_ffmpeg tries to decode some audio data after
opening the libavcodec decoder; however the method returned success
even if this part failed. Change it to return failure instead,
indicating that the codec could not be successfully opened.
This improves behavior at least with some AAC files, for which the
libavcodec decoder can be successfully initialized but decoding
packets always fails. Before the audio would be decoded with
libavcodec, producing only a constant stream of errors; after this
commit audio decoder initialization falls back to FAAD (if available)
which works for these samples.
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/ad_ffmpeg.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c index 8f56e71b5d..b4ecd628c4 100644 --- a/libmpcodecs/ad_ffmpeg.c +++ b/libmpcodecs/ad_ffmpeg.c @@ -98,8 +98,6 @@ static int setup_format(sh_audio_t *sh_audio, const AVCodecContext *lavc_context static int init(sh_audio_t *sh_audio) { struct MPOpts *opts = sh_audio->opts; - int tries = 0; - int x; AVCodecContext *lavc_context; AVCodec *lavc_codec; @@ -168,10 +166,19 @@ static int init(sh_audio_t *sh_audio) } // Decode at least 1 byte: (to get header filled) - do { - x=decode_audio(sh_audio,sh_audio->a_buffer,1,sh_audio->a_buffer_size); - } while (x <= 0 && tries++ < 5); - if(x>0) sh_audio->a_buffer_len=x; + for (int tries = 0;;) { + int x = decode_audio(sh_audio, sh_audio->a_buffer, 1, + sh_audio->a_buffer_size); + if (x > 0) { + sh_audio->a_buffer_len = x; + break; + } + if (++tries >= 5) { + mp_msg(MSGT_DECAUDIO, MSGL_ERR, + "ad_ffmpeg: initial decode failed\n"); + return 0; + } + } sh_audio->i_bps=lavc_context->bit_rate/8; if (sh_audio->wf && sh_audio->wf->nAvgBytesPerSec) |