diff options
author | wm4 <wm4@nowhere> | 2019-07-07 03:34:24 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:05 +0200 |
commit | 7893ab5a7ebab3bd04571105b55a6e4486134821 (patch) | |
tree | f8fed7588b4e8e64b53b2a3992e2b03d6fc21018 /demux/demux.c | |
parent | 5c0a626deec07614fd783316dc4679fbd0a66be8 (diff) | |
download | mpv-7893ab5a7ebab3bd04571105b55a6e4486134821.tar.bz2 mpv-7893ab5a7ebab3bd04571105b55a6e4486134821.tar.xz |
demux: minor simplification for backward cache size option
Always set max_bytes_bw to 0 if seekable cache is disabled, instead at
the place of its use. This is the only use of it, so the commit should
not change any behavior.
(Alternatively, this could drop the max_bytes_bw variable, use the
option directly, and keep the old code that resets it on use of the
cache is disabled.)
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/demux/demux.c b/demux/demux.c index 967b5c9310..2056c12d11 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -2189,14 +2189,13 @@ static void prune_old_packets(struct demux_internal *in) // It's not clear what the ideal way to prune old packets is. For now, we // prune the oldest packet runs, as long as the total cache amount is too // big. - size_t max_bytes = in->seekable_cache ? in->max_bytes_bw : 0; while (1) { uint64_t fw_bytes = 0; for (int n = 0; n < in->num_streams; n++) { struct demux_stream *ds = in->streams[n]->ds; fw_bytes += get_foward_buffered_bytes(ds); } - uint64_t max_avail = max_bytes; + 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)) @@ -2370,6 +2369,9 @@ static void update_opts(struct demux_internal *in) in->seekable_cache = seekable == 1; in->using_network_cache_opts = is_streaming && use_cache; + if (!in->seekable_cache) + in->max_bytes_bw = 0; + if (!in->can_cache) { in->seekable_cache = false; in->min_secs = 0; |