summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/osd.c21
-rw-r--r--player/playloop.c14
2 files changed, 23 insertions, 12 deletions
diff --git a/player/osd.c b/player/osd.c
index b7fb841485..08bf28dd85 100644
--- a/player/osd.c
+++ b/player/osd.c
@@ -37,6 +37,7 @@
#include "osdep/timer.h"
#include "demux/demux.h"
+#include "stream/stream.h"
#include "sub/osd.h"
#include "video/out/vo.h"
@@ -232,9 +233,23 @@ static void print_status(struct MPContext *mpctx)
}
}
- float cache = mp_get_cache_percent(mpctx);
- if (cache >= 0)
- saddf(&line, " Cache: %.2f%%", cache);
+ if (mpctx->demuxer) {
+ int64_t fill = -1;
+ demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &fill);
+ if (fill >= 0) {
+ saddf(&line, " Cache: ");
+
+ struct demux_ctrl_reader_state s = {.ts_duration = -1};
+ demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
+
+ if (s.ts_duration < 0) {
+ saddf(&line, "???");
+ } else {
+ saddf(&line, "%2ds", (int)s.ts_duration);
+ }
+ saddf(&line, "+%lldKB", (long long)(fill / 1024));
+ }
+ }
if (opts->term_osd_bar) {
saddf(&line, "\n");
diff --git a/player/playloop.c b/player/playloop.c
index 89af8fa55b..319e4a89f1 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -521,18 +521,14 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
if (!mpctx->demuxer)
return;
- struct demux_ctrl_reader_state s =
- {.idle = true, .ts_range = {MP_NOPTS_VALUE, MP_NOPTS_VALUE}};
- demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
-
int idle = -1;
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle);
- double range = -1;
- if (s.ts_range[0] != MP_NOPTS_VALUE && s.ts_range[1] != MP_NOPTS_VALUE)
- range = s.ts_range[1] - s.ts_range[0];
- if (range < 0)
- range = 1e20; // unknown/broken timestamps; disable
+ struct demux_ctrl_reader_state s = {.idle = true, .ts_duration = -1};
+ demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
+
+ // disable on unknown/broken timestamps
+ double range = s.ts_duration >= 0 ? s.ts_duration : 1e20;
if (mpctx->restart_complete && idle != -1) {
if (mpctx->paused && mpctx->paused_for_cache) {