diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index 901a8cf246..2c38361994 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -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