From 8846a2f95c274aeccdf9755dffa69b2a40a942e5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 26 Nov 2013 01:49:17 +0100 Subject: [PATCH] ad_lavc: increase number of packets for initial decode Apparently just 5 packets is not enough for the initial audio decode (which is needed to find the format). The old code (before the recent refactor) appeared to use 5 packets, but there were apparently other code paths which in the end amounted to more than 5 packets being read. The sample that failed (see github issue #368) needed 9 packets. Fixes #368. --- audio/decode/ad_lavc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index 35ebce07cc..0f442cef52 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -263,9 +263,12 @@ static int init(struct dec_audio *da, const char *decoder) // Decode at least 1 sample: (to get header filled) for (int tries = 1; ; tries++) { int x = decode_new_packet(da); - if (x >= 0 && ctx->frame.samples > 0) + if (x >= 0 && ctx->frame.samples > 0) { + mp_msg(MSGT_DECAUDIO, MSGL_V, + "Initial decode succeeded after %d packets.\n", tries); break; - if (tries >= 5) { + } + if (tries >= 50) { mp_msg(MSGT_DECAUDIO, MSGL_ERR, "ad_lavc: initial decode failed\n"); uninit(da);