From patchwork Fri May 26 13:18:03 2006 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Schmidinger X-Patchwork-Id: 12318 Received: from raven.cadsoft.de ([217.7.101.211]) by www.linuxtv.org with esmtp (Exim 4.50) id 1FjcCe-0002ca-7E for vdr@linuxtv.org; Fri, 26 May 2006 15:18:08 +0200 Received: from [192.168.100.10] (hawk.cadsoft.de [192.168.100.10]) by raven.cadsoft.de (8.13.3/8.13.3) with ESMTP id k4QDI6gx010620 for ; Fri, 26 May 2006 15:18:06 +0200 Message-ID: <4477000B.60408@cadsoft.de> Date: Fri, 26 May 2006 15:18:03 +0200 From: Klaus Schmidinger Organization: CadSoft Computer GmbH User-Agent: Thunderbird 1.5.0.2 (X11/20060420) MIME-Version: 1.0 To: vdr@linuxtv.org Subject: Re: [vdr] RFC: recording strategy on timer conflicts References: <200605200840.48851.cwieninger@gmx.de> <200605232032.42463.cwieninger@gmx.de> <44736A21.1030302@gmx.net> <200605232332.14916.cwieninger@gmx.de> In-Reply-To: <200605232332.14916.cwieninger@gmx.de> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (raven.cadsoft.de [192.168.1.1]); Fri, 26 May 2006 15:18:07 +0200 (CEST) X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 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: Fri, 26 May 2006 13:18:08 -0000 Status: O X-Status: X-Keywords: X-UID: 9599 Christian Wieninger wrote: > Am Dienstag, 23. Mai 2006 22:01 schrieb Andreas Brugger: >> This isn't as easy as I thought ... > > no it isn't ;-) But I think my patch should solve the problem. At least it > works fine here. So let's see what Klaus is thinking of it (if he is reading > this). I believe the main problem with the current GetDevice() function is that it doesn't query *all* devices, but rather selects the "first best" device. The attached patch implements a new way of selecting the device. It makes sure all devices are queried and selects the one with the least "impact". The various criteria are represented as parts of an integer number, and in the end the device with the smallest value wins. The most important criteria are pushed into the integer first, resulting in the highest order bits, thus making the most difference. In this patch the new calculation is done in parallel to the old one, and the result is logged in case the decision would be different. The final result is still taken from the old calculation, but once you find the new one stable enough, you can enable the 'return dd' line. There is a lot of debug output in there, so that we can see the individual parts of the decision making. This will be removed in the final version. Please give this a try, and let me know whether it fixes all known problems. Klaus --- device.c 2006/04/14 14:34:43 1.128 +++ device.c 2006/05/26 13:07:12 @@ -313,6 +313,47 @@ } } } + //XXX + { + cDevice *dd = NULL;//XXX + uint Impact = 0xFFFFFFFF; + for (int i = 0; i < numDevices; i++) { + printf("%d ", i + 1);//XXX + bool ndr; + if (device[i]->ProvidesChannel(Channel, Priority, &ndr)) { // this device is basicly able to do the job + uint imp = 0; + imp <<= 1; imp |= !device[i]->Receiving() || ndr; + imp <<= 1; imp |= device[i]->Receiving(); + imp <<= 1; imp |= device[i] == ActualDevice(); + imp <<= 1; imp |= device[i]->IsPrimaryDevice(); + imp <<= 1; imp |= device[i]->HasDecoder(); + imp <<= 8; imp |= device[i]->Priority() + 1; //XXX what if Priority() is < -1? -> limit to -1..MAXPRIORITY??? + imp <<= 8; imp |= device[i]->ProvidesCa(Channel); //XXX limit to 0..255??? + if (imp < Impact) { + Impact = imp; + dd = device[i]; + } + printf(" %d", !device[i]->Receiving() || ndr);//XXX + printf(" %d", device[i]->Receiving());//XXX + printf(" %d", device[i] == ActualDevice());//XXX + printf(" %d", device[i]->IsPrimaryDevice());//XXX + printf(" %d", device[i]->HasDecoder());//XXX + printf(" %3d", device[i]->Priority() + 1);//XXX + printf(" %d", device[i]->ProvidesCa(Channel));//XXX + printf(" - %08X ", imp);//XXX + } + else {//XXX + printf(" -");//XXX + }//XXX + printf("\n");//XXX + } + if (dd && d)//XXX + printf("--> %d (%d)\n", dd->CardIndex() + 1, d->CardIndex() + 1);//XXX + if (dd && d && dd != d)//XXX + dsyslog("******* new GetDevice would select device %d instead of %d", dd->CardIndex() + 1, d->CardIndex() + 1);//XXX + //return dd; //XXX activate this if you trust it + } + //XXX return d; }