summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-11-01 14:28:36 +0100
committerwm4 <wm4@nowhere>2016-11-01 16:25:40 +0100
commit58383229756a8871fb312c0897914e45e5824fc1 (patch)
treea14d3301ea3508efd7e280419049993d01623cd7 /demux
parent8dff51e06c7474baf0870f5f1345fdef2149f72f (diff)
downloadmpv-58383229756a8871fb312c0897914e45e5824fc1.tar.bz2
mpv-58383229756a8871fb312c0897914e45e5824fc1.tar.xz
demux: improve buffer estimation in a corner case
This deals with the estimation of buffered packets, which is used mostly for display, but also things like pausing on low buffer levels. If a stream is fully EOF (no more packets), we don't want to include it in the total buffer amount. This also means we should make ds->eof less flaky and more stable, so don't reset it in ds_get_packets() (this function reset ds->eof just to retrigger a packet read attempt - we can have this slightly simpler). This somewhat fixes buffering display when e.g. issuing a refresh seek after re-enabling audio/video when playing with subtitles only.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 5072eb9f05..8aa9989de3 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -681,8 +681,7 @@ static void ds_get_packets(struct demux_stream *ds)
struct demux_internal *in = ds->in;
MP_DBG(in, "reading packet for %s\n", t);
in->eof = false; // force retry
- ds->eof = false;
- while (ds->selected && !ds->head && !ds->eof) {
+ while (ds->selected && !ds->head) {
ds->active = true;
// Note: the following code marks EOF if it can't continue
if (in->threading) {
@@ -692,6 +691,8 @@ static void ds_get_packets(struct demux_stream *ds)
} else {
read_packet(in);
}
+ if (ds->eof)
+ break;
}
}
@@ -1662,7 +1663,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
int num_packets = 0;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
- if (ds->active) {
+ if (ds->active && !(!ds->head && ds->eof)) {
r->underrun |= !ds->head && !ds->eof;
r->ts_range[0] = MP_PTS_MAX(r->ts_range[0], ds->base_ts);
r->ts_range[1] = MP_PTS_MIN(r->ts_range[1], ds->last_ts);