History

osc.lua: add option to use display fps for update interval

If the display fps is unavailable, use the tick_delay as a fallback.

nanahi committed 2 years ago

Commit f8f47d01 parent fa525262 files · +24 −2Browse files

Showing the changes to player/lua/osc.lua (1 of 2 files). Show all

Unified · Split

player/lua/osc.lua+16−2
@@ -72,6 +72,7 @@ local user_opts = { · 71 unmodified lines
7272 time_pos_outline_color = "#000000", -- color of the border timecodes in slimbox and TimePosBar
7373
7474 tick_delay = 1 / 60, -- minimum interval between OSC redraws in seconds
75+ tick_delay_follow_display_fps = false -- use display fps as the minimum interval
7576 }
7677
7778 local osc_param = { -- calculated by osc_init()
@@ -2730,6 +2731,15 @@ local function update_duration_watch() · 2652 unmodified lines
27302731 end
27312732 end
27322733
2734+local function set_tick_delay(_, display_fps)
2735+ -- may be nil if unavailable or 0 fps is reported
2736+ if not display_fps or not user_opts.tick_delay_follow_display_fps then
2737+ tick_delay = user_opts.tick_delay
2738+ return
2739+ end
2740+ tick_delay = 1 / display_fps
2741+end
2742+
27332743 mp.register_event("shutdown", shutdown)
27342744 mp.register_event("start-file", request_init)
27352745 mp.observe_property("track-list", "native", request_init)
@@ -2779,6 +2789,7 @@ mp.observe_property("idle-active", "bool", function(_, val) · 43 unmodified lines
27792789 request_tick()
27802790 end)
27812791
2792+mp.observe_property("display-fps", "number", set_tick_delay)
27822793 mp.observe_property("pause", "bool", pause_state)
27832794 mp.observe_property("demuxer-cache-state", "native", cache_state)
27842795 mp.observe_property("vo-configured", "bool", request_tick)
@@ -2970,10 +2981,12 @@ local function validate_user_opts() · 185 unmodified lines
29702981 end
29712982
29722983 -- read options from config and command-line
2973−opt.read_options(user_opts, "osc", function()
2984+opt.read_options(user_opts, "osc", function(changed)
29742985 validate_user_opts()
29752986 set_osc_styles()
2976− tick_delay = user_opts.tick_delay
2987+ if changed.tick_delay or changed.tick_delay_follow_display_fps then
2988+ set_tick_delay("display_fps", mp.get_property_number("display_fps", nil))
2989+ end
29772990 request_tick()
29782991 visibility_mode(user_opts.visibility, true)
29792992 update_duration_watch()
@@ -2982,6 +2995,7 @@ end) · 2 unmodified lines
29822995
29832996 validate_user_opts()
29842997 set_osc_styles()
2998+set_tick_delay("display_fps", mp.get_property_number("display_fps", nil))
29852999 visibility_mode(user_opts.visibility, true)
29863000 update_duration_watch()
29873001

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t