summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/ad_ffmpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs/ad_ffmpeg.c')
-rw-r--r--libmpcodecs/ad_ffmpeg.c19
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)