diff options
-rw-r--r-- | DOCS/man/options.rst | 9 | ||||
-rw-r--r-- | options/options.c | 2 | ||||
-rw-r--r-- | options/options.h | 1 | ||||
-rw-r--r-- | player/core.h | 2 | ||||
-rw-r--r-- | player/playloop.c | 12 |
5 files changed, 15 insertions, 11 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 556299853f..3d1c2ade2d 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3856,6 +3856,15 @@ Cache data and stalls decoding/playback (default: yes). If enabled, it will pause and unpause once more data is available, aka "buffering". +``--cache-pause-wait=<seconds>`` + Number of seconds the packet cache should have buffered before starting + playback again if "buffering" was entered (default: 1). This can be used + to control how long the player rebuffers if ``--cache-pause`` is enabled, + and the demuxer underruns. If the given time is higher than the maximum + set with ``--cache-secs`` or ``--demuxer-readahead-secs``, or prefetching + ends before that for some other reason (like file end), playback resumes + earlier. + Network ------- diff --git a/options/options.c b/options/options.c index 4e40d77a90..030ba6f9e6 100644 --- a/options/options.c +++ b/options/options.c @@ -451,6 +451,7 @@ const m_option_t mp_opts[] = { OPT_FLAG("demuxer-thread", demuxer_thread, 0), OPT_FLAG("prefetch-playlist", prefetch_open, 0), OPT_FLAG("cache-pause", cache_pausing, 0), + OPT_FLOAT("cache-pause-wait", cache_pause_wait, M_OPT_MIN, .min = 0), OPT_DOUBLE("mf-fps", mf_fps, 0), OPT_STRING("mf-type", mf_type, 0), @@ -894,6 +895,7 @@ const struct MPOpts mp_default_opts = { .demuxer_thread = 1, .hls_bitrate = INT_MAX, .cache_pausing = 1, + .cache_pause_wait = 1.0, .chapterrange = {-1, -1}, .ab_loop = {MP_NOPTS_VALUE, MP_NOPTS_VALUE}, .edition_id = -1, diff --git a/options/options.h b/options/options.h index 3f90a2b78f..3774b7b343 100644 --- a/options/options.h +++ b/options/options.h @@ -263,6 +263,7 @@ typedef struct MPOpts { char *sub_demuxer_name; int cache_pausing; + float cache_pause_wait; struct image_writer_opts *screenshot_image_opts; char *screenshot_template; diff --git a/player/core.h b/player/core.h index 4f4765d3e5..cee1bf3bc2 100644 --- a/player/core.h +++ b/player/core.h @@ -432,7 +432,7 @@ typedef struct MPContext { bool playing_msg_shown; bool paused_for_cache; - double cache_stop_time, cache_wait_time; + double cache_stop_time; int cache_buffer; // Set after showing warning about decoding being too slow for realtime diff --git a/player/playloop.c b/player/playloop.c index 46e93dd64a..632ccd0999 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -234,7 +234,6 @@ void reset_playback_state(struct MPContext *mpctx) mpctx->current_seek = (struct seek_params){0}; mpctx->playback_pts = MP_NOPTS_VALUE; mpctx->last_seek_pts = MP_NOPTS_VALUE; - mpctx->cache_wait_time = 0; mpctx->step_frames = 0; mpctx->ab_loop_clip = true; mpctx->restart_complete = false; @@ -620,14 +619,8 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx) if (mpctx->restart_complete && use_pause_on_low_cache) { if (mpctx->paused && mpctx->paused_for_cache) { if (!s.underrun && (!opts->cache_pausing || s.idle || - s.ts_duration >= mpctx->cache_wait_time)) + s.ts_duration >= opts->cache_pause_wait)) { - double elapsed_time = now - mpctx->cache_stop_time; - if (elapsed_time > mpctx->cache_wait_time) { - mpctx->cache_wait_time *= 1.5 + 0.1; - } else { - mpctx->cache_wait_time /= 1.5 - 0.1; - } mpctx->paused_for_cache = false; update_internal_pause_state(mpctx); force_update = true; @@ -641,10 +634,9 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx) force_update = true; } } - mpctx->cache_wait_time = MPCLAMP(mpctx->cache_wait_time, 1, 10); if (mpctx->paused_for_cache) { cache_buffer = - 100 * MPCLAMP(s.ts_duration / mpctx->cache_wait_time, 0, 0.99); + 100 * MPCLAMP(s.ts_duration / opts->cache_pause_wait, 0, 0.99); } } |