From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.1 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 719E31FE1C for ; Wed, 23 Sep 2015 20:15:30 +0000 (UTC) Received: from localhost ([::1]:50455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeqRt-0005M4-TJ for dtas-all@80x24.org; Wed, 23 Sep 2015 16:15:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeqRr-0005LD-1J for dtas-all@nongnu.org; Wed, 23 Sep 2015 16:15:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeqRn-0007VN-J5 for dtas-all@nongnu.org; Wed, 23 Sep 2015 16:15:26 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:39696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeqRn-0007UD-Dl for dtas-all@nongnu.org; Wed, 23 Sep 2015 16:15:23 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id AA7C61FE1C for ; Wed, 23 Sep 2015 20:15:21 +0000 (UTC) From: Eric Wong To: Subject: [PATCH] dtas-readahead: avoid polling on pause Date: Wed, 23 Sep 2015 20:15:24 +0000 Message-Id: <20150923201524.9734-1-e@80x24.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org 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