demux: fix dropped subtitle packets with the new stream switching

If the previous subtitle packet is too far back, and the refresh seek
won't pick it up, and the packet never comes again. As a consequence,
the refresh mode was never stopped on the subtitle stream, which caused
all packets to be discarded.

Fix by assuming the file position is monotonically increasing; then it
will resume even if a packet _after_ the intended resume point is
returned. This introduces a new requirement on how the demuxer behaves.
(I'm not sure if mp4 actually satisfies this requirement in all cases.)

Fixes a regression introduced by commit f9f2e1cc.
This commit is contained in:
wm4 2015-02-14 14:29:21 +01:00
parent bf46f4c997
commit de0f3747ee
2 changed files with 4 additions and 3 deletions

View File

@ -309,8 +309,8 @@ int demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
if (ds->refreshing) {
// Resume reading once the old position was reached (i.e. we start
// returning packets where we left off before the refresh).
drop = true;
if (dp->pos == ds->last_pos)
drop = dp->pos <= ds->last_pos;
if (dp->pos >= ds->last_pos)
ds->refreshing = false;
}

View File

@ -195,7 +195,8 @@ typedef struct demuxer {
bool rel_seeks;
// Enable fast track switching hacks. This requires from the demuxer:
// - seeking is somewhat reliable; packet contents must not change
// - packet position (demux_packet.pos) is set, not negative, and unique
// - packet position (demux_packet.pos) is set, not negative, unique, and
// monotonically increasing
// - seeking leaves packet positions invariant
bool allow_refresh_seeks;