- improved scan error handling
[enigma2.git] / lib / components / scan.cpp
index 4d8d8b7..ad2e4d1 100644 (file)
@@ -20,23 +20,29 @@ void eComponentScan::scanEvent(int evt)
                if ((err = eDVBResourceManager::getInstance(res)) != 0)
                {
                        eDebug("no resource manager");
-                       return;
-               }
-               if ((err = res->getChannelList(db)) != 0)
+                       m_failed = 2;
+               } else if ((err = res->getChannelList(db)) != 0)
                {
+                       m_failed = 3;
                        eDebug("no channel list");
-                       return;
+               } else
+               {
+                       m_scan->insertInto(db);
+                       eDebug("scan done!");
                }
-               
-               m_scan->insertInto(db);
-               
-               eDebug("scan done!");
+       }
+       
+       if (evt == eDVBScan::evtFail)
+       {
+               eDebug("scan failed.");
+               m_failed = 1;
+               m_done = 1;
        }
        
        statusChanged();
 }
 
-eComponentScan::eComponentScan(): m_done(-1)
+eComponentScan::eComponentScan(): m_done(-1), m_failed(0)
 {
 }
 
@@ -53,7 +59,9 @@ int eComponentScan::start()
        ePtr<eDVBResourceManager> mgr;
        
        eDVBResourceManager::getInstance(mgr);
-       
+
+       eDVBFrontendParameters *fe = new eDVBFrontendParameters();
+#if 0  
        eDVBFrontendParametersSatellite fesat;
                
        fesat.frequency = 11817000; // 12070000;
@@ -63,23 +71,37 @@ int eComponentScan::start()
        fesat.inversion = eDVBFrontendParametersSatellite::Inversion::Off;
        fesat.orbital_position = 192;
 
-       eDVBFrontendParameters *fe = new eDVBFrontendParameters();
        
        fe->setDVBS(fesat);
+#endif
+
+       eDVBFrontendParametersTerrestrial fet;
+       fet.frequency = 626000000;
+       fet.inversion = eDVBFrontendParametersTerrestrial::Inversion::Unknown;
+       fet.bandwidth = eDVBFrontendParametersTerrestrial::Bandwidth::Bw8MHz;
+       fet.code_rate_HP = fet.code_rate_LP = eDVBFrontendParametersTerrestrial::FEC::fAuto;
+       fet.modulation = eDVBFrontendParametersTerrestrial::Modulation::QAM16;
+       fet.transmission_mode = eDVBFrontendParametersTerrestrial::TransmissionMode::TM8k;
+       fet.guard_interval = eDVBFrontendParametersTerrestrial::GuardInterval::GI_1_32;
+       fet.hierarchy = eDVBFrontendParametersTerrestrial::Hierarchy::HNone;
+       fe->setDVBT(fet);
        
        ePtr<iDVBChannel> channel;
 
        if (mgr->allocateRawChannel(channel))
+       {
                eDebug("scan: allocating raw channel failed!");
+               return -1;
+       }
 
        std::list<ePtr<iDVBFrontendParameters> > list;
                
        list.push_back(fe);
        
        m_scan = new eDVBScan(channel);
-       m_scan->start(list);
        m_scan->connectEvent(slot(*this, &eComponentScan::scanEvent), m_scan_event_connection);
-
+       m_scan->start(list);
+       
        return 0;
 }
 
@@ -107,3 +129,8 @@ int eComponentScan::isDone()
 {
        return m_done;
 }
+
+int eComponentScan::getError()
+{
+       return m_failed;
+}