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
72 time_pos_outline_color = "#000000", -- color of the border timecodes in slimbox and TimePosBar72 time_pos_outline_color = "#000000", -- color of the border timecodes in slimbox and TimePosBar
73 73
74 tick_delay = 1 / 60, -- minimum interval between OSC redraws in seconds74 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
75}76}
76 77
77local osc_param = { -- calculated by osc_init()78local osc_param = { -- calculated by osc_init()
@@ -2730,6 +2731,15 @@ local function update_duration_watch() · 2652 unmodified lines
2730 end2731 end
2731end2732end
2732 2733
2734local 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
2741end
2742
2733mp.register_event("shutdown", shutdown)2743mp.register_event("shutdown", shutdown)
2734mp.register_event("start-file", request_init)2744mp.register_event("start-file", request_init)
2735mp.observe_property("track-list", "native", request_init)2745mp.observe_property("track-list", "native", request_init)
@@ -2779,6 +2789,7 @@ mp.observe_property("idle-active", "bool", function(_, val) · 43 unmodified lines
2779 request_tick()2789 request_tick()
2780end)2790end)
2781 2791
2792mp.observe_property("display-fps", "number", set_tick_delay)
2782mp.observe_property("pause", "bool", pause_state)2793mp.observe_property("pause", "bool", pause_state)
2783mp.observe_property("demuxer-cache-state", "native", cache_state)2794mp.observe_property("demuxer-cache-state", "native", cache_state)
2784mp.observe_property("vo-configured", "bool", request_tick)2795mp.observe_property("vo-configured", "bool", request_tick)
@@ -2970,10 +2981,12 @@ local function validate_user_opts() · 185 unmodified lines
2970end2981end
2971 2982
2972-- read options from config and command-line2983-- read options from config and command-line
2973opt.read_options(user_opts, "osc", function()2984opt.read_options(user_opts, "osc", function(changed)
2974 validate_user_opts()2985 validate_user_opts()
2975 set_osc_styles()2986 set_osc_styles()
2976 tick_delay = user_opts.tick_delay2987 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
2977 request_tick()2990 request_tick()
2978 visibility_mode(user_opts.visibility, true)2991 visibility_mode(user_opts.visibility, true)
2979 update_duration_watch()2992 update_duration_watch()
@@ -2982,6 +2995,7 @@ end) · 2 unmodified lines
2982 2995
2983validate_user_opts()2996validate_user_opts()
2984set_osc_styles()2997set_osc_styles()
2998set_tick_delay("display_fps", mp.get_property_number("display_fps", nil))
2985visibility_mode(user_opts.visibility, true)2999visibility_mode(user_opts.visibility, true)
2986update_duration_watch()3000update_duration_watch()
2987 3001

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