neutrino: clearify mode handling in saveEpg() function

Origin commit data
------------------
Commit: d8b2be5d19
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-11-20 (Mon, 20 Nov 2017)

Origin message was:
------------------
- neutrino: clearify mode handling in saveEpg() function
This commit is contained in:
vanhofen
2017-11-20 15:19:06 +01:00
parent 8729b26638
commit 30bcdce671
3 changed files with 25 additions and 20 deletions

View File

@@ -336,7 +336,7 @@ void CEpgScan::EnterStandby()
//NI
if (g_settings.epg_save && g_settings.epg_save_standby)
CNeutrinoApp::getInstance()->saveEpg(false); //false CVFD::MODE_STANDBY
CNeutrinoApp::getInstance()->saveEpg(NeutrinoModes::mode_standby);
}
}

View File

@@ -4060,7 +4060,7 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
if(g_settings.epg_save /* && timeset && g_Sectionsd->getIsTimeSet ()*/)
{
g_Sectionsd->setPauseScanning(true);
saveEpg(true);// true CVFD::MODE_SHUTDOWN
saveEpg(NeutrinoModes::mode_off);
}
/* on shutdown force load new fst */
@@ -4259,42 +4259,47 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
#endif
}
void CNeutrinoApp::saveEpg(bool cvfd_mode)
void CNeutrinoApp::saveEpg(int _mode)
{
struct stat my_stat;
if(stat(g_settings.epg_dir.c_str(), &my_stat) == 0){
if(!cvfd_mode){//skip saveepg in standby mode, if last saveepg time < 15 Min.
if (stat(g_settings.epg_dir.c_str(), &my_stat) == 0)
{
if (_mode == NeutrinoModes::mode_standby)
{
// skip save epg in standby mode, if last saveepg time < 15 Min.
std::string index_xml = g_settings.epg_dir.c_str();
index_xml += "/index.xml";
time_t t=0;
if(stat(index_xml.c_str(), &my_stat) == 0){
if(difftime(time(&t), my_stat.st_ctime) < 900){
if (stat(index_xml.c_str(), &my_stat) == 0)
{
if (difftime(time(&t), my_stat.st_ctime) < 900)
return;
}
}
}
printf("[neutrino] Saving EPG to %s...\n", g_settings.epg_dir.c_str());
if(!cvfd_mode){
CVFD::getInstance()->Clear();
//NI CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_EPG_SAVING));
}
printf("[neutrino] Saving EPG to %s...\n", g_settings.epg_dir.c_str());
g_Sectionsd->writeSI2XML(g_settings.epg_dir.c_str());
neutrino_msg_t msg;
neutrino_msg_t msg;
neutrino_msg_data_t data;
while( true ) {
while(true)
{
g_RCInput->getMsg(&msg, &data, 1200); // 120 secs..
if (( msg == CRCInput::RC_timeout ) || (msg == NeutrinoMessages::EVT_SI_FINISHED)) {
if ((msg == CRCInput::RC_timeout) || (msg == NeutrinoMessages::EVT_SI_FINISHED))
{
//printf("Msg %x timeout %d EVT_SI_FINISHED %x\n", msg, CRCInput::RC_timeout, NeutrinoMessages::EVT_SI_FINISHED);
CVFD::getInstance()->Clear();
CVFD::getInstance()->setMode(cvfd_mode ? CVFD::MODE_SHUTDOWN : CVFD::MODE_STANDBY);// true CVFD::MODE_SHUTDOWN , false CVFD::MODE_STANDBY
// do we really have to change VFD-mode here again?
CVFD::getInstance()->setMode((_mode == NeutrinoModes::mode_standby) ? CVFD::MODE_STANDBY : CVFD::MODE_SHUTDOWN);
delete [] (unsigned char*) data;
break;
} else if (!cvfd_mode){
printf("wait for epg saving, Msg %x \n", (int) msg);
}
else if (_mode == NeutrinoModes::mode_standby)
{
printf("wait for epg saving, msg %x \n", (int) msg);
handleMsg(msg, data);
}
}
@@ -4453,7 +4458,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
if(!CRecordManager::getInstance()->RecordingStatus() ) {
//only save epg when not recording
if(g_settings.epg_save && !fromDeepStandby && g_settings.epg_save_standby) {
saveEpg(false);//false CVFD::MODE_STANDBY
saveEpg(NeutrinoModes::mode_standby);
}
}

View File

@@ -213,7 +213,7 @@ public:
CConfigFile* getConfigFile() {return &configfile;};
bool SDTreloadChannels;
void saveEpg(bool cvfd_mode);
void saveEpg(int _mode);
void stopDaemonsForFlash();
int showChannelList(const neutrino_msg_t msg, bool from_menu = false);
void allowChannelList(bool allow){channelList_allowed = allow;}