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.
This commit is contained in:
Avi Halachmi (:avih) 2021-09-13 17:03:01 +03:00 committed by avih
parent bc6dab6d92
commit ca6108baf4
1 changed files with 11 additions and 1 deletions

View File

@ -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