driver/scanepg.cpp: reuse code, do not try to add favorites again if scan complete

This commit is contained in:
[CST] Focus
2013-10-07 14:53:06 +04:00
parent 839547acb9
commit f2f3737c10
2 changed files with 20 additions and 15 deletions

View File

@@ -45,6 +45,7 @@ CEpgScan::CEpgScan()
current_bnum = -1; current_bnum = -1;
next_chid = 0; next_chid = 0;
current_mode = 0; current_mode = 0;
allfav_done = false;
} }
CEpgScan::~CEpgScan() CEpgScan::~CEpgScan()
@@ -64,6 +65,16 @@ void CEpgScan::Clear()
scanmap.clear(); scanmap.clear();
current_bnum = -1; current_bnum = -1;
next_chid = 0; next_chid = 0;
allfav_done = false;
}
void CEpgScan::AddBouquet(CChannelList * clist)
{
for (unsigned i = 0; i < clist->Size(); i++) {
CZapitChannel * chan = clist->getChannelFromIndex(i);
if (scanned.find(chan->getTransponderId()) == scanned.end())
scanmap.insert(eit_scanmap_pair_t(chan->getTransponderId(), chan->getChannelID()));
}
} }
void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
@@ -80,30 +91,23 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
current_mode = g_settings.epg_scan; current_mode = g_settings.epg_scan;
Clear(); Clear();
} }
/* TODO: add interval check to clear scanned ? */
if (g_settings.epg_scan == 1) { if (g_settings.epg_scan == 1) {
/* current bouquet mode */ /* current bouquet mode */
if (current_bnum != bouquetList->getActiveBouquetNumber()) { if (current_bnum != bouquetList->getActiveBouquetNumber()) {
scanmap.clear(); scanmap.clear();
current_bnum = bouquetList->getActiveBouquetNumber(); current_bnum = bouquetList->getActiveBouquetNumber();
CChannelList * clist = bouquetList->Bouquets[current_bnum]->channelList; CChannelList * clist = bouquetList->Bouquets[current_bnum]->channelList;
for (unsigned i = 0; i < clist->Size(); i++) { AddBouquet(clist);
CZapitChannel * chan = clist->getChannelFromIndex(i);
/* TODO: add interval check to clear scanned ? */
if (scanned.find(chan->getTransponderId()) == scanned.end())
scanmap.insert(eit_scanmap_pair_t(chan->getTransponderId(), chan->getChannelID()));
}
INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size()); INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size());
} }
} else { } else {
/* all favorites mode */ /* all favorites mode */
if (scanmap.empty()) { if (!allfav_done) {
allfav_done = true;
for (unsigned j = 0; j < TVfavList->Bouquets.size(); ++j) { for (unsigned j = 0; j < TVfavList->Bouquets.size(); ++j) {
CChannelList * clist = TVfavList->Bouquets[j]->channelList; CChannelList * clist = TVfavList->Bouquets[j]->channelList;
for (unsigned i = 0; i < clist->Size(); i++) { AddBouquet(clist);
CZapitChannel * chan = clist->getChannelFromIndex(i);
if (scanned.find(chan->getTransponderId()) == scanned.end())
scanmap.insert(eit_scanmap_pair_t(chan->getTransponderId(), chan->getChannelID()));
}
} }
INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size()); INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size());
} }
@@ -118,9 +122,6 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
} }
INFO("EIT read complete [" PRINTF_CHANNEL_ID_TYPE "], scan map size: %d", chid, scanmap.size()); INFO("EIT read complete [" PRINTF_CHANNEL_ID_TYPE "], scan map size: %d", chid, scanmap.size());
if (scanmap.empty())
return;
Next(); Next();
} }
else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) { else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) {
@@ -147,6 +148,8 @@ void CEpgScan::Next()
next_chid = 0; next_chid = 0;
if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby) if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby)
return; return;
if (scanmap.empty())
return;
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();

View File

@@ -31,10 +31,12 @@ class CEpgScan
private: private:
int current_bnum; int current_bnum;
int current_mode; int current_mode;
bool allfav_done;
eit_scanmap_t scanmap; eit_scanmap_t scanmap;
t_channel_id next_chid; t_channel_id next_chid;
std::set<transponder_id_t> scanned; std::set<transponder_id_t> scanned;
void Next(); void Next();
void AddBouquet(CChannelList * clist);
CEpgScan(); CEpgScan();
public: public: