1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-19 18:05:21 +00:00

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.
This commit is contained in:
Uoti Urpala 2011-05-03 16:52:57 +03:00
parent 78dca64301
commit 0321d683b4

View File

@ -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)