Skip to content

Commit e56ad90

Browse files
committed
stats.lua: fix append_property exclusions
f676a9f changed some append_property calls to append, but append does not support the exclusion feature which results in "HW: no" shown when no hwdec is active when this was not displayed before. Fix this by adding option to append_property to use get_property_cached. Fixes: f676a9f
1 parent 27c08af commit e56ad90

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

player/lua/stats.lua

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,15 @@ end
297297
-- exclude: Optional table containing keys which are considered invalid values
298298
-- for this property. Specifying this will replace empty string as
299299
-- default invalid value (nil is always invalid).
300-
local function append_property(s, prop, attr, excluded)
300+
-- cached : If true, use get_property_cached instead of get_property_osd
301+
local function append_property(s, prop, attr, excluded, cached)
301302
excluded = excluded or {[""] = true}
302-
local ret = mp.get_property_osd(prop)
303+
local ret
304+
if cached then
305+
ret = get_property_cached(prop)
306+
else
307+
ret = mp.get_property_osd(prop)
308+
end
303309
if not ret or excluded[ret] then
304310
if o.debug then
305311
print("No value for property: " .. prop)
@@ -919,8 +925,8 @@ local function add_video_out(s)
919925
append(s, "", {prefix="Display:", nl=o.nl .. o.nl, indent=""})
920926
append(s, vo, {prefix_sep="", nl="", indent=""})
921927

922-
append(s, get_property_cached("display-names"), {prefix_sep="", prefix="(", suffix=")",
923-
no_prefix_markup=true, nl="", indent=" "})
928+
append_property(s, "display-names", {prefix_sep="", prefix="(", suffix=")",
929+
no_prefix_markup=true, nl="", indent=" "}, nil, true)
924930
append(s, mp.get_property_native("current-gpu-context"),
925931
{prefix="Context:", nl="", indent=o.prefix_sep .. o.prefix_sep})
926932
append_property(s, "avsync", {prefix="A-V:"})
@@ -985,9 +991,9 @@ local function add_video(s)
985991
append(s, track["decoder"], {prefix="[", nl="", indent=" ", prefix_sep="",
986992
no_prefix_markup=true, suffix="]"})
987993
end
988-
append(s, get_property_cached("hwdec-current"), {prefix="HW:", nl="",
989-
indent=o.prefix_sep .. o.prefix_sep,
990-
no_prefix_markup=false, suffix=""}, {no=true, [""]=true})
994+
append_property(s, "hwdec-current", {prefix="HW:", nl="",
995+
indent=o.prefix_sep .. o.prefix_sep,
996+
no_prefix_markup=false, suffix=""}, {no=true, [""]=true}, true)
991997
end
992998
local has_prefix = false
993999
if o.show_frame_info then

0 commit comments

Comments
 (0)