mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
Merge branch 'dvbsi++' into next
Conflicts: src/neutrino.cpp src/zapit/src/femanager.cpp src/zapit/src/getservices.cpp src/zapit/src/transponder.cpp
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2001 by fnbrd (fnbrd@gmx.de)
|
||||
* Homepage: http://dbox2.elxsi.de
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Stefan Seyfried
|
||||
* Copyright (C) 2008-2013 Stefan Seyfried
|
||||
*
|
||||
* Copyright (C) 2011-2012 CoolStream International Ltd
|
||||
*
|
||||
@@ -55,7 +55,7 @@
|
||||
//#define ENABLE_SDT //FIXME
|
||||
|
||||
//#define DEBUG_SDT_THREAD
|
||||
#define DEBUG_TIME_THREAD
|
||||
//#define DEBUG_TIME_THREAD
|
||||
|
||||
#define DEBUG_SECTION_THREADS
|
||||
#define DEBUG_CN_THREAD
|
||||
@@ -255,12 +255,12 @@ static bool deleteEvent(const event_id_t uniqueKey)
|
||||
}
|
||||
|
||||
if (cn) { // current-next => fill current or next event...
|
||||
//xprintf("addEvent: current %016llx event %016llx messaging_got_CN %d\n", messaging_current_servicekey, evt.get_channel_id(), messaging_got_CN);
|
||||
//xprintf("addEvent: current %016" PRIx64 " event %016" PRIx64 " messaging_got_CN %d\n", messaging_current_servicekey, evt.get_channel_id(), messaging_got_CN);
|
||||
readLockMessaging();
|
||||
// only if it is the current channel... and if we don't have them already.
|
||||
if (evt.get_channel_id() == messaging_current_servicekey &&
|
||||
(messaging_got_CN != 0x03)) {
|
||||
xprintf("addEvent: current %016llx event %016llx running %d messaging_got_CN %d\n", messaging_current_servicekey, evt.get_channel_id(), evt.runningStatus(), messaging_got_CN);
|
||||
xprintf("addEvent: current %016" PRIx64 " event %016" PRIx64 " running %d messaging_got_CN %d\n", messaging_current_servicekey, evt.get_channel_id(), evt.runningStatus(), messaging_got_CN);
|
||||
|
||||
unlockMessaging();
|
||||
writeLockEvents();
|
||||
@@ -318,7 +318,7 @@ xprintf("addEvent: current %016llx event %016llx running %d messaging_got_CN %d\
|
||||
{
|
||||
/* if the new event has a lower (== more recent) table ID, replace the old one */
|
||||
already_exists = false;
|
||||
dprintf("replacing event %016llx:%02x with %04x:%02x '%.40s'\n", si->second->uniqueKey(),
|
||||
dprintf("replacing event %016" PRIx64 ":%02x with %04x:%02x '%.40s'\n", si->second->uniqueKey(),
|
||||
si->second->table_id, evt.eventID, evt.table_id, evt.getName().c_str());
|
||||
}
|
||||
else if (already_exists && ( (evt.table_id == 0x51 || evt.table_id == 0x50 || evt.table_id == 0x4e) && evt.table_id == si->second->table_id && evt.version != si->second->version ))
|
||||
@@ -408,9 +408,16 @@ xprintf("addEvent: current %016llx event %016llx running %d messaging_got_CN %d\
|
||||
else
|
||||
{
|
||||
event_id_t x_key = (*x)->uniqueKey();
|
||||
/* do we need this check? */
|
||||
if (x_key == e_key)
|
||||
continue;
|
||||
{
|
||||
/* the present event has a higher table_id than the new one
|
||||
* => delete and insert the new one */
|
||||
if ((*x)->table_id >= e->table_id)
|
||||
continue;
|
||||
/* else: keep the old event with the lower table_id */
|
||||
unlockEvents();
|
||||
return;
|
||||
}
|
||||
if ((*x)->times.begin()->startzeit >= end_time)
|
||||
continue;
|
||||
/* iterating backwards: if the endtime of the stored events
|
||||
@@ -418,8 +425,16 @@ xprintf("addEvent: current %016llx event %016llx running %d messaging_got_CN %d\
|
||||
* find an identical one => bail out */
|
||||
if ((*x)->times.begin()->startzeit + (long)(*x)->times.begin()->dauer <= start_time)
|
||||
break;
|
||||
if ((*x)->table_id < e->table_id)
|
||||
{
|
||||
/* don't add the higher table_id */
|
||||
dprintf("%s: don't replace 0x%016" PRIx64 ".%02x with 0x%016" PRIx64 ".%02x\n",
|
||||
__func__, x_key, (*x)->table_id, e_key, e->table_id);
|
||||
unlockEvents();
|
||||
return;
|
||||
}
|
||||
/* here we have an overlapping event */
|
||||
dprintf("%s: delete 0x%016llx.%02x time = 0x%016llx.%02x\n", __func__,
|
||||
dprintf("%s: delete 0x%016" PRIx64 ".%02x time = 0x%016" PRIx64 ".%02x\n", __func__,
|
||||
x_key, (*x)->table_id, e_key, e->table_id);
|
||||
to_delete.push_back(x_key);
|
||||
}
|
||||
@@ -884,7 +899,7 @@ static void commandserviceChanged(int connfd, char *data, const unsigned dataLen
|
||||
|
||||
t_channel_id uniqueServiceKey = (((sectionsd::commandSetServiceChanged *)data)->channel_id);
|
||||
|
||||
xprintf("[sectionsd] commandserviceChanged: Service change to " PRINTF_CHANNEL_ID_TYPE "\n\n", uniqueServiceKey);
|
||||
xprintf("[sectionsd] commandserviceChanged: Service change to " PRINTF_CHANNEL_ID_TYPE "\n", uniqueServiceKey);
|
||||
|
||||
static t_channel_id time_trigger_last = 0;
|
||||
|
||||
@@ -927,7 +942,7 @@ static void commandserviceChanged(int connfd, char *data, const unsigned dataLen
|
||||
else
|
||||
dprintf("[sectionsd] commandserviceChanged: no change...\n");
|
||||
|
||||
xprintf("[sectionsd] commandserviceChanged: Service changed to " PRINTF_CHANNEL_ID_TYPE "\n\n", uniqueServiceKey);
|
||||
dprintf("[sectionsd] commandserviceChanged: Service changed to " PRINTF_CHANNEL_ID_TYPE "\n", uniqueServiceKey);
|
||||
}
|
||||
|
||||
static void commandGetIsScanningActive(int connfd, char* /*data*/, const unsigned /*dataLength*/)
|
||||
@@ -1287,7 +1302,8 @@ void CTimeThread::sendTimeEvent(bool ntp, time_t tim)
|
||||
eventServer->sendEvent(CSectionsdClient::EVT_TIMESET, CEventServer::INITID_SECTIONSD, &actTime, sizeof(actTime) );
|
||||
#endif
|
||||
if(ntp || tim) {}
|
||||
eventServer->sendEvent(CSectionsdClient::EVT_TIMESET, CEventServer::INITID_SECTIONSD, &timediff, sizeof(timediff));
|
||||
if (timediff)
|
||||
eventServer->sendEvent(CSectionsdClient::EVT_TIMESET, CEventServer::INITID_SECTIONSD, &timediff, sizeof(timediff));
|
||||
setTimeSet();
|
||||
}
|
||||
|
||||
@@ -1317,15 +1333,30 @@ void CTimeThread::setSystemTime(time_t tim)
|
||||
gettimeofday(&tv, NULL);
|
||||
timediff = (int64_t)tim * (int64_t)1000000 - (tv.tv_usec + tv.tv_sec * (int64_t)1000000);
|
||||
|
||||
xprintf("%s: timediff %lld, current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", name.c_str(), timediff,
|
||||
xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", name.c_str(), timediff,
|
||||
tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900,
|
||||
tmTime->tm_hour, tmTime->tm_min, tmTime->tm_sec, ctime(&tim));
|
||||
|
||||
#if 0
|
||||
/* if new time less than current for less than 1 second, ignore */
|
||||
if(timediff < 0 && timediff > (int64_t) -1000000) {
|
||||
timediff = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (timediff == 0) /* very unlikely... :-) */
|
||||
return;
|
||||
if (abs(timediff) < 120000000LL) {
|
||||
struct timeval oldd;
|
||||
tv.tv_sec = timediff / 1000000LL;
|
||||
tv.tv_usec = timediff % 1000000LL;
|
||||
if (adjtime(&tv, &oldd))
|
||||
perror("adjtime");
|
||||
xprintf("difference is < 120s, using adjtime(%d, %d). oldd(%d, %d)\n",
|
||||
(int)tv.tv_sec, (int)tv.tv_usec, (int)oldd.tv_sec, (int)oldd.tv_usec);
|
||||
timediff = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
tv.tv_sec = tim;
|
||||
tv.tv_usec = 0;
|
||||
@@ -1357,9 +1388,11 @@ void CTimeThread::run()
|
||||
if(!scanning)
|
||||
sleep_time = 0;
|
||||
real_pause();
|
||||
#ifndef DEBUG_TIME_THREAD
|
||||
Sleep();
|
||||
#else
|
||||
int rs = Sleep();
|
||||
#ifdef DEBUG_TIME_THREAD
|
||||
xprintf("%s: wakeup, running %d scanning %d channel %llx reason %d\n",
|
||||
xprintf("%s: wakeup, running %d scanning %d channel %" PRIx64 " reason %d\n",
|
||||
name.c_str(), running, scanning, current_service, rs);
|
||||
#endif
|
||||
} while (running && !scanning);
|
||||
@@ -1434,7 +1467,7 @@ int CSectionThread::Sleep()
|
||||
TIMEVAL_TO_TIMESPEC(&now, &abs_wait);
|
||||
abs_wait.tv_sec += sleep_time;
|
||||
}
|
||||
xprintf("%s: going to sleep for %d seconds...\n", name.c_str(), sleep_time);
|
||||
dprintf("%s: going to sleep for %d seconds...\n", name.c_str(), sleep_time);
|
||||
pthread_mutex_lock(&start_stop_mutex);
|
||||
|
||||
beforeWait();
|
||||
@@ -1482,7 +1515,7 @@ void CSectionThread::run()
|
||||
real_pause();
|
||||
rs = Sleep();
|
||||
#ifdef DEBUG_SECTION_THREADS
|
||||
xprintf("%s: wakeup, running %d scanning %d blacklisted %d reason %d\n\n",
|
||||
xprintf("%s: wakeup, running %d scanning %d blacklisted %d reason %d\n",
|
||||
name.c_str(), running, scanning, channel_is_blacklisted, rs);
|
||||
#endif
|
||||
} while (checkSleep());
|
||||
@@ -1506,7 +1539,7 @@ void CSectionThread::run()
|
||||
if (timeoutsDMX < 0 || timeoutsDMX >= skipTimeouts) {
|
||||
#ifdef DEBUG_SECTION_THREADS
|
||||
xprintf("%s: skipping to next filter %d from %d (timeouts %d)\n",
|
||||
name.c_str(), filter_index+1, filters.size(), timeoutsDMX);
|
||||
name.c_str(), filter_index+1, (int)filters.size(), timeoutsDMX);
|
||||
#endif
|
||||
timeoutsDMX = 0;
|
||||
need_change = true;
|
||||
@@ -1514,7 +1547,7 @@ void CSectionThread::run()
|
||||
if (zeit > lastChanged + skipTime) {
|
||||
#ifdef DEBUG_SECTION_THREADS
|
||||
xprintf("%s: skipping to next filter %d from %d (seconds %d)\n",
|
||||
name.c_str(), filter_index+1, filters.size(), (int) (zeit - lastChanged));
|
||||
name.c_str(), filter_index+1, (int)filters.size(), (int)(zeit - lastChanged));
|
||||
#endif
|
||||
need_change = true;
|
||||
}
|
||||
@@ -1540,7 +1573,7 @@ bool CEventsThread::addEvents()
|
||||
if (!eit.is_parsed())
|
||||
return false;
|
||||
|
||||
dprintf("[%s] adding %d events (begin)\n", name.c_str(), eit.events().size());
|
||||
dprintf("[%s] adding %d events (begin)\n", name.c_str(), (int)eit.events().size());
|
||||
time_t zeit = time(NULL);
|
||||
|
||||
for (SIevents::const_iterator e = eit.events().begin(); e != eit.events().end(); ++e) {
|
||||
@@ -1583,6 +1616,23 @@ bool CEventsThread::addEvents()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCNThread::shouldSleep()
|
||||
{
|
||||
if (!scanning || channel_is_blacklisted)
|
||||
return true;
|
||||
if (!sendToSleepNow)
|
||||
return false;
|
||||
if (eit_version != 0xff)
|
||||
return true;
|
||||
|
||||
if (++eit_retry > 1) {
|
||||
xprintf("%s::%s eit_retry > 1 (%d) -> going to sleep\n", name.c_str(), __func__, eit_retry);
|
||||
return true;
|
||||
}
|
||||
sendToSleepNow = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* default check if thread should go to sleep */
|
||||
bool CEventsThread::shouldSleep()
|
||||
{
|
||||
@@ -1656,6 +1706,7 @@ CCNThread::CCNThread()
|
||||
|
||||
updating = false;
|
||||
eitDmx = new cDemux(0);
|
||||
eit_retry = 0;
|
||||
}
|
||||
|
||||
/* CN thread hooks */
|
||||
@@ -1671,7 +1722,7 @@ void CCNThread::addFilters()
|
||||
|
||||
void CCNThread::beforeWait()
|
||||
{
|
||||
xprintf("%s: set eit update filter, service = 0x%016llx, current version 0x%x got events %d (%s)\n",
|
||||
xprintf("%s: set eit update filter, service = 0x%016" PRIx64 ", current version 0x%x got events %d (%s)\n",
|
||||
name.c_str(), messaging_current_servicekey, eit_version, messaging_have_CN,
|
||||
updating ? "active" : "not active");
|
||||
|
||||
@@ -1721,6 +1772,7 @@ void CCNThread::beforeSleep()
|
||||
/* send a "no epg" event anyway before going to sleep */
|
||||
sendCNEvent();
|
||||
}
|
||||
eit_retry = 0;
|
||||
}
|
||||
|
||||
void CCNThread::processSection()
|
||||
@@ -1738,7 +1790,7 @@ void CCNThread::processSection()
|
||||
unlockMessaging();
|
||||
|
||||
#ifdef DEBUG_CN_THREAD
|
||||
xprintf("%s: have CN: timeoutsDMX %d messaging_have_CN %x messaging_got_CN %x\n\n",
|
||||
xprintf("%s: have CN: timeoutsDMX %d messaging_have_CN %x messaging_got_CN %x\n",
|
||||
name.c_str(), timeoutsDMX, messaging_have_CN, messaging_got_CN);
|
||||
#endif
|
||||
dprintf("[cnThread] got current_next (0x%x) - sending event!\n", messaging_have_CN);
|
||||
@@ -1971,11 +2023,11 @@ static void *houseKeepingThread(void *)
|
||||
removeOldEvents(oldEventsAre); // alte Events
|
||||
dprintf("after removeoldevents\n");
|
||||
readLockEvents();
|
||||
printf("[sectionsd] Removed %d old events (%d left).\n", anzEventsAlt - mySIeventsOrderUniqueKey.size(), mySIeventsOrderUniqueKey.size());
|
||||
printf("[sectionsd] Removed %d old events (%d left).\n", (int)(anzEventsAlt - mySIeventsOrderUniqueKey.size()), (int)mySIeventsOrderUniqueKey.size());
|
||||
if (mySIeventsOrderUniqueKey.size() != anzEventsAlt)
|
||||
{
|
||||
print_meminfo();
|
||||
dprintf("Removed %d old events.\n", anzEventsAlt - mySIeventsOrderUniqueKey.size());
|
||||
dprintf("Removed %d old events.\n", (int)(anzEventsAlt - mySIeventsOrderUniqueKey.size()));
|
||||
}
|
||||
anzEventsAlt = mySIeventsOrderUniqueKey.size();
|
||||
unlockEvents();
|
||||
@@ -1984,14 +2036,14 @@ static void *houseKeepingThread(void *)
|
||||
if (mySIeventsOrderUniqueKey.size() != anzEventsAlt)
|
||||
{
|
||||
print_meminfo();
|
||||
dprintf("Removed %d waste events.\n", anzEventsAlt - mySIeventsOrderUniqueKey.size());
|
||||
dprintf("Removed %d waste events.\n", (int)(anzEventsAlt - mySIeventsOrderUniqueKey.size()));
|
||||
}
|
||||
|
||||
dprintf("Number of sptr events (event-ID): %u\n", mySIeventsOrderUniqueKey.size());
|
||||
dprintf("Number of sptr events (service-id, start time, event-id): %u\n", mySIeventsOrderServiceUniqueKeyFirstStartTimeEventUniqueKey.size());
|
||||
dprintf("Number of sptr events (end time, service-id, event-id): %u\n", mySIeventsOrderFirstEndTimeServiceIDEventUniqueKey.size());
|
||||
dprintf("Number of sptr nvod events (event-ID): %u\n", mySIeventsNVODorderUniqueKey.size());
|
||||
dprintf("Number of cached meta-services: %u\n", mySIeventUniqueKeysMetaOrderServiceUniqueKey.size());
|
||||
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());
|
||||
dprintf("Number of sptr events (end time, service-id, event-id): %u\n", (unsigned)mySIeventsOrderFirstEndTimeServiceIDEventUniqueKey.size());
|
||||
dprintf("Number of sptr nvod events (event-ID): %u\n", (unsigned)mySIeventsNVODorderUniqueKey.size());
|
||||
dprintf("Number of cached meta-services: %u\n", (unsigned)mySIeventUniqueKeysMetaOrderServiceUniqueKey.size());
|
||||
|
||||
unlockEvents();
|
||||
|
||||
@@ -2072,7 +2124,7 @@ void CEitManager::run()
|
||||
int rc;
|
||||
|
||||
xprintf("[sectionsd] starting\n");
|
||||
printf("SIevent size: %d\n", sizeof(SIevent));
|
||||
printf("SIevent size: %d\n", (int)sizeof(SIevent));
|
||||
|
||||
/* "export NO_SLOW_ADDEVENT=true" to disable this */
|
||||
slow_addevent = (getenv("NO_SLOW_ADDEVENT") == NULL);
|
||||
@@ -2451,7 +2503,7 @@ void CEitManager::getCurrentNextServiceKey(t_channel_id uniqueServiceKey, CSecti
|
||||
bool CEitManager::getEPGidShort(event_id_t epgID, CShortEPGData * epgdata)
|
||||
{
|
||||
bool ret = false;
|
||||
dprintf("Request of current EPG for 0x%llx\n", epgID);
|
||||
dprintf("Request of current EPG for 0x%" PRIx64 "\n", epgID);
|
||||
|
||||
readLockEvents();
|
||||
|
||||
@@ -2476,7 +2528,7 @@ bool CEitManager::getEPGidShort(event_id_t epgID, CShortEPGData * epgdata)
|
||||
bool CEitManager::getEPGid(const event_id_t epgID, const time_t startzeit, CEPGData * epgdata)
|
||||
{
|
||||
bool ret = false;
|
||||
dprintf("Request of actual EPG for 0x%llx 0x%lx\n", epgID, startzeit);
|
||||
dprintf("Request of actual EPG for 0x%" PRIx64 " 0x%lx\n", epgID, startzeit);
|
||||
|
||||
const SIevent& evt = findSIeventForEventUniqueKey(epgID);
|
||||
|
||||
@@ -2647,7 +2699,7 @@ showProfiling("sectionsd_getChannelEvents end");
|
||||
bool CEitManager::getComponentTagsUniqueKey(const event_id_t uniqueKey, CSectionsdClient::ComponentTagList& tags)
|
||||
{
|
||||
bool ret = false;
|
||||
dprintf("Request of ComponentTags for 0x%llx\n", uniqueKey);
|
||||
dprintf("Request of ComponentTags for 0x%" PRIx64 "\n", uniqueKey);
|
||||
|
||||
tags.clear();
|
||||
|
||||
@@ -2677,7 +2729,7 @@ bool CEitManager::getComponentTagsUniqueKey(const event_id_t uniqueKey, CSection
|
||||
bool CEitManager::getLinkageDescriptorsUniqueKey(const event_id_t uniqueKey, CSectionsdClient::LinkageDescriptorList& descriptors)
|
||||
{
|
||||
bool ret = false;
|
||||
dprintf("Request of LinkageDescriptors for 0x%llx\n", uniqueKey);
|
||||
dprintf("Request of LinkageDescriptors for 0x%" PRIx64 "\n", uniqueKey);
|
||||
|
||||
descriptors.clear();
|
||||
readLockEvents();
|
||||
@@ -2719,7 +2771,7 @@ bool CEitManager::getNVODTimesServiceKey(const t_channel_id channel_id, CSection
|
||||
MySIservicesNVODorderUniqueKey::iterator si = mySIservicesNVODorderUniqueKey.find(uniqueServiceKey);
|
||||
if (si != mySIservicesNVODorderUniqueKey.end())
|
||||
{
|
||||
dprintf("NVODServices: %u\n", si->second->nvods.size());
|
||||
dprintf("NVODServices: %u\n", (unsigned)si->second->nvods.size());
|
||||
|
||||
if (!si->second->nvods.empty()) {
|
||||
for (SInvodReferences::iterator ni = si->second->nvods.begin(); ni != si->second->nvods.end(); ++ni) {
|
||||
|
Reference in New Issue
Block a user