about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-23 20:15:24 +0000
committerEric Wong <e@80x24.org>2015-09-24 06:56:11 +0000
commit542b6eaac17e11f117fc92884c51bfa0217cbd10 (patch)
tree6ff2557f4b477b4c5fa5a0a33683ed88931b617c
parente90e414ebf4b143b3ddbaa16460987f485ad8117 (diff)
downloaddtas-542b6eaac17e11f117fc92884c51bfa0217cbd10.tar.gz
When a player is paused with nothing player, we will not waste CPU
time polling for the player to become available.  It is wasteful
of processing power and battery life.
-rw-r--r--bin/dtas-readahead14
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/dtas-readahead b/bin/dtas-readahead
index f02bc35..798a5b4 100644
--- a/bin/dtas-readahead
+++ b/bin/dtas-readahead
@@ -190,12 +190,16 @@ begin
     end
     idx or break
     cur = YAML.load(c.req('current'))
-    cur['current'] or break
+    current = cur['current'] or break
+  end
+  if current
+    elapsed = DTAS.now - t0
+    p [:elapsed, elapsed]
+    timeout = 5 - elapsed
+    timeout = 0 if timeout < 0
+  else
+    timeout = nil
   end
-  elapsed = DTAS.now - t0
-  p [:elapsed, elapsed]
-  timeout = 5 - elapsed
-  timeout = 0 if timeout < 0
   r = wait_read(w, timeout)
   p w.res_wait if r
 rescue EOFError