From 3789f1a3878a46cde7b5ef524f043c24a43b9d41 Mon Sep 17 00:00:00 2001 From: NRK Date: Sat, 21 Oct 2023 17:26:46 +0600 Subject: demux: make hysteresis-secs respect cache-secs currently hysteresis-secs only works when the demuxer-max-bytes fills up. but it's possible for the cache-secs/demuxer-readahead-secs to be reached first. in those cases, hysteresis-secs doesn't work and keeps buffering non-stop. but the goal of this option was to save power by avoiding non-stop buffering so go ahead and make it respect cache-secs as well. additionally remove some redundant repetition from the docs. --- DOCS/interface-changes.rst | 2 ++ DOCS/man/options.rst | 10 ++++------ demux/demux.c | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 827b960db8..d49e61a340 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -110,6 +110,8 @@ Interface changes - `--js-memory-report` is now used for enabling memory reporting for javascript scripts - drop support for `-del` syntax for list options + - `--demuxer-hysteresis-secs` now respects `--cache-secs` and/or + `--demuxer-readahead-secs` as well --- mpv 0.36.0 --- - add `--target-contrast` - Target luminance value is now also applied when ICC profile is used. diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 351294b110..a4fb20f8a0 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3908,18 +3908,16 @@ Demuxer timestamps.) ``--demuxer-hysteresis-secs=`` - Once the ``--demuxer-max-bytes`` limit is reached, this value can be used + Once the demuxer limit is reached (``--demuxer-max-bytes``, + ``--demuxer-readahead-secs`` or ``--cache-secs``), this value can be used to specify a hysteresis before the demuxer will buffer ahead again. This specifies the maximum number of seconds from the current playback position that needs to be remaining in the cache before the demuxer will continue buffering ahead. For example, with a value of 10 seconds specified, the demuxer will buffer - ahead up to ``--demuxer-max-bytes`` and won't start buffering ahead again - until there is only 10 seconds of content left in the cache. When the - demuxer starts buffering ahead again, it will buffer ahead up to - ``--demuxer-max-bytes`` and stop until there's only 10 seconds of content - remaining in the cache, and so on. + ahead up to the demuxer limit and won't start buffering ahead again until + there is only 10 seconds of content left in the cache. This can provide significant power savings and reduce load by making the demuxer only buffer ahead in chunks at a time rather than buffering ahead diff --git a/demux/demux.c b/demux/demux.c index e44ba75eea..58b6b6ed81 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -2235,8 +2235,10 @@ static bool read_packet(struct demux_internal *in) return false; } - if (!read_more && !prefetch_more && !refresh_more) + if (!read_more && !prefetch_more && !refresh_more) { + in->hyst_active = !!in->hyst_secs; return false; + } if (in->after_seek_to_start) { for (int n = 0; n < in->num_streams; n++) { -- cgit v1.2.3