stats: do not use "tick" event

It's deprecated. The new solution works almost exactly the same way
(since the still existing internal tick event triggers vsync-jitter
change command), though as far as API usage goes, it's somewhat
questionable. (The comment is meant to discourage anyone trying to copy
the idea for external scripts.)
This commit is contained in:
wm4 2019-12-24 16:02:24 +01:00
parent f868052872
commit b9084dfd47
1 changed files with 6 additions and 2 deletions

View File

@ -814,7 +814,7 @@ local function process_key_binding(oneshot)
clear_screen() clear_screen()
remove_page_bindings() remove_page_bindings()
if recorder then if recorder then
mp.unregister_event(recorder) mp.unobserve_property(recorder)
recorder = nil recorder = nil
end end
end end
@ -822,7 +822,11 @@ local function process_key_binding(oneshot)
else else
if not oneshot and (o.plot_vsync_jitter or o.plot_vsync_ratio) then if not oneshot and (o.plot_vsync_jitter or o.plot_vsync_ratio) then
recorder = record_data(o.skip_frames) recorder = record_data(o.skip_frames)
mp.register_event("tick", recorder) -- Rely on the fact that "vsync-ratio" is updated at the same time.
-- Using "none" to get a sample any time, even if it does not change.
-- Will stop working if "vsync-jitter" property change notification
-- changes, but it's fine for an internal script.
mp.observe_property("vsync-jitter", "none", recorder)
cache_recorder_timer:resume() cache_recorder_timer:resume()
end end
display_timer:kill() display_timer:kill()