diff options
author | wm4 <wm4@nowhere> | 2017-11-03 16:36:21 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-11-03 16:36:21 +0100 |
commit | 49ae599883a2c61143ec728dd45f1827c2e878b2 (patch) | |
tree | ae31e35b73b8d59701adb7ce2bd2440dac61b1ee /demux/demux.c | |
parent | 5261d1b099edf16712582790085f4d369438dfe5 (diff) | |
download | mpv-49ae599883a2c61143ec728dd45f1827c2e878b2.tar.bz2 mpv-49ae599883a2c61143ec728dd45f1827c2e878b2.tar.xz |
demux: don't show queue overflow warning when merely prefetching
If fulfilling --demuxer-readahead-secs requires more memory than allowed
by --demuxer-max-bytes, the queue obviously overflows. But the warning
is normally only for the case when trying to find the next video or
audio packet fails, and decoding can't continue.
Use a separate variable for determining whether to prefetch, and if the
queue has overflown, skip the message. In fact, skip the EOF setting and
waking up the decoder thread as well, because the EOF flag should not be
(have been) set in this situation, and waking up the reader thread helps
only if the EOF state changed.
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/demux/demux.c b/demux/demux.c index f00a1c8069..2283a0773b 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -702,7 +702,7 @@ static bool read_packet(struct demux_internal *in) // Check if we need to read a new packet. We do this if all queues are below // the minimum, or if a stream explicitly needs new packets. Also includes // safe-guards against packet queue overflow. - bool active = false, read_more = false; + bool active = false, read_more = false, prefetch_more = false; size_t bytes = 0; for (int n = 0; n < in->num_streams; n++) { struct demux_stream *ds = in->streams[n]->ds; @@ -711,11 +711,13 @@ static bool read_packet(struct demux_internal *in) bytes += ds->fw_bytes; if (ds->active && ds->last_ts != MP_NOPTS_VALUE && in->min_secs > 0 && ds->last_ts >= ds->base_ts) - read_more |= ds->last_ts - ds->base_ts < in->min_secs; + prefetch_more |= ds->last_ts - ds->base_ts < in->min_secs; } - MP_DBG(in, "bytes=%zd, active=%d, more=%d\n", - bytes, active, read_more); + MP_DBG(in, "bytes=%zd, active=%d, read_more=%d prefetch_more=%d\n", + bytes, active, read_more, prefetch_more); if (bytes >= in->max_bytes) { + if (!read_more) + return false; if (!in->warned_queue_overflow) { in->warned_queue_overflow = true; MP_WARN(in, "Too many packets in the demuxer packet queues:\n"); @@ -743,9 +745,8 @@ static bool read_packet(struct demux_internal *in) double seek_pts = get_refresh_seek_pts(in); bool refresh_seek = seek_pts != MP_NOPTS_VALUE; - read_more |= refresh_seek; - if (!read_more) + if (!read_more && !refresh_seek && !prefetch_more) return false; // Actually read a packet. Drop the lock while doing so, because waiting |