If the display fps is unavailable, use the tick_delay as a fallback.
Showing the changes to player/lua/osc.lua (1 of 2 files). Show all
Unified · Split
| @@ -72,6 +72,7 @@ local user_opts = { · 71 unmodified lines | |||
| 72 | time_pos_outline_color = "#000000", -- color of the border timecodes in slimbox and TimePosBar | 72 | 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 seconds | 74 | 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 | ||
| 77 | local osc_param = { -- calculated by osc_init() | 78 | local osc_param = { -- calculated by osc_init() |
| @@ -2730,6 +2731,15 @@ local function update_duration_watch() · 2652 unmodified lines | |||
| 2730 | end | 2731 | end |
| 2731 | end | 2732 | end |
| 2732 | 2733 | ||
| 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 | |||
| 2733 | mp.register_event("shutdown", shutdown) | 2743 | mp.register_event("shutdown", shutdown) |
| 2734 | mp.register_event("start-file", request_init) | 2744 | mp.register_event("start-file", request_init) |
| 2735 | mp.observe_property("track-list", "native", request_init) | 2745 | mp.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() |
| 2780 | end) | 2790 | end) |
| 2781 | 2791 | ||
| 2792 | mp.observe_property("display-fps", "number", set_tick_delay) | ||
| 2782 | mp.observe_property("pause", "bool", pause_state) | 2793 | mp.observe_property("pause", "bool", pause_state) |
| 2783 | mp.observe_property("demuxer-cache-state", "native", cache_state) | 2794 | mp.observe_property("demuxer-cache-state", "native", cache_state) |
| 2784 | mp.observe_property("vo-configured", "bool", request_tick) | 2795 | mp.observe_property("vo-configured", "bool", request_tick) |
| @@ -2970,10 +2981,12 @@ local function validate_user_opts() · 185 unmodified lines | |||
| 2970 | end | 2981 | end |
| 2971 | 2982 | ||
| 2972 | -- read options from config and command-line | 2983 | -- read options from config and command-line |
| 2973 | opt.read_options(user_opts, "osc", function() | 2984 | opt.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_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 | ||
| 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 | ||
| 2983 | validate_user_opts() | 2996 | validate_user_opts() |
| 2984 | set_osc_styles() | 2997 | set_osc_styles() |
| 2998 | set_tick_delay("display_fps", mp.get_property_number("display_fps", nil)) | ||
| 2985 | visibility_mode(user_opts.visibility, true) | 2999 | visibility_mode(user_opts.visibility, true) |
| 2986 | update_duration_watch() | 3000 | update_duration_watch() |
| 2987 | 3001 | ||