summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-07-08 22:04:35 +0200
committerwm4 <wm4@nowhere>2015-07-08 22:04:35 +0200
commit23220db92443a5748cb034edf29b4c3b428bee5a (patch)
treefc49c36cf2a3b828a06d5dbed7a3136aa6e3e02f
parent15581f2209898bdd1747d4a32f57a00ba5098fdd (diff)
downloadmpv-23220db92443a5748cb034edf29b4c3b428bee5a.tar.bz2
mpv-23220db92443a5748cb034edf29b4c3b428bee5a.tar.xz
player: disable seeking even if the cache is enabled
Until now, if a stream wasn't seekable, but the stream cache was enabled (--cache), we've enabled seeking anyway. The idea was that at least short seeks would typically fall within the cache. And if not, the user was out of luck and terrible things happened. In other words, it was unreliable. Be stricter about it and remove this behavior. Effectively, this will for example disable seeking in piped data. Instead of trying to be clever, add an --force-seekable option, which will always enable seeking if the user really wants it.
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst5
-rw-r--r--demux/demux.c5
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
5 files changed, 11 insertions, 3 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index bf2b17d1cd..7ffe4351a8 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -20,6 +20,7 @@ Interface changes
::
--- mpv 0.10.0 will be released ---
+ - add --force-seekable, and change default seekability in some cases
- add vf yadif/vavpp/vdpaupp interlaced-only suboptions
Also, the option is enabled by default (Except vf_yadif, which has
it enabled only if it's inserted by the deinterlace property.)
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index da0038bfbf..8a0587e383 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2229,6 +2229,11 @@ Demuxer
``--demuxer-readahead-bytes=<bytes>``
See ``--demuxer-readahead-packets``.
+``--force-seekable=<yes|no>``
+ If the player thinks that the media is not seekable (e.g. playing from a
+ pipe, or it's a http stream with a server that doesn't support range
+ requests), seeking will be disabled. This option can forcibly enable it.
+ For seeks within the cache, there's a good chance of success.
Input
-----
diff --git a/demux/demux.c b/demux/demux.c
index aa3308b87f..ff6bf40ec0 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -990,9 +990,8 @@ static struct demuxer *open_given_type(struct mpv_global *global,
mp_verbose(log, "Detected file format: %s\n", desc->desc);
if (!in->d_thread->seekable)
mp_verbose(log, "Stream is not seekable.\n");
- // Pretend we can seek if we can't seek, but there's a cache.
- if (!in->d_thread->seekable && stream->uncached_stream) {
- mp_verbose(log, "Enabling seeking because stream cache is active.\n");
+ if (!in->d_thread->seekable && demuxer->opts->force_seekable) {
+ mp_warn(log, "Not seekable, but enabling seeking on user request.\n");
in->d_thread->seekable = true;
in->d_thread->partially_seekable = true;
}
diff --git a/options/options.c b/options/options.c
index d92a0eef5d..7523be990a 100644
--- a/options/options.c
+++ b/options/options.c
@@ -243,6 +243,8 @@ const m_option_t mp_opts[] = {
OPT_INTRANGE("demuxer-readahead-packets", demuxer_min_packs, 0, 0, MAX_PACKS),
OPT_INTRANGE("demuxer-readahead-bytes", demuxer_min_bytes, 0, 0, MAX_PACK_BYTES),
+ OPT_FLAG("force-seekable", force_seekable, 0),
+
OPT_DOUBLE("cache-secs", demuxer_min_secs_cache, M_OPT_MIN, .min = 0),
OPT_FLAG("cache-pause", cache_pausing, 0),
diff --git a/options/options.h b/options/options.h
index 9d211390e0..b43e28a06f 100644
--- a/options/options.h
+++ b/options/options.h
@@ -199,6 +199,7 @@ typedef struct MPOpts {
double demuxer_min_secs;
char *audio_demuxer_name;
char *sub_demuxer_name;
+ int force_seekable;
double demuxer_min_secs_cache;
int cache_pausing;