mirror of
https://github.com/mpv-player/mpv
synced 2025-02-04 06:01:56 +00:00
lua: run timers only after draining the event queue
Instead of rechecking the timers every time after an event is read, do it only once the event queue is empty. This is probably slightly more efficient, and facilitates the next commit.
This commit is contained in:
parent
33598182a0
commit
b521f15ae9
@ -451,16 +451,14 @@ function mp.dispatch_events(allow_wait)
|
||||
mp.suspend()
|
||||
end
|
||||
while mp.keep_running do
|
||||
local wait = process_timers()
|
||||
if wait == nil then
|
||||
wait = 1e20 -- infinity for all practical purposes
|
||||
end
|
||||
if more_events or wait < 0 then
|
||||
wait = 0
|
||||
end
|
||||
-- Resume playloop - important especially if an error happened while
|
||||
-- suspended, and the error was handled, but no resume was done.
|
||||
if wait > 0 then
|
||||
local wait = 0
|
||||
if not more_events then
|
||||
wait = process_timers()
|
||||
if wait == nil then
|
||||
wait = 1e20 -- infinity for all practical purposes
|
||||
end
|
||||
-- Resume playloop - important especially if an error happened while
|
||||
-- suspended, and the error was handled, but no resume was done.
|
||||
mp.resume_all()
|
||||
if allow_wait ~= true then
|
||||
return
|
||||
@ -472,9 +470,10 @@ function mp.dispatch_events(allow_wait)
|
||||
if mp.use_suspend then
|
||||
mp.suspend()
|
||||
end
|
||||
more_events = (e.event ~= "none")
|
||||
if more_events then
|
||||
more_events = false
|
||||
if e.event ~= "none" then
|
||||
call_event_handlers(e)
|
||||
more_events = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user