src/driver/scanepg.cpp: add support for standby epg scan;

block scan if recording is running;
experimental, needs more testing


Origin commit data
------------------
Commit: 201fb60262
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2013-10-10 (Thu, 10 Oct 2013)
This commit is contained in:
[CST] Focus
2013-10-10 18:59:19 +04:00
parent 8e25c33526
commit f275d04349
2 changed files with 106 additions and 38 deletions

View File

@@ -36,6 +36,7 @@
#include <gui/channellist.h> #include <gui/channellist.h>
#include <driver/scanepg.h> #include <driver/scanepg.h>
#include <driver/record.h>
extern CBouquetList * bouquetList; extern CBouquetList * bouquetList;
extern CBouquetList * TVfavList; extern CBouquetList * TVfavList;
@@ -46,6 +47,7 @@ CEpgScan::CEpgScan()
next_chid = 0; next_chid = 0;
current_mode = 0; current_mode = 0;
allfav_done = false; allfav_done = false;
standby = false;
} }
CEpgScan::~CEpgScan() CEpgScan::~CEpgScan()
@@ -68,6 +70,11 @@ void CEpgScan::Clear()
allfav_done = false; allfav_done = false;
} }
bool CEpgScan::Running()
{
return (g_settings.epg_scan && !scanmap.empty());
}
void CEpgScan::AddBouquet(CChannelList * clist) void CEpgScan::AddBouquet(CChannelList * clist)
{ {
for (unsigned i = 0; i < clist->Size(); i++) { for (unsigned i = 0; i < clist->Size(); i++) {
@@ -93,13 +100,8 @@ bool CEpgScan::AddFavorites()
return (old_size != scanmap.size()); return (old_size != scanmap.size());
} }
void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) void CEpgScan::AddTransponders()
{ {
if (!g_settings.epg_scan || CFEManager::getInstance()->getEnabledCount() <= 1)
return;
CZapitChannel * newchan;
if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) {
if(bouquetList->Bouquets.empty()) if(bouquetList->Bouquets.empty())
return; return;
@@ -124,6 +126,38 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size()); INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size());
} }
} }
void CEpgScan::StartStandby()
{
if (!g_settings.epg_scan)
return;
AddTransponders();
INFO("starting standby scan, scan map size: %d", scanmap.size());
if (!scanmap.empty()) {
standby = true;
Next();
}
}
void CEpgScan::StopStandby()
{
if (!g_settings.epg_scan)
return;
INFO("stopping standby scan...");
standby = false;
}
void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
{
if (!g_settings.epg_scan || (!standby && (CFEManager::getInstance()->getEnabledCount() <= 1)))
return;
CZapitChannel * newchan;
if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) {
AddTransponders();
}
else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) { else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) {
t_channel_id chid = *(t_channel_id *)data; t_channel_id chid = *(t_channel_id *)data;
newchan = CServiceManager::getInstance()->FindChannel(chid); newchan = CServiceManager::getInstance()->FindChannel(chid);
@@ -142,8 +176,12 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
newchan = CServiceManager::getInstance()->FindChannel(next_chid); newchan = CServiceManager::getInstance()->FindChannel(next_chid);
if (newchan) { if (newchan) {
if(chid) { if(chid) {
if (!CRecordManager::getInstance()->RecordingStatus()) {
INFO("try to scan [%s]", newchan->getName().c_str()); INFO("try to scan [%s]", newchan->getName().c_str());
if (standby && !g_Sectionsd->getIsScanningActive())
g_Sectionsd->setPauseScanning(false);
g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux()); g_Sectionsd->setServiceChanged(newchan->getChannelID(), false, newchan->getRecordDemux());
}
} else { } else {
INFO("tune failed [%s]", newchan->getName().c_str()); INFO("tune failed [%s]", newchan->getName().c_str());
scanmap.erase(newchan->getTransponderId()); scanmap.erase(newchan->getTransponderId());
@@ -154,17 +192,33 @@ void CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
} }
} }
void CEpgScan::EnterStandby()
{
if (standby) {
g_Zapit->setStandby(true);
g_Sectionsd->setPauseScanning(true);
}
}
void CEpgScan::Next() void CEpgScan::Next()
{ {
bool locked = false;
next_chid = 0; next_chid = 0;
if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby) if (!g_settings.epg_scan)
return;
if (!standby && CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby)
return;
if (CRecordManager::getInstance()->RecordingStatus())
return; return;
if (g_settings.epg_scan == 2 && scanmap.empty()) if (g_settings.epg_scan == 2 && scanmap.empty())
AddFavorites(); AddFavorites();
if (scanmap.empty()) if (scanmap.empty()) {
EnterStandby();
return; return;
}
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
@@ -172,13 +226,17 @@ void CEpgScan::Next()
send zapTo_NOWAIT -> EIT_COMPLETE from sectionsd -> zap and this at the same time send zapTo_NOWAIT -> EIT_COMPLETE from sectionsd -> zap and this at the same time
*/ */
CFEManager::getInstance()->Lock(); CFEManager::getInstance()->Lock();
CFrontend *live_fe = CZapit::getInstance()->GetLiveFrontend(); CFrontend *live_fe, *pip_fe;
if (!standby) {
locked = true;
live_fe = CZapit::getInstance()->GetLiveFrontend();
CFEManager::getInstance()->lockFrontend(live_fe); CFEManager::getInstance()->lockFrontend(live_fe);
#ifdef ENABLE_PIP #ifdef ENABLE_PIP
CFrontend *pip_fe = CZapit::getInstance()->GetPipFrontend(); pip_fe = CZapit::getInstance()->GetPipFrontend();
if (pip_fe && pip_fe != live_fe) if (pip_fe && pip_fe != live_fe)
CFEManager::getInstance()->lockFrontend(pip_fe); CFEManager::getInstance()->lockFrontend(pip_fe);
#endif #endif
}
_repeat: _repeat:
for (eit_scanmap_iterator_t it = scanmap.begin(); it != scanmap.end(); /* ++it*/) { for (eit_scanmap_iterator_t it = scanmap.begin(); it != scanmap.end(); /* ++it*/) {
CZapitChannel * newchan = CServiceManager::getInstance()->FindChannel(it->second); CZapitChannel * newchan = CServiceManager::getInstance()->FindChannel(it->second);
@@ -197,12 +255,16 @@ _repeat:
if (!next_chid && AddFavorites()) if (!next_chid && AddFavorites())
goto _repeat; goto _repeat;
if (locked) {
CFEManager::getInstance()->unlockFrontend(live_fe); CFEManager::getInstance()->unlockFrontend(live_fe);
#ifdef ENABLE_PIP #ifdef ENABLE_PIP
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
}
CFEManager::getInstance()->Unlock(); CFEManager::getInstance()->Unlock();
if (next_chid) if (next_chid)
g_Zapit->zapTo_epg(next_chid); g_Zapit->zapTo_epg(next_chid, standby);
else
EnterStandby();
} }

View File

@@ -32,12 +32,14 @@ class CEpgScan
int current_bnum; int current_bnum;
int current_mode; int current_mode;
bool allfav_done; bool allfav_done;
bool standby;
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 AddBouquet(CChannelList * clist); void AddBouquet(CChannelList * clist);
bool AddFavorites(); bool AddFavorites();
void AddTransponders();
void EnterStandby();
CEpgScan(); CEpgScan();
public: public:
@@ -45,7 +47,11 @@ class CEpgScan
static CEpgScan * getInstance(); static CEpgScan * getInstance();
void handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data); void handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data);
void Next();
void Clear(); void Clear();
void StartStandby();
void StopStandby();
bool Running();
}; };
#endif #endif