aboutsummaryrefslogtreecommitdiffhomepage
path: root/player/lua
diff options
context:
space:
mode:
authorGravatar Ricardo Constantino <wiiaboo@gmail.com>2017-12-26 17:53:17 +0000
committerGravatar Martin Herkt <652892+lachs0r@users.noreply.github.com>2017-12-26 19:11:52 +0100
commitb51f6c59b9689b163a4ced2cd4ee9b7242eaf958 (patch)
tree7308a20a78ec1ff5f44ae284c762f81888ba6fa2 /player/lua
parent882d8ece57aa683d6908f5f9b9cf42e817bb7b9f (diff)
osc: hide cache if not forced for local files
Also hide cache if 'cache-used' is 0 (usually means video fits entirely within demuxer-cache-duration or stream cache is disabled).
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/osc.lua20
1 files changed, 7 insertions, 13 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 1be24556f3..60ddcdb39f 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -1839,30 +1839,24 @@ function osc_init()
ne.content = function ()
local dmx_cache = mp.get_property_number("demuxer-cache-duration")
- local cache_used = mp.get_property_number("cache-used", 0)
+ local cache_used = mp.get_property_number("cache-used", 0) * 1024
local dmx_cache_state = mp.get_property_native("demuxer-cache-state", {})
local is_network = mp.get_property_native("demuxer-via-network")
+ local show_cache = cache_used > 0
if dmx_cache then
dmx_cache = string.format("%3.0fs", dmx_cache)
end
if dmx_cache_state["fw-bytes"] then
- cache_used = cache_used + dmx_cache_state["fw-bytes"] / 1024
+ cache_used = cache_used + dmx_cache_state["fw-bytes"]
end
- if cache_used > 0 then
- local suffix = " KiB"
- if (cache_used >= 1024) then
- cache_used = cache_used/1024
- suffix = " MiB"
- end
- cache_used = string.format("%5.1f%s", cache_used, suffix)
- end
- if (is_network and dmx_cache) or cache_used then
+ if (is_network and dmx_cache) or show_cache then
-- Only show dmx-cache-duration by itself if it's a network file.
-- Cache can be forced even for local files, so always show that.
return string.format("Cache: %s%s%s",
(dmx_cache and dmx_cache or ""),
- ((dmx_cache and cache_used) and " + " or ""),
- (cache_used or ""))
+ ((dmx_cache and show_cache) and " | " or ""),
+ (show_cache and
+ utils.format_bytes_humanized(cache_used) or ""))
else
return ""
end