Logo Search packages:      
Sourcecode: vdr version File versions

cDevice * cDevice::GetDevice ( const cChannel *  Channel,
int  Priority = -1,
bool *  NeedsDetachReceivers = NULL 
) [static, inherited]

Returns a device that is able to receive the given Channel at the given Priority. See ProvidesChannel() for more information on how priorities are handled, and the meaning of NeedsDetachReceivers.

Definition at line 142 of file device.c.

References cDevice::IsPrimaryDevice(), cDevice::Priority(), cDevice::ProvidesCa(), cDevice::ProvidesChannel(), and cDevice::Receiving().

{
  cDevice *d = NULL;
  int select = 7, pri;

  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
         if (device[i]->Receiving() && !ndr)
            pri = 0; // receiving and allows additional receivers
         else if (d && !device[i]->Receiving() && device[i]->ProvidesCa(Channel->Ca()) < d->ProvidesCa(Channel->Ca()))
            pri = 1; // free and fewer Ca's
         else if (!device[i]->Receiving() && !device[i]->IsPrimaryDevice())
            pri = 2; // free and not the primary device
         else if (!device[i]->Receiving())
            pri = 3; // free
         else if (d && device[i]->Priority() < d->Priority())
            pri = 4; // receiving but priority is lower
         else if (d && device[i]->Priority() == d->Priority() && device[i]->ProvidesCa(Channel->Ca()) < d->ProvidesCa(Channel->Ca()))
            pri = 5; // receiving with same priority but fewer Ca's
         else
            pri = 6; // all others
         if (pri < select) {
            select = pri;
            d = device[i];
            if (NeedsDetachReceivers)
               *NeedsDetachReceivers = ndr;
            }
         }
      }

  /*XXX+ too complex with multiple recordings per device
  if (!d && Ca > MAXDEVICES) {
     // We didn't find one the easy way, so now we have to try harder:
     int ShiftLevel = -1;
     for (int i = 0; i < numDevices; i++) {
         if (Provides[i]) { // this device is basicly able to do the job, but for some reason we didn't get it above
            int sl = device[i]->CanShift(Ca, Priority); // asks this device to shift its job to another device
            if (sl >= 0 && (ShiftLevel < 0 || sl < ShiftLevel)) {
               d = device[i]; // found one that can be shifted with the fewest number of subsequent shifts
               ShiftLevel = sl;
               }
            }
         }
     }
  XXX*/
  return d;
}


Generated by  Doxygen 1.6.0   Back to index