mirror of https://github.com/mpv-player/mpv
demux: report correct cache state close to EOF
On EOF, this stopped reporting the actual cache duration, and just signalled unknown duration. Fix this and keep reporting whatever is left in the packet queue. This reverts commit5438a8b3
. The commit doesn't give a good explanation as to why it is needed, but I guess it was because the reporting was imperfect (it switched between unknown or 0, and the correct duration). This also removes a line added in commit848546f2
. The line is ds->active = false; The "active" flag basically says that data from this stream is actively needed, and it's used to calculate the minimum data that can actually be played (approximately). If this were ignored, a sparse subtitle stream would set the cache duration to 0s. The commit message adding the line says "actually does nothing, but in theory it's cleaner". Well, screw it.
This commit is contained in:
parent
a1e410e43a
commit
debf57bb0d
|
@ -144,6 +144,8 @@ struct demux_stream {
|
||||||
// all fields are protected by in->lock
|
// all fields are protected by in->lock
|
||||||
bool selected; // user wants packets from this stream
|
bool selected; // user wants packets from this stream
|
||||||
bool active; // try to keep at least 1 packet queued
|
bool active; // try to keep at least 1 packet queued
|
||||||
|
// if false, this stream is disabled, or passively
|
||||||
|
// read (like subtitles)
|
||||||
bool eof; // end of demuxed stream? (true if all buffer empty)
|
bool eof; // end of demuxed stream? (true if all buffer empty)
|
||||||
bool refreshing;
|
bool refreshing;
|
||||||
size_t packs; // number of packets in buffer
|
size_t packs; // number of packets in buffer
|
||||||
|
@ -431,7 +433,6 @@ static bool read_packet(struct demux_internal *in)
|
||||||
for (int n = 0; n < in->d_buffer->num_streams; n++) {
|
for (int n = 0; n < in->d_buffer->num_streams; n++) {
|
||||||
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
|
struct demux_stream *ds = in->d_buffer->streams[n]->ds;
|
||||||
ds->eof = true;
|
ds->eof = true;
|
||||||
ds->active = false;
|
|
||||||
}
|
}
|
||||||
// If we had EOF previously, then don't wakeup (avoids wakeup loop)
|
// If we had EOF previously, then don't wakeup (avoids wakeup loop)
|
||||||
if (!in->last_eof) {
|
if (!in->last_eof) {
|
||||||
|
@ -1382,10 +1383,8 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
|
||||||
struct demux_stream *ds = in->d_user->streams[n]->ds;
|
struct demux_stream *ds = in->d_user->streams[n]->ds;
|
||||||
if (ds->active) {
|
if (ds->active) {
|
||||||
r->underrun |= !ds->head && !ds->eof;
|
r->underrun |= !ds->head && !ds->eof;
|
||||||
if (!ds->eof) {
|
r->ts_range[0] = MP_PTS_MAX(r->ts_range[0], ds->base_ts);
|
||||||
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);
|
||||||
r->ts_range[1] = MP_PTS_MIN(r->ts_range[1], ds->last_ts);
|
|
||||||
}
|
|
||||||
num_packets += ds->packs;
|
num_packets += ds->packs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue