summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-07 15:56:52 +0100
committerwm4 <wm4@nowhere>2020-02-07 15:58:13 +0100
commit27d5d3202081ec8e328a928c117a43e3337aff83 (patch)
treefe8ae76f6f5944d2470931c4321a5988534bc933 /demux
parentc48fd48f1e39ebd6a6ef793916284d64ce2d2abc (diff)
downloadmpv-27d5d3202081ec8e328a928c117a43e3337aff83.tar.bz2
mpv-27d5d3202081ec8e328a928c117a43e3337aff83.tar.xz
demux: add option to disable "sharing" between back and forward buffers
As requested. I guess option name and manpage text could be better and clearer. Closes: #7442
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/demux/demux.c b/demux/demux.c
index a5a287e8bd..2ecfc96ba2 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -87,6 +87,7 @@ struct demux_opts {
int disk_cache;
int64_t max_bytes;
int64_t max_bytes_bw;
+ int donate_fw;
double min_secs;
int force_seekable;
double min_secs_cache;
@@ -117,6 +118,7 @@ const struct m_sub_options demux_conf = {
// of double type.)
OPT_BYTE_SIZE("demuxer-max-bytes", max_bytes, 0, 0, MAX_BYTES),
OPT_BYTE_SIZE("demuxer-max-back-bytes", max_bytes_bw, 0, 0, MAX_BYTES),
+ OPT_FLAG("demuxer-donate-buffer", donate_fw, 0),
OPT_FLAG("force-seekable", force_seekable, 0),
OPT_DOUBLE("cache-secs", min_secs_cache, M_OPT_MIN, .min = 0),
OPT_FLAG("access-references", access_references, 0),
@@ -140,6 +142,7 @@ const struct m_sub_options demux_conf = {
.enable_cache = -1, // auto
.max_bytes = 150 * 1024 * 1024,
.max_bytes_bw = 50 * 1024 * 1024,
+ .donate_fw = 1,
.min_secs = 1.0,
.min_secs_cache = 10.0 * 60 * 60,
.seekable_cache = -1,
@@ -2265,7 +2268,7 @@ static void prune_old_packets(struct demux_internal *in)
uint64_t max_avail = in->max_bytes_bw;
// Backward cache (if enabled at all) can use unused forward cache.
// Still leave 1 byte free, so the read_packet logic doesn't get stuck.
- if (max_avail && in->max_bytes > (fw_bytes + 1))
+ if (max_avail && in->max_bytes > (fw_bytes + 1) && in->opts->donate_fw)
max_avail += in->max_bytes - (fw_bytes + 1);
if (in->total_bytes - fw_bytes <= max_avail)
break;