mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
player: use fixed timeout for cache pausing (buffering) duration
This tried to be clever by waiting for a longer time each time the buffer was underrunning, or shorter if it was getting better. I think this was pretty weird behavior and makes no sense. If the user really wants the stream to buffer longer, he/she/it can just pause the player (the network caches will continue to be filled until they're full). Every time I actually noticed this code triggering in my own use, I didn't find it helpful. Apart from that it was pretty hard to test. Some waiting is needed to avoid that the player just plays the available data as fast as possible (to compensate for late frames and underrunning audio). Just use a fixed wait time, which can now be controlled by the new --cache-pause-wait option.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user