From 63d1d53d2fb89de0c7ff081f8b3bb78ee5e52520 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 29 Jul 2014 18:05:55 +0200 Subject: audio: ignore (some) decoding errors on initialization It probably happens relatively often that the first packet (or even the first N packets) of a stream will fail to decode, but decoding will eventually succeed at a later point. Before commit 261506e3, this was handled by an explicit retry loop (although this was also for other purposes), but with then was changed to abort on the first error. This makes it impossible to decode some audio streams. Change this so that errors are ignored for the first 50 packets, which should make it equivalent to the old code. --- audio/decode/dec_audio.h | 1 + player/audio.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h index 6d2c61d862..b76ff0b95c 100644 --- a/audio/decode/dec_audio.h +++ b/audio/decode/dec_audio.h @@ -37,6 +37,7 @@ struct dec_audio { struct af_stream *afilter; char *decoder_desc; struct replaygain_data *replaygain_data; + int init_retries; // set by decoder struct mp_audio decoded; // decoded audio set by last decode_packet() call int bitrate; // input bitrate, can change with VBR sources diff --git a/player/audio.c b/player/audio.c index ab42573fad..4bf032f3a2 100644 --- a/player/audio.c +++ b/player/audio.c @@ -361,7 +361,10 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts) int r = initial_audio_decode(mpctx->d_audio); if (r == AD_WAIT) return -1; // continue later when new data is available - if (r != AD_OK) { + mpctx->d_audio->init_retries += 1; + MP_VERBOSE(mpctx, "Initial audio packets read: %d\n", + mpctx->d_audio->init_retries); + if (r != AD_OK && mpctx->d_audio->init_retries >= 50) { MP_ERR(mpctx, "Error initializing audio.\n"); struct track *track = mpctx->current_track[0][STREAM_AUDIO]; mp_deselect_track(mpctx, track); -- cgit v1.2.3