- add epg_save_frequently feature ...

... to provide the EPG data in frequently intervals on an external device
This commit is contained in:
svenhoefer
2014-12-04 16:48:50 +01:00
parent 4c621f1dec
commit e21a79195e
12 changed files with 50 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ static bool notify_complete = false;
/* period to clean cached sections and force restart sections read */
#define META_HOUSEKEEPING_COUNT (24 * 60 * 60) / HOUSEKEEPING_SLEEP // meta housekeeping after XX housekeepings - every 24h -
#define STANDBY_HOUSEKEEPING_COUNT (60 * 60) / HOUSEKEEPING_SLEEP
#define EPG_SAVE_FREQUENTLY_COUNT (60 * 60) / HOUSEKEEPING_SLEEP
// Timeout bei tcp/ip connections in ms
#define READ_TIMEOUT_IN_SECONDS 2
@@ -82,6 +83,7 @@ static bool notify_complete = false;
// number of timeouts after which we stop waiting for an EIT version number
#define TIMEOUTS_EIT_VERSION_WAIT (2 * CHECK_RESTART_DMX_AFTER_TIMEOUTS)
static unsigned int epg_save_frequently;
static long secondsToCache;
static long secondsExtendedTextCache;
static long oldEventsAre;
@@ -1108,6 +1110,7 @@ static void commandSetConfig(int connfd, char *data, const unsigned /*dataLength
oldEventsAre = (long)(pmsg->epg_old_events)*60L*60L;
secondsExtendedTextCache = (long)(pmsg->epg_extendedcache)*60L*60L;
max_events = pmsg->epg_max_events;
epg_save_frequently = pmsg->epg_save_frequently;
unlockEvents();
bool time_wakeup = false;
@@ -2036,7 +2039,7 @@ static void print_meminfo(void)
//---------------------------------------------------------------------
static void *houseKeepingThread(void *)
{
int count = 0, scount = 0;
int count = 0, scount = 0, ecount = 0;
dprintf("housekeeping-thread started.\n");
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
@@ -2065,6 +2068,23 @@ static void *houseKeepingThread(void *)
removeOldEvents(oldEventsAre); // alte Events
ecount++;
if (ecount == EPG_SAVE_FREQUENTLY_COUNT)
{
if (epg_save_frequently > 0)
{
std::string d = epg_dir;
if (d.length() > 1)
{
std::string::iterator it = d.end() - 1;
if (*it == '/')
d.erase(it);
}
writeEventsToFile((char *)d.c_str());
}
ecount = 0;
}
readLockEvents();
dprintf("Number of sptr events (event-ID): %u\n", (unsigned)mySIeventsOrderUniqueKey.size());
dprintf("Number of sptr events (service-id, start time, event-id): %u\n", (unsigned)mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.size());
@@ -2118,6 +2138,7 @@ bool CEitManager::Start()
secondsExtendedTextCache = config.epg_extendedcache*60L*60L; //hours
oldEventsAre = config.epg_old_events*60L*60L; //hours
max_events = config.epg_max_events;
epg_save_frequently = config.epg_save_frequently;
if (find_executable("ntpdate").empty())
ntp_system_cmd_prefix = "ntpd -n -q -p ";