summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-06-14 20:14:42 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commitd34550930b208c1b24474a2a25b44fc44ab6dc0a (patch)
tree237b75f75c4097f0f95fe85bf496d7cb49316ccd
parent2575f26f2c45aafb66fc5afbdf5128bcc31a534e (diff)
downloadmpv-d34550930b208c1b24474a2a25b44fc44ab6dc0a.tar.bz2
mpv-d34550930b208c1b24474a2a25b44fc44ab6dc0a.tar.xz
stats.lua: add cache info page
Uses page 3, which was apparently reserved for filter info.
-rw-r--r--player/lua/stats.lua73
1 files changed, 69 insertions, 4 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 45e1c3855b..81f5ab8774 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -595,10 +595,75 @@ local function vo_stats()
return table.concat(stats)
end
+local function opt_time(t)
+ if type(t) == type(1.1) then
+ return mp.format_time(t)
+ end
+ return "?"
+end
+
+-- Returns an ASS string with stats about the demuxer cache etc.
+local function cache_stats()
+ local stats = {}
+
+ add_header(stats)
+ append(stats, "", {prefix=o.nl .. o.nl .. "Cache info:", nl="", indent=""})
+
+ local info = mp.get_property_native("demuxer-cache-state")
+ if info == nil then
+ append(stats, "Unavailable.", {})
+ return table.concat(stats)
+ end
+
+ append(stats, opt_time(info["reader-pts"]) .. " - " ..
+ opt_time(info["cache-end"]),
+ {prefix = "Packet queue:"})
+
+ -- These states are not necessarily exclusive. They're about potentially
+ -- separate mechanisms, whose states may be decoupled.
+ local state = "reading"
+ local seek_ts = info["debug-seeking"]
+ if seek_ts ~= nil then
+ state = "seeking (to " .. mp.format_time(seek_ts) .. ")"
+ elseif info["eof"] == true then
+ state = "eof"
+ elseif info["underrun"] then
+ state = "underrun"
+ elseif info["idle"] == true then
+ state = "inactive"
+ end
+ append(stats, state, {prefix = "State:"})
+
+ append(stats, utils.format_bytes_humanized(info["total-bytes"]),
+ {prefix = "Total RAM:"})
+ append(stats, utils.format_bytes_humanized(info["fw-bytes"]),
+ {prefix = "Forward RAM:"})
+
+ local fc = info["file-cache-bytes"]
+ if fc ~= nil then
+ fc = utils.format_bytes_humanized(fc)
+ else
+ fc = "(disabled)"
+ end
+ append(stats, fc, {prefix = "Disk cache:"})
+
+ append(stats, info["debug-low-level-seeks"], {prefix = "Media seeks:"})
+
+ append(stats, "", {prefix=o.nl .. o.nl .. "Ranges:", nl="", indent=""})
+
+ append(stats, info["bof-cached"] and "yes" or "no",
+ {prefix = "Start cached:"})
+ append(stats, info["eof-cached"] and "yes" or "no",
+ {prefix = "End cached:"})
--- Returns an ASS string with stats about filters/profiles/shaders
-local function filter_stats()
- return "coming soon"
+ local ranges = info["seekable-ranges"] or {}
+ for n, r in ipairs(ranges) do
+ append(stats, mp.format_time(r["start"]) .. " - " ..
+ mp.format_time(r["end"]),
+ {prefix = format("Range %s:", n)})
+ end
+
+ return table.concat(stats)
end
@@ -607,7 +672,7 @@ curr_page = o.key_page_1
pages = {
[o.key_page_1] = { f = default_stats, desc = "Default" },
[o.key_page_2] = { f = vo_stats, desc = "Extended Frame Timings" },
- --[o.key_page_3] = { f = filter_stats, desc = "Dummy" },
+ [o.key_page_3] = { f = cache_stats, desc = "Cache Statistics" },
}