--- ./ci.c	2005/11/04 14:18:52	1.39
+++ ./ci.c	2005/11/13 13:46:44
@@ -845,6 +845,100 @@
   return false;
 }
 
+// --- cCiCaPmt --------------------------------------------------------------
+
+// Ca Pmt List Management:
+
+#define CPLM_MORE    0x00
+#define CPLM_FIRST   0x01
+#define CPLM_LAST    0x02
+#define CPLM_ONLY    0x03
+#define CPLM_ADD     0x04
+#define CPLM_UPDATE  0x05
+
+// Ca Pmt Cmd Ids:
+
+#define CPCI_OK_DESCRAMBLING  0x01
+#define CPCI_OK_MMI           0x02
+#define CPCI_QUERY            0x03
+#define CPCI_NOT_SELECTED     0x04
+
+class cCiCaPmt : public cListObject {
+  friend class cCiConditionalAccessSupport;
+private:
+  int length;
+  int esInfoLengthPos;
+  uint8_t capmt[2048]; ///< XXX is there a specified maximum?
+  int caDescriptorsLength;
+  uint8_t caDescriptors[2048];
+  bool streamFlag;
+  void AddCaDescriptors(int Length, const uint8_t *Data);
+public:
+  cCiCaPmt(int Source, int Transponder, int ProgramNumber, const unsigned short *CaSystemIds);
+  void SetListManagement(uint8_t ListManagement);
+  bool Valid(void);
+  void AddPid(int Pid, uint8_t StreamType);
+  };
+
+cCiCaPmt::cCiCaPmt(int Source, int Transponder, int ProgramNumber, const unsigned short *CaSystemIds)
+{
+  caDescriptorsLength = GetCaDescriptors(Source, Transponder, ProgramNumber, CaSystemIds, sizeof(caDescriptors), caDescriptors, streamFlag);
+  length = 0;
+  capmt[length++] = CPLM_ONLY;
+  capmt[length++] = (ProgramNumber >> 8) & 0xFF;
+  capmt[length++] =  ProgramNumber       & 0xFF;
+  capmt[length++] = 0x01; // version_number, current_next_indicator - apparently vn doesn't matter, but cni must be 1
+  esInfoLengthPos = length;
+  capmt[length++] = 0x00; // program_info_length H (at program level)
+  capmt[length++] = 0x00; // program_info_length L
+  if (!streamFlag)
+     AddCaDescriptors(caDescriptorsLength, caDescriptors);
+}
+
+void cCiCaPmt::SetListManagement(uint8_t ListManagement)
+{
+  capmt[0] = ListManagement;
+}
+
+bool cCiCaPmt::Valid(void)
+{
+  return caDescriptorsLength > 0;
+}
+
+void cCiCaPmt::AddPid(int Pid, uint8_t StreamType)
+{
+  if (Pid) {
+     //XXX buffer overflow check???
+     capmt[length++] = StreamType;
+     capmt[length++] = (Pid >> 8) & 0xFF;
+     capmt[length++] =  Pid       & 0xFF;
+     esInfoLengthPos = length;
+     capmt[length++] = 0x00; // ES_info_length H (at ES level)
+     capmt[length++] = 0x00; // ES_info_length L
+     if (streamFlag)
+        AddCaDescriptors(caDescriptorsLength, caDescriptors);
+     }
+}
+
+void cCiCaPmt::AddCaDescriptors(int Length, const uint8_t *Data)
+{
+  if (esInfoLengthPos) {
+     if (length + Length < int(sizeof(capmt))) {
+        capmt[length++] = CPCI_OK_DESCRAMBLING;
+        memcpy(capmt + length, Data, Length);
+        length += Length;
+        int l = length - esInfoLengthPos - 2;
+        capmt[esInfoLengthPos]     = (l >> 8) & 0xFF;
+        capmt[esInfoLengthPos + 1] =  l       & 0xFF;
+        }
+     else
+        esyslog("ERROR: buffer overflow in CA descriptor");
+     esInfoLengthPos = 0;
+     }
+  else
+     esyslog("ERROR: adding CA descriptor without Pid!");
+}
+
 // --- cCiConditionalAccessSupport -------------------------------------------
 
 #define MAXCASYSTEMIDS 16
@@ -858,7 +952,7 @@
   cCiConditionalAccessSupport(int SessionId, cCiTransportConnection *Tc);
   virtual bool Process(int Length = 0, const uint8_t *Data = NULL);
   const unsigned short *GetCaSystemIds(void) { return caSystemIds; }
-  bool SendPMT(cCiCaPmt &CaPmt);
+  bool SendPMT(cCiCaPmt *CaPmt);
   };
 
 cCiConditionalAccessSupport::cCiConditionalAccessSupport(int SessionId, cCiTransportConnection *Tc)
@@ -906,10 +1000,10 @@
   return true;
 }
 
-bool cCiConditionalAccessSupport::SendPMT(cCiCaPmt &CaPmt)
+bool cCiConditionalAccessSupport::SendPMT(cCiCaPmt *CaPmt)
 {
   if (state == 2) {
-     SendData(AOT_CA_PMT, CaPmt.length, CaPmt.capmt);
+     SendData(AOT_CA_PMT, CaPmt->length, CaPmt->capmt);
      return true;
      }
   return false;
@@ -1307,78 +1401,6 @@
   return mmi && mmi->SendCloseMMI();
 }
 
-// --- cCiCaPmt --------------------------------------------------------------
-
-// Ca Pmt List Management:
-
-#define CPLM_MORE    0x00
-#define CPLM_FIRST   0x01
-#define CPLM_LAST    0x02
-#define CPLM_ONLY    0x03
-#define CPLM_ADD     0x04
-#define CPLM_UPDATE  0x05
-
-// Ca Pmt Cmd Ids:
-
-#define CPCI_OK_DESCRAMBLING  0x01
-#define CPCI_OK_MMI           0x02
-#define CPCI_QUERY            0x03
-#define CPCI_NOT_SELECTED     0x04
-
-cCiCaPmt::cCiCaPmt(int Source, int Transponder, int ProgramNumber, const unsigned short *CaSystemIds)
-{
-  caDescriptorsLength = GetCaDescriptors(Source, Transponder, ProgramNumber, CaSystemIds, sizeof(caDescriptors), caDescriptors, streamFlag);
-  length = 0;
-  capmt[length++] = CPLM_ONLY;
-  capmt[length++] = (ProgramNumber >> 8) & 0xFF;
-  capmt[length++] =  ProgramNumber       & 0xFF;
-  capmt[length++] = 0x01; // version_number, current_next_indicator - apparently vn doesn't matter, but cni must be 1
-  esInfoLengthPos = length;
-  capmt[length++] = 0x00; // program_info_length H (at program level)
-  capmt[length++] = 0x00; // program_info_length L
-  if (!streamFlag)
-     AddCaDescriptors(caDescriptorsLength, caDescriptors);
-}
-
-bool cCiCaPmt::Valid(void)
-{
-  return caDescriptorsLength > 0;
-}
-
-void cCiCaPmt::AddPid(int Pid, uint8_t StreamType)
-{
-  if (Pid) {
-     //XXX buffer overflow check???
-     capmt[length++] = StreamType;
-     capmt[length++] = (Pid >> 8) & 0xFF;
-     capmt[length++] =  Pid       & 0xFF;
-     esInfoLengthPos = length;
-     capmt[length++] = 0x00; // ES_info_length H (at ES level)
-     capmt[length++] = 0x00; // ES_info_length L
-     if (streamFlag)
-        AddCaDescriptors(caDescriptorsLength, caDescriptors);
-     }
-}
-
-void cCiCaPmt::AddCaDescriptors(int Length, const uint8_t *Data)
-{
-  if (esInfoLengthPos) {
-     if (length + Length < int(sizeof(capmt))) {
-        capmt[length++] = CPCI_OK_DESCRAMBLING;
-        memcpy(capmt + length, Data, Length);
-        length += Length;
-        int l = length - esInfoLengthPos - 2;
-        capmt[esInfoLengthPos]     = (l >> 8) & 0xFF;
-        capmt[esInfoLengthPos + 1] =  l       & 0xFF;
-        }
-     else
-        esyslog("ERROR: buffer overflow in CA descriptor");
-     esInfoLengthPos = 0;
-     }
-  else
-     esyslog("ERROR: adding CA descriptor without Pid!");
-}
-
 // -- cCiHandler -------------------------------------------------------------
 
 cCiHandler::cCiHandler(int Fd, int NumSlots)
@@ -1393,6 +1415,7 @@
       moduleReady[i] = false;
   tpl = new cCiTransportLayer(Fd, numSlots);
   tc = NULL;
+  source = transponder = 0;
 }
 
 cCiHandler::~cCiHandler()
@@ -1597,17 +1620,61 @@
          tpl->NewConnection(Slot);
          }
       }
+  SendCaPmt();
   bool UserIO = false;
   for (int i = 0; i < MAX_CI_SESSION; i++) {
       if (sessions[i] && sessions[i]->Process())
          UserIO |= sessions[i]->HasUserIO();
       }
   hasUserIO = UserIO;
-  if (newCaSupport)
-     newCaSupport = result = false; // triggers new SetCaPmt at caller!
   return result;
 }
 
+void cCiHandler::SendCaPmt(void)
+{
+  cMutexLock MutexLock(&mutex);
+  if (newCaSupport) {
+     newCaSupport = false;
+     for (int Slot = 0; Slot < numSlots; Slot++) {
+         fprintf(stderr, "SendCaPmt Slot %d\n", Slot);//XXX
+         // build the list of CA_PMT data:
+         cList<cCiCaPmt> CaPmtList;
+         for (cCiCaProgramData *p = caProgramList.First(); p; p = caProgramList.Next(p)) {
+             fprintf(stderr, "  %5d\n", p->programNumber);//XXX
+             bool Active = false;
+             cCiCaPmt *CaPmt = new cCiCaPmt(source, transponder, p->programNumber, GetCaSystemIds(Slot));
+             if (CaPmt->Valid()) {
+                for (cCiCaPidData *q = p->pidList.First(); q; q = p->pidList.Next(q)) {
+                    fprintf(stderr, "        %5d %d %d\n", q->pid, q->streamType, q->active);//XXX
+                    if (q->active) {
+                       CaPmt->AddPid(q->pid, q->streamType);
+                       Active = true;
+                       }
+                    }
+                }
+             if (Active)
+                CaPmtList.Add(CaPmt);
+             else
+                delete CaPmt;
+             }
+         // send the CA_PMT data:
+         cCiConditionalAccessSupport *cas = (cCiConditionalAccessSupport *)GetSessionByResourceId(RI_CONDITIONAL_ACCESS_SUPPORT, Slot);
+         if (cas) {
+            uint8_t ListManagement = CaPmtList.Count() > 1 ? CPLM_FIRST : CPLM_ONLY;
+            for (cCiCaPmt *CaPmt = CaPmtList.First(); CaPmt; CaPmt = CaPmtList.Next(CaPmt)) {
+                fprintf(stderr, "CA_PMT %d\n", ListManagement);//XXX
+                CaPmt->SetListManagement(ListManagement);
+                if (!cas->SendPMT(CaPmt))
+                   newCaSupport = true;
+                ListManagement = CaPmt->Next() && CaPmt->Next()->Next() ? CPLM_MORE : CPLM_LAST;
+                }
+            }
+         else
+            newCaSupport = true;
+         }
+     }
+}
+
 bool cCiHandler::EnterMenu(int Slot)
 {
   cMutexLock MutexLock(&mutex);
@@ -1676,11 +1743,50 @@
   return false;
 }
 
-bool cCiHandler::SetCaPmt(cCiCaPmt &CaPmt, int Slot)
+void cCiHandler::SetSource(int Source, int Transponder)
 {
   cMutexLock MutexLock(&mutex);
-  cCiConditionalAccessSupport *cas = (cCiConditionalAccessSupport *)GetSessionByResourceId(RI_CONDITIONAL_ACCESS_SUPPORT, Slot);
-  return cas && cas->SendPMT(CaPmt);
+  fprintf(stderr, "SetSource %X %d\n", Source, Transponder);//XXX
+  if (source != Source || transponder != Transponder) {
+     caProgramList.Clear();//XXX
+     }
+  source = Source;
+  transponder = Transponder;
+}
+
+void cCiHandler::AddPid(int ProgramNumber, int Pid, int StreamType)
+{
+  cMutexLock MutexLock(&mutex);
+  fprintf(stderr, "AddPid %5d %5d %2d\n", ProgramNumber, Pid, StreamType);//XXX
+  cCiCaProgramData *ProgramData = NULL;
+  for (cCiCaProgramData *p = caProgramList.First(); p; p = caProgramList.Next(p)) {
+      if (p->programNumber == ProgramNumber) {
+         ProgramData = p;
+         for (cCiCaPidData *q = p->pidList.First(); q; q = p->pidList.Next(q)) {
+             if (q->pid == Pid)
+                return;
+             }
+         }
+      }
+  if (!ProgramData)
+     caProgramList.Add(ProgramData = new cCiCaProgramData(ProgramNumber));
+  ProgramData->pidList.Add(new cCiCaPidData(Pid, StreamType));
+}
+
+void cCiHandler::SetPid(int Pid, bool Active)
+{
+  cMutexLock MutexLock(&mutex);
+  fprintf(stderr, "SetPid %5d %d", Pid, Active);//XXX
+  for (cCiCaProgramData *p = caProgramList.First(); p; p = caProgramList.Next(p)) {
+      for (cCiCaPidData *q = p->pidList.First(); q; q = p->pidList.Next(q)) {
+          if (q->pid == Pid) {
+             q->active = Active;
+             fprintf(stderr, " *\n");//XXX
+             return;
+             }
+         }
+      }
+  fprintf(stderr, "\n");//XXX
 }
 
 bool cCiHandler::Reset(int Slot)
--- ./ci.h	2005/10/30 12:31:14	1.18
+++ ./ci.h	2005/11/13 12:59:57
@@ -13,6 +13,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include "thread.h"
+#include "tools.h"
 
 class cCiMMI;
 
@@ -65,24 +66,31 @@
   bool Abort(void);
   };
 
-class cCiCaPmt {
-  friend class cCiConditionalAccessSupport;
-private:
-  int length;
-  int esInfoLengthPos;
-  uint8_t capmt[2048]; ///< XXX is there a specified maximum?
-  int caDescriptorsLength;
-  uint8_t caDescriptors[2048];
-  bool streamFlag;
-  void AddCaDescriptors(int Length, const uint8_t *Data);
+#define MAX_CI_SESSION  16 //XXX
+#define MAX_CI_SLOT     16
+
+class cCiCaPidData : public cListObject {
 public:
-  cCiCaPmt(int Source, int Transponder, int ProgramNumber, const unsigned short *CaSystemIds);
-  bool Valid(void);
-  void AddPid(int Pid, uint8_t StreamType);
+  bool active;
+  int pid;
+  int streamType;
+  cCiCaPidData(int Pid, int StreamType)
+  {
+    active = false;
+    pid = Pid;
+    streamType = StreamType;
+  }
   };
 
-#define MAX_CI_SESSION  16 //XXX
-#define MAX_CI_SLOT     16
+class cCiCaProgramData : public cListObject {
+public:
+  int programNumber;
+  cList<cCiCaPidData> pidList;
+  cCiCaProgramData(int ProgramNumber)
+  {
+    programNumber = ProgramNumber;
+  }
+  };
 
 class cCiSession;
 class cCiTransportLayer;
@@ -99,6 +107,9 @@
   cCiSession *sessions[MAX_CI_SESSION];
   cCiTransportLayer *tpl;
   cCiTransportConnection *tc;
+  int source;
+  int transponder;
+  cList<cCiCaProgramData> caProgramList;
   int ResourceIdToInt(const uint8_t *Data);
   bool Send(uint8_t Tag, int SessionId, int ResourceId = 0, int Status = -1);
   cCiSession *GetSessionBySessionId(int SessionId);
@@ -108,6 +119,7 @@
   bool CloseSession(int SessionId);
   int CloseAllSessions(int Slot);
   cCiHandler(int Fd, int NumSlots);
+  void SendCaPmt(void);
 public:
   ~cCiHandler();
   static cCiHandler *CreateCiHandler(const char *FileName);
@@ -121,7 +133,14 @@
   const char *GetCamName(int Slot);
   const unsigned short *GetCaSystemIds(int Slot);
   bool ProvidesCa(const unsigned short *CaSystemIds); //XXX Slot???
-  bool SetCaPmt(cCiCaPmt &CaPmt, int Slot);
+  void SetSource(int Source, int Transponder);
+       ///< XXX
+  void AddPid(int ProgramNumber, int Pid, int StreamType);
+       ///< XXX
+  void SetPid(int Pid, bool Active);
+       ///< XXX
+  void Trigger(void) { newCaSupport = true; } //XXX name??? lock???
+       ///< XXX
   bool Reset(int Slot);
   };
 
--- ./device.c	2005/11/05 15:23:58	1.111
+++ ./device.c	2005/11/12 15:35:58
@@ -397,6 +397,8 @@
               DelPid(Pid, PidType);
               return false;
               }
+           if (ciHandler)
+              ciHandler->SetPid(Pid, true);
            }
         PRINTPIDS("a");
         return true;
@@ -424,6 +426,8 @@
            DelPid(Pid, PidType);
            return false;
            }
+        if (ciHandler)
+           ciHandler->SetPid(Pid, true);
         }
      }
   return true;
@@ -450,6 +454,8 @@
            if (pidHandles[n].used == 0) {
               pidHandles[n].handle = -1;
               pidHandles[n].pid = 0;
+              if (ciHandler)
+                 ciHandler->SetPid(Pid, false);
               }
            }
         PRINTPIDS("E");
@@ -601,12 +607,24 @@
         sectionHandler->SetStatus(false);
         sectionHandler->SetChannel(NULL);
         }
+     // XXX comment
+     if (ciHandler) {
+        ciHandler->SetSource(Channel->Source(), Channel->Transponder());
+        ciHandler->AddPid(Channel->Sid(), Channel->Vpid(), 2);
+        for (const int *Apid = Channel->Apids(); *Apid; Apid++)
+            ciHandler->AddPid(Channel->Sid(), *Apid, 4);
+        for (const int *Dpid = Channel->Dpids(); *Dpid; Dpid++)
+            ciHandler->AddPid(Channel->Sid(), *Dpid, 0);
+        }
      if (SetChannelDevice(Channel, LiveView)) {
         // Start section handling:
         if (sectionHandler) {
            sectionHandler->SetChannel(Channel);
            sectionHandler->SetStatus(true);
            }
+        // XXX comment
+        if (ciHandler)
+           ciHandler->Trigger();
         }
      else
         Result = scrFailed;
@@ -1168,6 +1186,8 @@
          Unlock();
          if (!Running())
             Start();
+         if (ciHandler)
+            ciHandler->Trigger();
          return true;
          }
       }
@@ -1194,6 +1214,8 @@
       else if (receiver[i])
          receiversLeft = true;
       }
+  if (ciHandler)
+     ciHandler->Trigger();
   if (!receiversLeft)
      Cancel(3);
 }
--- ./dvbdevice.c	2005/11/11 14:53:52	1.137
+++ ./dvbdevice.c	2005/11/13 11:04:31
@@ -69,14 +69,13 @@
 
 class cDvbTuner : public cThread {
 private:
-  enum eTunerStatus { tsIdle, tsSet, tsTuned, tsLocked, tsCam };
+  enum eTunerStatus { tsIdle, tsSet, tsTuned, tsLocked };
   int fd_frontend;
   int cardIndex;
   fe_type_t frontendType;
   cCiHandler *ciHandler;
   cChannel channel;
   const char *diseqcCommands;
-  bool useCa;
   time_t startTime;
   eTunerStatus tunerStatus;
   cMutex mutex;
@@ -89,7 +88,7 @@
   cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCiHandler *CiHandler);
   virtual ~cDvbTuner();
   bool IsTunedTo(const cChannel *Channel) const;
-  void Set(const cChannel *Channel, bool Tune, bool UseCa);
+  void Set(const cChannel *Channel, bool Tune);
   bool Locked(int TimeoutMs = 0);
   };
 
@@ -100,7 +99,6 @@
   frontendType = FrontendType;
   ciHandler = CiHandler;
   diseqcCommands = NULL;
-  useCa = false;
   tunerStatus = tsIdle;
   startTime = time(NULL);
   if (frontendType == FE_QPSK)
@@ -122,16 +120,12 @@
   return tunerStatus != tsIdle && channel.Source() == Channel->Source() && channel.Transponder() == Channel->Transponder();
 }
 
-void cDvbTuner::Set(const cChannel *Channel, bool Tune, bool UseCa)
+void cDvbTuner::Set(const cChannel *Channel, bool Tune)
 {
   cMutexLock MutexLock(&mutex);
   if (Tune)
      tunerStatus = tsSet;
-  else if (tunerStatus == tsCam)
-     tunerStatus = tsLocked;
-  useCa = UseCa;
-  if (Channel->Ca() && tunerStatus != tsCam)
-     startTime = time(NULL);
+  startTime = time(NULL);//XXX
   channel = *Channel;
   newSet.Broadcast();
 }
@@ -309,7 +303,6 @@
                continue;
           case tsTuned:
           case tsLocked:
-          case tsCam:
                if (hasEvent) {
                   if (event.status & FE_REINIT) {
                      tunerStatus = tsSet;
@@ -323,28 +316,9 @@
                   }
           }
 
-        if (ciHandler) {
-           if (ciHandler->Process() && useCa) {
-              if (tunerStatus == tsLocked) {
-                 for (int Slot = 0; Slot < ciHandler->NumSlots(); Slot++) {
-                     cCiCaPmt CaPmt(channel.Source(), channel.Transponder(), channel.Sid(), ciHandler->GetCaSystemIds(Slot));
-                     if (CaPmt.Valid()) {
-                        CaPmt.AddPid(channel.Vpid(), 2);
-                        CaPmt.AddPid(channel.Apid(0), 4);
-                        CaPmt.AddPid(channel.Apid(1), 4);
-                        CaPmt.AddPid(channel.Dpid(0), 0);
-                        if (ciHandler->SetCaPmt(CaPmt, Slot)) {
-                           tunerStatus = tsCam;
-                           startTime = 0;
-                           }
-                        }
-                     }
-                 }
-              }
-           else if (tunerStatus > tsLocked)
-              tunerStatus = tsLocked;
-           }
-        // in the beginning we loop more often to let the CAM connection start up fast
+        if (ciHandler)
+           ciHandler->Process();
+        // in the beginning we loop more often to let the CAM connection start up fast //XXX obsolete??? or other comment???
         if (tunerStatus != tsTuned)
            newSet.TimedWait(mutex, (ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000);
         }
@@ -772,28 +746,35 @@
 
 bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
 {
+  fprintf(stderr, "ProvidesChannel %d %d\n", Channel->Number(), Priority);//XXX
   bool result = false;
   bool hasPriority = Priority < 0 || Priority > this->Priority();
   bool needsDetachReceivers = false;
 
   if (ProvidesSource(Channel->Source()) && ProvidesCa(Channel)) {
      result = hasPriority;
+     fprintf(stderr, "%d %d\n", __LINE__, result);//XXX
      if (Priority >= 0 && Receiving(true)) {
+        fprintf(stderr, "%d %d\n", __LINE__, result);//XXX
         if (dvbTuner->IsTunedTo(Channel)) {
+           fprintf(stderr, "%d %d\n", __LINE__, result);//XXX
            if (Channel->Vpid() && !HasPid(Channel->Vpid()) || Channel->Apid(0) && !HasPid(Channel->Apid(0))) {
+              fprintf(stderr, "%d %d\n", __LINE__, result);//XXX
 #ifdef DO_MULTIPLE_RECORDINGS
-              if (Ca() > CACONFBASE || Channel->Ca() > CACONFBASE)
+              /*XXX if (Ca() > CACONFBASE || Channel->Ca() > CACONFBASE)
                  needsDetachReceivers = Ca() != Channel->Ca();
-              else if (!IsPrimaryDevice())
+              else XXX*/if (!IsPrimaryDevice())
                  result = true;
 #ifdef DO_REC_AND_PLAY_ON_PRIMARY_DEVICE
               else
                  result = Priority >= Setup.PrimaryLimit;
+              fprintf(stderr, "%d %d\n", __LINE__, result);//XXX
 #endif
 #endif
               }
            else
               result = !IsPrimaryDevice() || Priority >= Setup.PrimaryLimit;
+           fprintf(stderr, "%d %d\n", __LINE__, result);//XXX
            }
         else
            needsDetachReceivers = true;
@@ -801,6 +782,7 @@
      }
   if (NeedsDetachReceivers)
      *NeedsDetachReceivers = needsDetachReceivers;
+  fprintf(stderr, "%d %d %d\n", __LINE__, result, needsDetachReceivers);//XXX
   return result;
 }
 
@@ -834,13 +816,13 @@
 
   // Set the tuner:
 
-  dvbTuner->Set(Channel, DoTune, !EITScanner.UsesDevice(this)); //XXX 1.3: this is an ugly hack - find a cleaner solution//XXX
+  dvbTuner->Set(Channel, DoTune);
 
   // If this channel switch was requested by the EITScanner we don't wait for
   // a lock and don't set any live PIDs (the EITScanner will wait for the lock
   // by itself before setting any filters):
 
-  if (EITScanner.UsesDevice(this))
+  if (EITScanner.UsesDevice(this)) //XXX
      return true;
 
   // PID settings:
