From 847cbe9d5d03c77491f3139dde6e163426283ccb Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Nov 2013 18:50:00 +0100 Subject: demux: remove movi_start/movi_end fields Pointless, using stream->start_pos/end_pos instead. demux_mf was the only place where this was used specially, but we can rely on timestamps instead for this case. --- demux/demux.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index ba632218ec..1ce61da396 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -533,8 +533,6 @@ static struct demuxer *open_given_type(struct MPOpts *opts, .type = desc->type, .stream = stream, .stream_pts = MP_NOPTS_VALUE, - .movi_start = stream->start_pos, - .movi_end = stream->end_pos, .seekable = 1, .accurate_seek = true, .filepos = -1, -- cgit v1.2.3 From a49ab7cc2f9548edcfdd8ad9874050bd41e0b551 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Nov 2013 19:21:47 +0100 Subject: demux: make determining seek capability generic Instead of having each demuxer do it (only demux_mkv actually did...), let generic code determine whether the file is seekable. This requires adding exceptions to demuxers where the stream is not seekable, but the demuxer is. Sort-of try to improve handling of unseekable files in the player. Exit early if the file is determined to be unseekable, instead of resetting all decoders and then performing a pointless seek. Add an exception to allow seeking if the file is not seekable, but the stream cache is enabled. Print a warning in this case, because seeking outside the cache (which we can't prevent since the demuxer is not aware of this problem) still messes everything up. --- demux/demux.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index 1ce61da396..c6b0ebeb4e 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -533,7 +533,8 @@ static struct demuxer *open_given_type(struct MPOpts *opts, .type = desc->type, .stream = stream, .stream_pts = MP_NOPTS_VALUE, - .seekable = 1, + .seekable = (stream->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK && + stream->end_pos > 0, .accurate_seek = true, .filepos = -1, .opts = opts, @@ -564,6 +565,12 @@ static struct demuxer *open_given_type(struct MPOpts *opts, add_stream_chapters(demuxer); demuxer_sort_chapters(demuxer); demux_info_update(demuxer); + // Pretend we can seek if we can't seek, but there's a cache. + if (!demuxer->seekable && stream->uncached_stream) { + mp_msg(MSGT_DEMUXER, MSGL_WARN, + "File is not seekable, but there's a cache: enabling seeking.\n"); + demuxer->seekable = true; + } return demuxer; } @@ -632,7 +639,7 @@ void demux_flush(demuxer_t *demuxer) int demux_seek(demuxer_t *demuxer, float rel_seek_secs, int flags) { if (!demuxer->seekable) { - mp_tmsg(MSGT_SEEK, MSGL_WARN, "Cannot seek in this file.\n"); + mp_tmsg(MSGT_DEMUXER, MSGL_WARN, "Cannot seek in this file.\n"); return 0; } -- cgit v1.2.3