summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-05 03:03:27 +0100
committerwm4 <wm4@nowhere>2014-11-05 03:03:27 +0100
commita821e72b81029767414ed8c661532f41350cbce7 (patch)
treeba9874b0ed328b62d0be5ec48fd3da3cc6e61328 /demux/demux.c
parenta7686e86fff0412454076756f333e2e271511166 (diff)
downloadmpv-a821e72b81029767414ed8c661532f41350cbce7.tar.bz2
mpv-a821e72b81029767414ed8c661532f41350cbce7.tar.xz
demux: report 0s readahead time as fallback in some situations
If no packets are queued, the readahead time is obviously 0. If the end time is smaller than the start time, the problem is probably that audio and video start at slightly different times - report 0 in this case too. Do this because seeing "???" as readahead time is a bit annoying.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/demux/demux.c b/demux/demux.c
index b170b731c0..d3e9b43903 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1218,6 +1218,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
.ts_range = {MP_NOPTS_VALUE, MP_NOPTS_VALUE},
.ts_duration = -1,
};
+ int num_packets = 0;
for (int n = 0; n < in->d_user->num_streams; n++) {
struct demux_stream *ds = in->d_user->streams[n]->ds;
if (ds->active) {
@@ -1226,12 +1227,15 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
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);
}
+ num_packets += ds->packs;
}
}
r->idle = (in->idle && !r->underrun) || r->eof;
r->underrun &= !r->idle;
if (r->ts_range[0] != MP_NOPTS_VALUE && r->ts_range[1] != MP_NOPTS_VALUE)
- r->ts_duration = r->ts_range[1] - r->ts_range[0];
+ r->ts_duration = MPMAX(0, r->ts_range[1] - r->ts_range[0]);
+ if (!num_packets || in->seeking)
+ r->ts_duration = 0;
return DEMUXER_CTRL_OK;
}
}