diff options
author | wm4 <wm4@nowhere> | 2016-09-21 14:32:58 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-21 15:47:51 +0200 |
commit | b521f15ae9799a08d1cb328e3c1ef294d75f30c2 (patch) | |
tree | c8f4ab6e0c2eccd83704f5ca62dade1cea1f001e /player/lua/defaults.lua | |
parent | 33598182a008170b0fea05f0d149acfefaf99d0c (diff) | |
download | mpv-b521f15ae9799a08d1cb328e3c1ef294d75f30c2.tar.bz2 mpv-b521f15ae9799a08d1cb328e3c1ef294d75f30c2.tar.xz |
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.
Diffstat (limited to 'player/lua/defaults.lua')
-rw-r--r-- | player/lua/defaults.lua | 23 |
1 files changed, 11 insertions, 12 deletions
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 |