From patchwork Sun May 10 17:35:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jlacvdr X-Patchwork-Id: 12727 Received: from mail-fx0-f165.google.com ([209.85.220.165]) by mail.linuxtv.org with esmtp (Exim 4.63) (envelope-from ) id 1M3Cwa-0000F6-6J for vdr@linuxtv.org; Sun, 10 May 2009 19:36:09 +0200 Received: by fxm9 with SMTP id 9so2354608fxm.17 for ; Sun, 10 May 2009 10:35:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.60.148 with SMTP id p20mr5954593bkh.165.1241976934631; Sun, 10 May 2009 10:35:34 -0700 (PDT) Date: Sun, 10 May 2009 19:35:34 +0200 Message-ID: From: jlacvdr To: VDR Mailing List X-LSpam-Score: -2.4 (--) X-LSpam-Report: No, score=-2.4 required=5.0 tests=AWL=0.195, BAYES_00=-2.599 autolearn=ham Subject: [vdr] [patch] optimize device selection X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 May 2009 17:36:09 -0000 Status: O X-Status: X-Keywords: X-UID: 20396 Hi, This patch is for vdr users's which have several cards. He changes the device selection, by adding two factors in the 'impact' choice : - prefering a already tuned device - the last usage time of device So, all devices are used and zapping time is reduce. Works better when eitscanner is disable. Regards, JLac diff -bBurN vdr-1.7.7-orig/device.c vdr-1.7.7/device.c --- vdr-1.7.7-orig/device.c 2009-05-02 14:17:39.000000000 +0200 +++ vdr-1.7.7/device.c 2009-05-10 18:52:27.000000000 +0200 @@ -84,6 +84,7 @@ camSlot = NULL; startScrambleDetection = 0; + startReceiving = 0; player = NULL; isPlayingVideo = false; @@ -264,6 +265,11 @@ // to their individual severity, where the one listed first will make the most // difference, because it results in the most significant bit of the result. uint32_t imp = 0; + + imp <<= 1; imp |= device[i]->IsTunedToTransponder(Channel) ? 0 : 1; // prefer device already tune + int t=((time(NULL)-device[i]->startReceiving)/16); + imp <<= 4; imp |= t > 0x0f ? 0 : 0x0f-t; // sort devices by last time usage + imp <<= 1; imp |= LiveView ? !device[i]->IsPrimaryDevice() || ndr : 0; // prefer the primary device for live viewing if we don't need to detach existing receivers imp <<= 1; imp |= !device[i]->Receiving() && (device[i] != cTransferControl::ReceiverDevice() || device[i]->IsPrimaryDevice()) || ndr; // use receiving devices if we don't need to detach existing receivers, but avoid primary device in local transfer mode imp <<= 1; imp |= device[i]->Receiving(); // avoid devices that are receiving @@ -290,6 +296,7 @@ break; // no CAM necessary, so just one loop over the devices } if (d) { + d->startReceiving = time(NULL); if (NeedsDetachReceivers) d->DetachAllReceivers(); if (s) { diff -bBurN vdr-1.7.7-orig/device.h vdr-1.7.7/device.h --- vdr-1.7.7-orig/device.h 2009-05-02 14:16:20.000000000 +0200 +++ vdr-1.7.7/device.h 2009-05-10 18:49:00.000000000 +0200 @@ -340,6 +340,7 @@ private: time_t startScrambleDetection; + time_t startReceiving; cCamSlot *camSlot; public: virtual bool HasCi(void);