summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-07-29 18:05:55 +0200
committerwm4 <wm4@nowhere>2014-07-29 18:05:55 +0200
commit63d1d53d2fb89de0c7ff081f8b3bb78ee5e52520 (patch)
tree207b73bd9bc2f0390af127a283da5ddb737a2e56
parent862d7d8a1a852fc6bb6dd13ca5db90f83b676579 (diff)
downloadmpv-63d1d53d2fb89de0c7ff081f8b3bb78ee5e52520.tar.bz2
mpv-63d1d53d2fb89de0c7ff081f8b3bb78ee5e52520.tar.xz
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.
-rw-r--r--audio/decode/dec_audio.h1
-rw-r--r--player/audio.c5
2 files changed, 5 insertions, 1 deletions
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);