summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-28 17:25:07 +0100
committerwm4 <wm4@nowhere>2020-02-28 17:25:07 +0100
commitd32ce14d2c957cdb8cc9d0fdada06fe128ab673b (patch)
treea061e7a62181cef268d1c55e1e1235fec60a3a9b
parent7e2bb7b43948eeab67a03ba0e89dbf4761027073 (diff)
downloadmpv-d32ce14d2c957cdb8cc9d0fdada06fe128ab673b.tar.bz2
mpv-d32ce14d2c957cdb8cc9d0fdada06fe128ab673b.tar.xz
demux_lavf: don't interpret errors as EOF
It seems sporadic errors are possible, such as connection timeouts. Before the recent demuxer change, the demuxer thread retried many times even on EOF, so an error was only interpreted as EOF once the decoder queues ran out. Change it to use EOF only. Since this may actually lead to the demuxer thread being "stuck" and retrying forever (depending on libavformat API behavior), I'm also adding a heuristic to prevent this, using a random retry counter. This should not be necessary, but libavformat cannot be trusted. (This retrying forever could be stopped by the user, but obviously it would still heat the CPU for a longer time if the user is not present.)
-rw-r--r--demux/demux_lavf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index fe127cdb08..0e48c3e900 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -240,6 +240,8 @@ typedef struct lavf_priv {
int linearize_ts;
bool any_ts_fixed;
+ int retry_counter;
+
AVDictionary *av_opts;
// Proxying nested streams.
@@ -1129,13 +1131,17 @@ static bool demux_lavf_read_packet(struct demuxer *demux,
update_read_stats(demux);
if (r < 0) {
av_packet_unref(pkt);
- if (r == AVERROR(EAGAIN))
- return true;
if (r == AVERROR_EOF)
return false;
MP_WARN(demux, "error reading packet: %s.\n", av_err2str(r));
- return false;
+ if (priv->retry_counter >= 10) {
+ MP_ERR(demux, "...treating it as fatal error.\n");
+ return false;
+ }
+ priv->retry_counter += 1;
+ return true;
}
+ priv->retry_counter = 0;
add_new_streams(demux);
update_metadata(demux);