From 542b6eaac17e11f117fc92884c51bfa0217cbd10 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 23 Sep 2015 20:15:24 +0000 Subject: dtas-readahead: avoid polling on pause 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(-) (limited to 'bin/dtas-readahead') 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 -- cgit v1.2.3-24-ge0c7