Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: multiple card selection via cam entry?



On Wed, 27 Feb 2002 13:55:25 +0100, Dirk Wiebel <dirk@wiebel.de> wrote:

> If anyone tried such a thing already I would be glad for hints.

Try the following patch for dvbapi.c. You then have to specify the cards 
as bitmask, e.g. if card 3 and 4 (starting with 1) support this station 
then you specify 1100b = 12.

Have fun.

Emil

@@ -3160,22 +3160,19 @@
 cDvbApi *cDvbApi::GetDvbApi(int Ca, int Priority)
 {
   cDvbApi *d = NULL, *dMinPriority = NULL;
-  int index = Ca - 1;
+  int indexmask;
+
+  indexmask = Ca ? Ca : ~0;
   for (int i = 0; i < MAXDVBAPI; i++) {
-      if (dvbApi[i]) {
-         if (dvbApi[i]->CardIndex() == index) { // means we need exactly _this_ device
-            d = dvbApi[i];
-            break;
-            }
-         else if (Ca == 0) { // means any device would be acceptable
-            if (!d || !dvbApi[i]->Recording() || (d->Recording() && d->Priority() > dvbApi[i]->Priority()))
-               d = dvbApi[i]; // this is one that is either not currently recording or has the lowest priority
-            if (d && d != PrimaryDvbApi && !d->Recording()) // avoids the PrimaryDvbApi if possible
-               break;
-            if (d && d->Recording() && d->Priority() < Setup.PrimaryLimit && (!dMinPriority || d->Priority() < dMinPriority->Priority()))
-               dMinPriority = d; // this is the one with the lowest priority below Setup.PrimaryLimit
-            }
-         }
+      if (!dvbApi[i] || !((1 << dvbApi[i]->CardIndex()) & indexmask))
+          continue;				// not one of the selected cards
+
+      if (!d || !dvbApi[i]->Recording() || (d->Recording() && d->Priority() > dvbApi[i]->Priority()))
+          d = dvbApi[i]; // this is one that is either not currently recording or has the lowest priority
+      if (d && d != PrimaryDvbApi && !d->Recording()) // avoids the PrimaryDvbApi if possible
+          break;
+      if (d && d->Recording() && d->Priority() < Setup.PrimaryLimit && (!dMinPriority || d->Priority() < dMinPriority->Priority()))
+          dMinPriority = d; // this is the one with the lowest priority below Setup.PrimaryLimit
       }
   if (d == PrimaryDvbApi) { // the PrimaryDvbApi was the only one that was free
      if (Priority < Setup.PrimaryLimit)
@@ -3183,10 +3180,11 @@
      if (dMinPriority)      // there's one that must not use the PrimaryDvbApi...
         d = dMinPriority;   // ...so let's kick out that one
      }
+
   return (d                           // we found one...
       && (!d->Recording()             // ...that's either not currently recording...
           || d->Priority() < Priority // ...or has a lower priority...
-          || (!d->Ca() && Ca)))       // ...or doesn't need this card
+          || (!d->Ca() && Ca)))
           ? d : NULL;
 }
 
@@ -3655,7 +3653,7 @@
   // If this card can't receive this channel, we must not actually switch
   // the channel here, because that would irritate the driver when we
   // start replaying in Transfer Mode immediately after switching the channel:
-  bool NeedsTransferMode = (this == PrimaryDvbApi && Ca && Ca != CardIndex() + 1);
+  bool NeedsTransferMode = (this == PrimaryDvbApi && Ca && !(Ca & (1 << CardIndex())));
 
   if (!NeedsTransferMode) {
 
@@ -3789,7 +3787,7 @@
   if (NeedsTransferMode) {
      cDvbApi *CaDvbApi = GetDvbApi(Ca, 0);
      if (CaDvbApi && !CaDvbApi->Recording()) {
-        if ((Result = CaDvbApi->SetChannel(ChannelNumber, Frequency, Polarization, Diseqc, Srate, Vpid, Apid1, Apid2, Dpid1, Dpid2, Tpid, Ca, Pnr)) == scrOk) {
+        if ((Result = CaDvbApi->SetChannel(ChannelNumber, Frequency, Polarization, Diseqc, Srate, Vpid, Apid1, Apid2, Dpid1, Dpid2, Tpid, Ca ? CaDvbApi->CardIndex() + 1 : Ca, Pnr)) == scrOk) {
            SetModeReplay();
            transferringFromDvbApi = CaDvbApi->StartTransfer(fd_video);
            }
@@ -4223,7 +4221,7 @@
      time_t now = time(NULL);
      if (now - lastScan > ScanTimeout && now - lastActivity > ActivityTimeout) {
         for (int i = 0; i < MAXDVBAPI; i++) {
-            cDvbApi *DvbApi = cDvbApi::GetDvbApi(i + 1, MAXPRIORITY);
+            cDvbApi *DvbApi = cDvbApi::GetDvbApi(1<<i, MAXPRIORITY);
             if (DvbApi) {
                if (DvbApi != cDvbApi::PrimaryDvbApi || (cDvbApi::NumDvbApis == 1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600)) {
                   if (!(DvbApi->Recording() || DvbApi->Replaying() || DvbApi->Transferring())) {




Home | Main Index | Thread Index