better solution to add possibility to delete eSocketNotifiers,
[vuplus_dvbapp] / lib / dvb_ci / dvbci.cpp
index d8b3b0b..7525040 100644 (file)
@@ -45,6 +45,9 @@ eDVBCIInterfaces::eDVBCIInterfaces()
                ++num_ci;
        }
 
+       for (eSmartPtrList<eDVBCISlot>::iterator it(m_slots.begin()); it != m_slots.end(); ++it)
+               it->setSource(TUNER_A);
+
        if (num_ci > 1) // // FIXME .. we force DM8000 when more than one CI Slot is avail
        {
                setInputSource(0, TUNER_A);
@@ -202,21 +205,21 @@ void eDVBCIInterfaces::ciRemoved(eDVBCISlot *slot)
                {
                        if (slot->linked_next)
                                slot->linked_next->setSource(slot->current_source);
-                       else
+                       else // last CI in chain
                                setInputSource(slot->current_tuner, slot->current_source);
 
                        if (it->cislot == slot) // remove the base slot
                                it->cislot = slot->linked_next;
                        else
                        {
+                               eDVBCISlot *tmp = it->cislot;
+                               while(tmp->linked_next != slot)
+                                       tmp = tmp->linked_next;
+                               ASSERT(tmp);
                                if (slot->linked_next)
-                               {
-                                       eDVBCISlot *tmp = it->cislot;
-                                       while(tmp->linked_next != slot)
-                                               tmp = tmp->linked_next;
-                                       ASSERT(tmp);
                                        tmp->linked_next = slot->linked_next;
-                               }
+                               else
+                                       tmp->linked_next = 0;
                        }
                        slot->linked_next=0;
                }
@@ -402,7 +405,7 @@ void eDVBCIInterfaces::recheckPMTHandlers()
                                                        if (!channel->getFrontend(frontend))
                                                        {
                                                                eDVBFrontend *fe = (eDVBFrontend*) &(*frontend);
-                                                               tunernum = fe->getID();
+                                                               tunernum = fe->getSlotID();
                                                        }
                                                }
                                                ASSERT(tunernum != -1);
@@ -508,23 +511,23 @@ void eDVBCIInterfaces::removePMTHandler(eDVBServicePMTHandler *pmthandler)
                                        it->cislot = slot->linked_next;
                                else
                                {
+                                       eDVBCISlot *tmp = it->cislot;
+                                       while(tmp->linked_next != slot)
+                                               tmp = tmp->linked_next;
+                                       ASSERT(tmp);
                                        if (slot->linked_next)
-                                       {
-                                               eDVBCISlot *tmp = it->cislot;
-                                               while(tmp->linked_next != slot)
-                                                       tmp = tmp->linked_next;
-                                               ASSERT(tmp);
                                                tmp->linked_next = slot->linked_next;
-                                       }
+                                       else
+                                               tmp->linked_next = 0;
                                }
                                slot->linked_next=0;
                        }
 //                     eDebug("use_count is now %d", slot->use_count);
                        slot = next;
                }
+               // check if another service is waiting for the CI
+               recheckPMTHandlers();
        }
-       // check if another service is waiting for the CI
-       recheckPMTHandlers();
 }
 
 void eDVBCIInterfaces::gotPMT(eDVBServicePMTHandler *pmthandler)
@@ -895,13 +898,12 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
 
        if (fd >= 0)
        {
-               notifier = new eSocketNotifier(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
+               notifier = eSocketNotifier::create(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
                CONNECT(notifier->activated, eDVBCISlot::data);
        } else
        {
                perror(filename);
        }
-       setSource(TUNER_A);
 }
 
 eDVBCISlot::~eDVBCISlot()