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_lavf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'demux/demux_lavf.c') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 117dcd48ed..b2dfcb2193 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -584,9 +584,12 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) } } - if (!(priv->avif->flags & AVFMT_NOFILE) && - demuxer->stream->type != STREAMTYPE_AVDEVICE) + if ((priv->avif->flags & AVFMT_NOFILE) || + demuxer->stream->type == STREAMTYPE_AVDEVICE) { + // This might be incorrect. + demuxer->seekable = true; + } else { void *buffer = av_malloc(lavfdopts->buffersize); if (!buffer) return -1; @@ -597,9 +600,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) return -1; } priv->pb->read_seek = mp_read_seek; - priv->pb->seekable = demuxer->stream->end_pos - && (demuxer->stream->flags & MP_STREAM_SEEK) == MP_STREAM_SEEK - ? AVIO_SEEKABLE_NORMAL : 0; + priv->pb->seekable = demuxer->seekable ? AVIO_SEEKABLE_NORMAL : 0; avfc->pb = priv->pb; } -- cgit v1.2.3