summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/loadfile.c21
-rw-r--r--player/playloop.c12
-rw-r--r--player/timeline/tl_matroska.c8
-rw-r--r--player/timeline/tl_mpv_edl.c6
4 files changed, 18 insertions, 29 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 723837baa8..2a41149b11 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -743,7 +743,7 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
}
static struct track *open_external_file(struct MPContext *mpctx, char *filename,
- char *demuxer_name, int stream_cache,
+ char *demuxer_name,
enum stream_type filter)
{
struct MPOpts *opts = mpctx->opts;
@@ -755,10 +755,8 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
struct stream *stream = stream_open(filename, mpctx->global);
if (!stream)
goto err_out;
- stream_enable_cache_percent(&stream, stream_cache,
- opts->stream_cache_def_size,
- opts->stream_cache_min_percent,
- opts->stream_cache_seek_min_percent);
+ if (filter != STREAM_SUB)
+ stream_enable_cache(&stream, &opts->stream_cache);
struct demuxer_params params = {
.expect_subtitle = filter == STREAM_SUB,
};
@@ -799,13 +797,13 @@ static void open_audiofiles_from_options(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
open_external_file(mpctx, opts->audio_stream, opts->audio_demuxer_name,
- opts->audio_stream_cache, STREAM_AUDIO);
+ STREAM_AUDIO);
}
struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename)
{
struct MPOpts *opts = mpctx->opts;
- return open_external_file(mpctx, filename, opts->sub_demuxer_name, 0,
+ return open_external_file(mpctx, filename, opts->sub_demuxer_name,
STREAM_SUB);
}
@@ -821,7 +819,7 @@ static void open_subtitles_from_resolve(struct MPContext *mpctx)
if (!s)
s = talloc_asprintf(NULL, "memory://%s", sub->data);
struct track *t =
- open_external_file(mpctx, s, opts->sub_demuxer_name, 0, STREAM_SUB);
+ open_external_file(mpctx, s, opts->sub_demuxer_name, STREAM_SUB);
talloc_free(s);
if (t) {
t->lang = talloc_strdup(t, sub->lang);
@@ -1125,12 +1123,7 @@ static void play_current_file(struct MPContext *mpctx)
// Must be called before enabling cache.
mp_nav_init(mpctx);
- // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts)
- int res = stream_enable_cache_percent(&mpctx->stream,
- opts->stream_cache_size,
- opts->stream_cache_def_size,
- opts->stream_cache_min_percent,
- opts->stream_cache_seek_min_percent);
+ int res = stream_enable_cache(&mpctx->stream, &opts->stream_cache);
if (res == 0)
if (demux_was_interrupted(mpctx))
goto terminate_playback;
diff --git a/player/playloop.c b/player/playloop.c
index 9e7a673f73..835d9b0bec 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -650,17 +650,21 @@ static void handle_metadata_update(struct MPContext *mpctx)
static void handle_pause_on_low_cache(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
- int cache = mp_get_cache_percent(mpctx);
+ if (!mpctx->stream)
+ return;
+ int64_t fill = -1;
+ stream_control(mpctx->stream, STREAM_CTRL_GET_CACHE_FILL, &fill);
+ int cache_kb = fill > 0 ? (fill + 1023) / 1024 : -1;
bool idle = mp_get_cache_idle(mpctx);
if (mpctx->paused && mpctx->paused_for_cache) {
- if (cache < 0 || cache >= opts->stream_cache_min_percent || idle) {
+ if (cache_kb < 0 || cache_kb >= opts->stream_cache_unpause || idle) {
mpctx->paused_for_cache = false;
if (!opts->pause)
unpause_player(mpctx);
}
} else {
- if (cache >= 0 && cache <= opts->stream_cache_pause && !idle &&
- opts->stream_cache_pause < opts->stream_cache_min_percent)
+ if (cache_kb >= 0 && cache_kb <= opts->stream_cache_pause && !idle &&
+ opts->stream_cache_pause < opts->stream_cache_unpause)
{
bool prev_paused_user = opts->pause;
pause_player(mpctx);
diff --git a/player/timeline/tl_matroska.c b/player/timeline/tl_matroska.c
index 176d35c21f..cfcc379867 100644
--- a/player/timeline/tl_matroska.c
+++ b/player/timeline/tl_matroska.c
@@ -119,7 +119,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream,
{
struct MPOpts *opts = mpctx->opts;
- if (opts->stream_cache_size <= 0)
+ if (!stream_wants_cache(*stream, &opts->stream_cache))
return 0;
char *filename = talloc_strdup(NULL, (*demuxer)->filename);
@@ -132,11 +132,7 @@ static int enable_cache(struct MPContext *mpctx, struct stream **stream,
return -1;
}
- stream_enable_cache_percent(stream,
- opts->stream_cache_size,
- opts->stream_cache_def_size,
- opts->stream_cache_min_percent,
- opts->stream_cache_seek_min_percent);
+ stream_enable_cache(stream, &opts->stream_cache);
*demuxer = demux_open(*stream, "mkv", params, mpctx->global);
if (!*demuxer) {
diff --git a/player/timeline/tl_mpv_edl.c b/player/timeline/tl_mpv_edl.c
index 277db5b87f..7892d5294d 100644
--- a/player/timeline/tl_mpv_edl.c
+++ b/player/timeline/tl_mpv_edl.c
@@ -129,11 +129,7 @@ static struct demuxer *open_file(char *filename, struct MPContext *mpctx)
struct demuxer *d = NULL;
struct stream *s = stream_open(filename, mpctx->global);
if (s) {
- stream_enable_cache_percent(&s,
- opts->stream_cache_size,
- opts->stream_cache_def_size,
- opts->stream_cache_min_percent,
- opts->stream_cache_seek_min_percent);
+ stream_enable_cache(&s, &opts->stream_cache);
d = demux_open(s, NULL, NULL, mpctx->global);
}
if (!d) {