History

lua: idle observers: ensure timers are up-to-date

This fixes two issues, both of which resulted from the timers-wait period not being re-calculated after idle-observers were executed: - If timers were added from an idle observer then they could fire long after they were due (only when/if the next mpv event arrives). - Idle observers don't execute in zero time, and the wait period for the next timer was implicitly extended by the idle observers execution time (because it was calculated before the idle observers). This commit ensures that if idle-observers were executed, then the timers wait period is re-calculated, which solves both issues.

Avi Halachmi (:avih) committed 5 years ago

Commit 5b40db31 parent f73814b1 file · +9 −0Browse files

Showing the changes to player/lua/defaults.lua (1 of 1 file). Show all

Unified · Split

player/lua/defaults.lua+9−0
@@ -528,9 +528,18 @@ function mp.dispatch_events(allow_wait) · 527 unmodified lines
528 if not more_events then528 if not more_events then
529 wait = process_timers() or 1e20 -- infinity for all practical purposes529 wait = process_timers() or 1e20 -- infinity for all practical purposes
530 if wait ~= 0 then530 if wait ~= 0 then
531 local idle_called = nil
531 for _, handler in ipairs(idle_handlers) do532 for _, handler in ipairs(idle_handlers) do
533 idle_called = true
532 handler()534 handler()
533 end535 end
536 if idle_called then
537 -- handlers don't complete in 0 time, and may modify timers
538 wait = mp.get_next_timeout() or 1e20
539 if wait < 0 then
540 wait = 0
541 end
542 end
534 end543 end
535 -- Resume playloop - important especially if an error happened while544 -- Resume playloop - important especially if an error happened while
536 -- suspended, and the error was handled, but no resume was done.545 -- suspended, and the error was handled, but no resume was done.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t