RFC: recording strategy on timer conflicts

Message ID 44781F22.601@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger May 27, 2006, 9:42 a.m. UTC
  Klaus Schmidinger wrote:
> Christian Wieninger wrote:
>> ...
>>> //XXX what if Priority() is < -1? -> limit to -1..MAXPRIORITY???
>>
>> how can one set a priority below -1 and what would this mean? As far 
>> as understood the cDevice class, this can only be done in a 
>> cDevice-derived class. So perhaps cDevice::Priority should limit its 
>> return value to -1 ... MAXPRIORITY?
> 
> The priority comes from the cReveicers attached to the device:
> 
>   cReceiver(int Ca, int Priority, int Pid, const int *Pids1 = NULL, 
> const int *Pids2 = NULL, const int *Pids3 = NULL);
>       ...
>       ///< Priority may be any value in the range 0..99. Negative values 
> indicate
>       ///< that this cReceiver may be detached at any time (without 
> blocking the
>       ///< cDevice it is attached to).
> 
> So officially the value can't be greater than 99, but it may well
> be any negative value. However, VDR itself only uses '-1', and I guess
> it's fair to assume that no plugin will be using too large negative
> values. To be on the safe side I guess I'll do
> 
>       imp <<= 8; imp |= min(max(device[i]->Priority() + MAXPRIORITY, 0), 
> 0xFF);
> 
> which would allow values in the range -99..99, and in any case limit the
> result to 0..255.

I just noticed that I have inadvertently removed assigning 'ndr' to the
resulting 'NeedsDetachReceivers'. So attached is an updated version of the
fix.

Klaus
  

Comments

C.Y.M May 27, 2006, 3:46 p.m. UTC | #1
> I just noticed that I have inadvertently removed assigning 'ndr' to the
> resulting 'NeedsDetachReceivers'. So attached is an updated version of the
> fix.
>
>
Klaus, does this patch you just posted nullify both of Anssi Hannula's
patches (vdr-1.4.0-transfermode-primary-limit.diff and
vdr-1.4.0-transfermode-priority4.diff) or only the "priority4" patch.

Best Regards.
  
Klaus Schmidinger May 27, 2006, 4:26 p.m. UTC | #2
Stone wrote:
> 
>     I just noticed that I have inadvertently removed assigning 'ndr' to the
>     resulting 'NeedsDetachReceivers'. So attached is an updated version
>     of the
>     fix.
> 
> 
> Klaus, does this patch you just posted nullify both of Anssi Hannula's 
> patches (vdr-1.4.0-transfermode-primary-limit.diff and 
> vdr-1.4.0-transfermode-priority4.diff) or only the "priority4" patch.

Well, first of all it was meant to fix a problem with timer conflicts.
Maybe it also helps for the problems Anssi has encountered - but that's
a question he should answer.

Klaus
  
Anssi Hannula May 28, 2006, 10:02 a.m. UTC | #3
On 5/27/06, Stone <syphyr@gmail.com> wrote:
>
>
> > I just noticed that I have inadvertently removed assigning 'ndr' to the
> > resulting 'NeedsDetachReceivers'. So attached is an updated version of the
> > fix.
> >
>
> Klaus, does this patch you just posted nullify both of Anssi Hannula's
> patches (vdr-1.4.0-transfermode-primary-limit.diff and
> vdr-1.4.0-transfermode-priority4.diff) or only the
> "priority4" patch.

It does indeed nullify the "priority4" patch :)

The vdr-1.4.0-transfermode-primary-limit.diff is still valid. It
changes the behaviour of the PrimaryLimit config option from "primary
device protector" to "liveview protector". Note that Klaus has said he
might be removing the PrimaryLimit alltogether in the near future as
it's quite useless.
  

Patch

--- device.c	2006/04/14 14:34:43	1.128
+++ device.c	2006/05/27 09:38:38
@@ -281,32 +281,20 @@ 
 cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers)
 {
   cDevice *d = NULL;
-  int select = INT_MAX;
-
+  uint Impact = 0xFFFFFFFF;
   for (int i = 0; i < numDevices; i++) {
       bool ndr;
       if (device[i]->ProvidesChannel(Channel, Priority, &ndr)) { // this device is basicly able to do the job
-         int pri;
-         if (device[i]->Receiving() && !ndr)
-            pri = 0; // receiving and allows additional receivers
-         else if (!device[i]->Receiving(true) && d && device[i]->ProvidesCa(Channel) < d->ProvidesCa(Channel))
-            pri = 1; // free and fewer Ca's
-         else if (!device[i]->Receiving() && !device[i]->HasDecoder())
-            pri = 2; // free and not a full featured card
-         else if (!device[i]->Receiving() && device[i] != ActualDevice())
-            pri = 3; // free and not the actual device
-         else if (!device[i]->Receiving() && !device[i]->IsPrimaryDevice())
-            pri = 4; // free and not the primary device
-         else if (!device[i]->Receiving())
-            pri = 5; // free
-         else if (d && device[i]->Priority() < d->Priority())
-            pri = 6; // receiving but priority is lower
-         else if (d && device[i]->Priority() == d->Priority() && device[i]->ProvidesCa(Channel) < d->ProvidesCa(Channel))
-            pri = 7; // receiving with same priority but fewer Ca's
-         else
-            pri = 8; // all others
-         if (pri <= select) {
-            select = pri;
+         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 |= min(max(device[i]->Priority() + MAXPRIORITY, 0), 0xFF);
+         imp <<= 8; imp |= min(max(device[i]->ProvidesCa(Channel), 0), 0xFF);
+         if (imp < Impact) {
+            Impact = imp;
             d = device[i];
             if (NeedsDetachReceivers)
                *NeedsDetachReceivers = ndr;