mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
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.)
This commit is contained in:
parent
7e2bb7b439
commit
d32ce14d2c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user