summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-09-13 17:03:01 +0300
committeravih <avih@users.noreply.github.com>2021-10-03 19:52:58 +0300
commitca6108baf4c90bdac8ebaea2d88329e77777377e (patch)
tree110e91c727cc1021bc18b647e4f6acaffaf4bb26
parentbc6dab6d92203131a2666cf83f23907c10aa5134 (diff)
downloadmpv-ca6108baf4c90bdac8ebaea2d88329e77777377e.tar.bz2
mpv-ca6108baf4c90bdac8ebaea2d88329e77777377e.tar.xz
osc.lua: avoid infinite ticks loop on idle
Before this commit, animation-end was handled at render(), however, it's not called on idle, which resulted in state.anitype ~= nil, with nothing to reset it during idle, which caused in an infinite tick() loop (starts on first mouse move). Now tick resets the animation on idle, and also, as a safety measure, if we're past 1s after the animation deadline. The safety measure is because the osc states are complex, and it's easier to detect a "we really shouldn't be animating now" at tick() itself rather than detecting the exact states where animation should be reset. Generally, the safety mmeasure is not needed.
-rw-r--r--player/lua/osc.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 4d37d766d3..19f4e9b8c4 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -2609,7 +2609,17 @@ function tick()
state.tick_last_time = mp.get_time()
if state.anitype ~= nil then
- request_tick()
+ -- state.anistart can be nil - animation should now start, or it can
+ -- be a timestamp when it started. state.idle has no animation.
+ if not state.idle and
+ (not state.anistart or
+ mp.get_time() < 1 + state.anistart + user_opts.fadeduration/1000)
+ then
+ -- animating or starting, or still within 1s past the deadline
+ request_tick()
+ else
+ kill_animation()
+ end
end
end