driver/scanepg.cpp: try to make zap for epg scan non-blocking

This commit is contained in:
[CST] Focus
2013-08-12 13:35:32 +04:00
parent 640056c938
commit 46980f524d
2 changed files with 59 additions and 30 deletions

View File

@@ -42,6 +42,7 @@ extern CBouquetList * bouquetList;
CEpgScan::CEpgScan() CEpgScan::CEpgScan()
{ {
current_bnum = -1; current_bnum = -1;
next_chid = 0;
} }
CEpgScan::~CEpgScan() CEpgScan::~CEpgScan()
@@ -60,6 +61,7 @@ void CEpgScan::Clear()
{ {
scanmap.clear(); scanmap.clear();
current_bnum = -1; current_bnum = -1;
next_chid = 0;
} }
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)
@@ -98,9 +100,39 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
if (scanmap.empty()) if (scanmap.empty())
return; return;
Next();
}
else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) {
t_channel_id chid = *(t_channel_id *)data;
INFO("EVT_BACK_ZAP_COMPLETE [" PRINTF_CHANNEL_ID_TYPE "]", chid);
if (next_chid) {
newchan = CServiceManager::getInstance()->FindChannel(next_chid);
if (newchan) {
if(chid) {
INFO("try to scan [%s]", newchan->getName().c_str());
g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux());
} else {
INFO("tune failed [%s]", newchan->getName().c_str());
scanmap.erase(newchan->getTransponderId());
Next();
}
}
}
}
}
void CEpgScan::Next()
{
next_chid = 0;
if (CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_standby)
return;
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
CFrontend *live_fe = CZapit::getInstance()->GetLiveFrontend(); CFrontend *live_fe = CZapit::getInstance()->GetLiveFrontend();
/* executed in neutrino thread - possible race with locks in zapit zap NOWAIT :
send zaTo_NOWAIT -> EIT_COMPLETE from sectionsd -> zap and this at the same time
*/
CFEManager::getInstance()->lockFrontend(live_fe); CFEManager::getInstance()->lockFrontend(live_fe);
#ifdef ENABLE_PIP #ifdef ENABLE_PIP
CFrontend *pip_fe = CZapit::getInstance()->GetPipFrontend(); CFrontend *pip_fe = CZapit::getInstance()->GetPipFrontend();
@@ -108,21 +140,15 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
CFEManager::getInstance()->lockFrontend(pip_fe); CFEManager::getInstance()->lockFrontend(pip_fe);
#endif #endif
for (eit_scanmap_iterator_t it = scanmap.begin(); it != scanmap.end(); /* ++it*/) { for (eit_scanmap_iterator_t it = scanmap.begin(); it != scanmap.end(); /* ++it*/) {
newchan = CServiceManager::getInstance()->FindChannel(it->second); CZapitChannel * newchan = CServiceManager::getInstance()->FindChannel(it->second);
if ((newchan == NULL) || SAME_TRANSPONDER(live_channel_id, newchan->getChannelID())) { if ((newchan == NULL) || SAME_TRANSPONDER(live_channel_id, newchan->getChannelID())) {
scanmap.erase(it++); scanmap.erase(it++);
continue; continue;
} }
if (CFEManager::getInstance()->canTune(newchan)) { if (CFEManager::getInstance()->canTune(newchan)) {
INFO("try to scan [%s]", newchan->getName().c_str()); INFO("try to tune [%s]", newchan->getName().c_str());
bool ret = g_Zapit->zapTo_record(newchan->getChannelID()) > 0; next_chid = newchan->getChannelID();
if (ret) {
g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux());
break; break;
} else {
scanmap.erase(it++);
continue;
}
} else } else
INFO("skip [%s], cannot tune", newchan->getName().c_str()); INFO("skip [%s], cannot tune", newchan->getName().c_str());
++it; ++it;
@@ -132,5 +158,6 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
if (pip_fe && pip_fe != live_fe) if (pip_fe && pip_fe != live_fe)
CFEManager::getInstance()->unlockFrontend(pip_fe); CFEManager::getInstance()->unlockFrontend(pip_fe);
#endif #endif
} if (next_chid)
g_Zapit->zapTo_epg(next_chid);
} }

View File

@@ -31,7 +31,9 @@ class CEpgScan
private: private:
int current_bnum; int current_bnum;
eit_scanmap_t scanmap; eit_scanmap_t scanmap;
t_channel_id next_chid;
std::set<transponder_id_t> scanned; std::set<transponder_id_t> scanned;
void Next();
CEpgScan(); CEpgScan();
public: public: