driver/scanepg.cpp: add timer to rescan epg every 24 hours

This commit is contained in:
[CST] Focus
2013-12-19 19:44:17 +04:00
parent 5acfcb9dee
commit bf520e26fc
2 changed files with 50 additions and 17 deletions

View File

@@ -38,6 +38,8 @@
#include <driver/scanepg.h> #include <driver/scanepg.h>
#include <driver/record.h> #include <driver/record.h>
#define EPG_RESCAN_TIME (24*60*60)
extern CBouquetList * bouquetList; extern CBouquetList * bouquetList;
extern CBouquetList * TVfavList; extern CBouquetList * TVfavList;
@@ -45,6 +47,8 @@ CEpgScan::CEpgScan()
{ {
current_mode = 0; current_mode = 0;
standby = false; standby = false;
rescan_timer = 0;
scan_in_progress = false;
Clear(); Clear();
} }
@@ -108,7 +112,6 @@ void CEpgScan::AddTransponders()
current_mode = g_settings.epg_scan; current_mode = g_settings.epg_scan;
Clear(); Clear();
} }
/* TODO: add interval check to clear scanned ? */
int mode = CNeutrinoApp::getInstance()->GetChannelMode(); int mode = CNeutrinoApp::getInstance()->GetChannelMode();
if ((g_settings.epg_scan == 1) || (mode == LIST_MODE_FAV)) { if ((g_settings.epg_scan == 1) || (mode == LIST_MODE_FAV)) {
@@ -129,45 +132,68 @@ void CEpgScan::AddTransponders()
} }
} }
void CEpgScan::StartStandby() void CEpgScan::Start(bool instandby)
{ {
if (!g_settings.epg_scan) if (!g_settings.epg_scan)
return; return;
if (!standby && (CFEManager::getInstance()->getEnabledCount() <= 1))
return;
live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
AddTransponders(); AddTransponders();
INFO("starting standby scan, scan map size: %d", scanmap.size()); standby = instandby;
if (!scanmap.empty()) { g_RCInput->killTimer(rescan_timer);
standby = true; INFO("starting %s scan, scanning %d, scan map size: %d", standby ? "standby" : "live", scan_in_progress, scanmap.size());
if (standby || !scan_in_progress)
Next(); Next();
}
} }
void CEpgScan::StopStandby() void CEpgScan::Stop()
{ {
if (!g_settings.epg_scan) if (!g_settings.epg_scan)
return; return;
INFO("stopping standby scan..."); INFO("stopping %s scan...", standby ? "standby" : "live");
standby = false; if (standby) {
CZapit::getInstance()->SetCurrentChannelID(live_channel_id); standby = false;
CZapit::getInstance()->SetCurrentChannelID(live_channel_id);
}
} }
int CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) int CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
{ {
if ((msg == NeutrinoMessages::EVT_TIMER) && (data == rescan_timer)) {
INFO("rescan timer in %s mode, scanning %d", standby ? "standby" : "live", scan_in_progress);
scanned.clear();
Clear();
if (standby || (CFEManager::getInstance()->getEnabledCount() > 1)) {
if (standby)
g_Zapit->setStandby(false);
Start(standby);
}
return messages_return::handled;
}
if (!g_settings.epg_scan || (!standby && (CFEManager::getInstance()->getEnabledCount() <= 1))) { if (!g_settings.epg_scan || (!standby && (CFEManager::getInstance()->getEnabledCount() <= 1))) {
if ((msg == NeutrinoMessages::EVT_EIT_COMPLETE) || (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE)) int ret = messages_return::handled;
return messages_return::handled; if (msg == NeutrinoMessages::EVT_EIT_COMPLETE)
return messages_return::unhandled; scan_in_progress = false;
else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE)
scan_in_progress = true;
else
ret = messages_return::unhandled;
return ret;
} }
CZapitChannel * newchan; CZapitChannel * newchan;
if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) { if (msg == NeutrinoMessages::EVT_ZAP_COMPLETE) {
/* live channel changed, block scan channel change by timer */
scan_in_progress = true;
AddTransponders(); AddTransponders();
INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size()); INFO("EVT_ZAP_COMPLETE, scan map size: %d\n", scanmap.size());
return messages_return::handled; return messages_return::handled;
} }
else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) { else if (msg == NeutrinoMessages::EVT_EIT_COMPLETE) {
scan_in_progress = false;
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);
if (newchan) { if (newchan) {
@@ -180,6 +206,7 @@ int CEpgScan::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data)
return messages_return::handled; return messages_return::handled;
} }
else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) { else if (msg == NeutrinoMessages::EVT_BACK_ZAP_COMPLETE) {
scan_in_progress = true;
t_channel_id chid = *(t_channel_id *)data; t_channel_id chid = *(t_channel_id *)data;
INFO("EVT_BACK_ZAP_COMPLETE [" PRINTF_CHANNEL_ID_TYPE "]", chid); INFO("EVT_BACK_ZAP_COMPLETE [" PRINTF_CHANNEL_ID_TYPE "]", chid);
if (next_chid) { if (next_chid) {
@@ -208,10 +235,13 @@ void CEpgScan::EnterStandby()
{ {
if (standby) { if (standby) {
CZapit::getInstance()->SetCurrentChannelID(live_channel_id); CZapit::getInstance()->SetCurrentChannelID(live_channel_id);
CZapit::getInstance()->EnablePlayback(true); //CZapit::getInstance()->EnablePlayback(true);
g_Zapit->setStandby(true); g_Zapit->setStandby(true);
g_Sectionsd->setPauseScanning(true); g_Sectionsd->setPauseScanning(true);
} }
g_RCInput->killTimer(rescan_timer);
rescan_timer = g_RCInput->addTimer(EPG_RESCAN_TIME*1000ULL*1000ULL, true);
INFO("rescan timer id %d", rescan_timer);
} }
void CEpgScan::Next() void CEpgScan::Next()

View File

@@ -38,6 +38,9 @@ class CEpgScan
t_channel_id next_chid; t_channel_id next_chid;
t_channel_id live_channel_id; t_channel_id live_channel_id;
std::set<transponder_id_t> scanned; std::set<transponder_id_t> scanned;
uint32_t rescan_timer;
bool scan_in_progress;
void AddBouquet(CChannelList * clist); void AddBouquet(CChannelList * clist);
bool AddFavorites(); bool AddFavorites();
void AddTransponders(); void AddTransponders();
@@ -51,8 +54,8 @@ class CEpgScan
int handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data); int handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data);
void Next(); void Next();
void Clear(); void Clear();
void StartStandby(); void Start(bool instandby = false);
void StopStandby(); void Stop();
bool Running(); bool Running();
}; };