everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [PATCH] dtas-readahead: avoid polling on pause
@ 2015-09-23 20:15 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-09-23 20:15 UTC (permalink / raw)
  To: dtas-all

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.
---
 bin/dtas-readahead | 14 +++++++++-----
 1 file 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
-- 
EW



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-09-23 20:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-23 20:15 [PATCH] dtas-readahead: avoid polling on pause Eric Wong

Code repositories for project(s) associated with this public inbox

	http://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).