From b9084dfd47881492b53bd660bfaea88e80f1e547 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 24 Dec 2019 16:02:24 +0100 Subject: 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.) --- player/lua/stats.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'player') diff --git a/player/lua/stats.lua b/player/lua/stats.lua index aa95592694..0749dbaf40 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -814,7 +814,7 @@ local function process_key_binding(oneshot) clear_screen() remove_page_bindings() if recorder then - mp.unregister_event(recorder) + mp.unobserve_property(recorder) recorder = nil end end @@ -822,7 +822,11 @@ local function process_key_binding(oneshot) else if not oneshot and (o.plot_vsync_jitter or o.plot_vsync_ratio) then 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() end display_timer:kill() -- cgit v1.2.3