summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorJulian <MyFakeAcc.4@googlemail.com>2017-06-16 12:38:41 +0200
committerwm4 <wm4@nowhere>2017-10-09 20:40:32 +0200
commitfa80ac13b60745bc743feaee2bc3e5980151de03 (patch)
tree394d0c834e877e01c4a1793b053bcff33c2a5900 /player/lua
parent6f9a7d1fdb40ac7cdf7c6dbfebeedf881c75776b (diff)
downloadmpv-fa80ac13b60745bc743feaee2bc3e5980151de03.tar.bz2
mpv-fa80ac13b60745bc743feaee2bc3e5980151de03.tar.xz
stats: add support for deprecated properties
Previously, we used a property and when it was unavailable we assumed it doesn't exist before assuming it really is just unavailable. This lead to unnecessarily falling back to deprecated properties which made mpv print deprecation warnings. Now we can really check if a property is not known to mpv. The alternative would've been to check the error part of mp.get_property and perform string comparisons on the returned error message. Not sure if supporting old mpv versions is actually worth it though. Fixes #37 #36
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/stats.lua32
1 files changed, 21 insertions, 11 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index ebe523236a..814ce36d32 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -89,6 +89,23 @@ local function init_buffers()
vsjitter_buf = {0, pos = 1, len = 50, max = 0}
end
+-- Save all properties known to this version of mpv
+local property_list = {}
+for p in string.gmatch(mp.get_property("property-list"), "([^,]+)") do property_list[p] = true end
+-- Mapping of properties to their deprecated names
+local property_aliases = {
+ ["decoder-frame-drop-count"] = "drop-frame-count",
+ ["frame-drop-count"] = "vo-drop-frame-count",
+ ["container-fps"] = "fps",
+}
+-- Return deprecated name for the given property
+local function compat(p)
+ while not property_list[p] and property_aliases[p] do
+ p = property_aliases[p]
+ end
+ return p
+end
+
local function set_ASS(b)
if not o.ass_formatting then
@@ -236,8 +253,7 @@ local function append_perfdata(s)
local ds = mp.get_property_bool("display-sync-active", false)
local target_fps = ds and mp.get_property_number("display-fps", 0)
- or mp.get_property_number("container-fps", 0)
- or mp.get_property_number("fps", 0)
+ or mp.get_property_number(compat("container-fps"), 0)
if target_fps > 0 then target_fps = 1 / target_fps * 1e6 end
local last_s = vo_p["render-last"] + vo_p["present-last"] + vo_p["upload-last"]
@@ -374,13 +390,8 @@ local function add_video(s)
{no=true, [""]=true})
end
append_property(s, "avsync", {prefix="A-V:"})
- if append_property(s, "decoder-frame-drop-count", {prefix="Dropped:"}) then
- append_property(s, "frame-drop-count", {prefix="VO:", nl=""})
- append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""})
- append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""})
- -- Deprecated FPS properties for backwards compatibility
- elseif append_property(s, "drop-frame-count", {prefix="Dropped:"}) then
- append_property(s, "vo-drop-frame-count", {prefix="VO:", nl=""})
+ if append_property(s, compat("decoder-frame-drop-count"), {prefix="Dropped:"}) then
+ append_property(s, compat("frame-drop-count"), {prefix="VO:", nl=""})
append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""})
append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""})
end
@@ -391,8 +402,7 @@ local function add_video(s)
append_property(s, "estimated-display-fps",
{prefix="Display FPS:", suffix=" (estimated)"})
end
- if append_property(s, "container-fps", {prefix="FPS:", suffix=" (specified)"}) or
- append_property(s, "fps", {prefix="FPS:", suffix=" (specified)"}) then
+ if append_property(s, compat("container-fps"), {prefix="FPS:", suffix=" (specified)"}) then
append_property(s, "estimated-vf-fps",
{suffix=" (estimated)", nl="", indent=""})
else