sectionsd: improve CN thread's handling of non-broadcast events

* reduce EIT timeout to 3 seconds
* if there are no events broadcast, send an event to neutrino anyway
* when EIT has changed but events are the same, return to sleep faster

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1229 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
seife
2011-02-27 21:19:32 +00:00
parent 887b489725
commit b1e7ea7d55

View File

@@ -159,7 +159,7 @@ static unsigned int max_events;
#define CHECK_RESTART_DMX_AFTER_TIMEOUTS (2000 / EIT_READ_TIMEOUT) // 2 seconds
// Time in seconds we are waiting for an EIT version number
#define TIME_EIT_VERSION_WAIT 35
#define TIME_EIT_VERSION_WAIT 3
// number of timeouts after which we stop waiting for an EIT version number
#define TIMEOUTS_EIT_VERSION_WAIT (2 * CHECK_RESTART_DMX_AFTER_TIMEOUTS)
@@ -745,6 +745,9 @@ static void addEvent(const SIevent &evt, const unsigned table_id, const time_t z
dprintf("addevent-cn: added running (%d) event 0x%04x '%s'\n",
e->runningStatus(), e->eventID, e->getName().c_str());
} else {
writeLockMessaging();
messaging_got_CN |= 0x01;
unlockMessaging();
dprintf("addevent-cn: not add runn. (%d) event 0x%04x '%s'\n",
e->runningStatus(), e->eventID, e->getName().c_str());
}
@@ -762,6 +765,9 @@ static void addEvent(const SIevent &evt, const unsigned table_id, const time_t z
} else {
dprintf("addevent-cn: not added next(%d) event 0x%04x '%s'\n",
e->runningStatus(), e->eventID, e->getName().c_str());
writeLockMessaging();
messaging_got_CN |= 0x02;
unlockMessaging();
}
}
unlockEvents();
@@ -7607,14 +7613,21 @@ static void *cnThread(void *)
if (!messaging_need_eit_version) {
unlockMessaging();
dprintf("waiting for eit_version...\n");
eit_waiting_since = zeit;
zeit = time(NULL); /* reset so that we don't get negative */
eit_waiting_since = zeit; /* and still compensate for getSection */
dmxCN.lastChanged = zeit; /* this is ugly - needs somehting better */
sendToSleepNow = false; /* reset after channel change */
writeLockMessaging();
messaging_need_eit_version = true;
sendToSleepNow = false; // reset after channel change
}
unlockMessaging();
if (zeit - eit_waiting_since > TIME_EIT_VERSION_WAIT) {
dprintf("waiting for more than %d seconds - bail out...\n", TIME_EIT_VERSION_WAIT);
/* send event anyway, so that we know there is no EPG */
eventServer->sendEvent(CSectionsdClient::EVT_GOT_CN_EPG,
CEventServer::INITID_SECTIONSD,
&messaging_current_servicekey,
sizeof(messaging_current_servicekey));
writeLockMessaging();
messaging_need_eit_version = false;
unlockMessaging();
@@ -7645,6 +7658,9 @@ static void *cnThread(void *)
CEventServer::INITID_SECTIONSD,
&messaging_current_servicekey,
sizeof(messaging_current_servicekey));
/* we received an event => reset timeout timer... */
eit_waiting_since = zeit;
dmxCN.lastChanged = zeit; /* this is ugly - needs somehting better */
readLockMessaging();
}
if (messaging_have_CN == 0x03) // current + next
@@ -7747,6 +7763,7 @@ static void *cnThread(void *)
}
else if (zeit > dmxCN.lastChanged + TIME_EIT_VERSION_WAIT && !messaging_need_eit_version)
{
xprintf("zeit > dmxCN.lastChanged + TIME_EIT_VERSION_WAIT\n");
sendToSleepNow = true;
continue;
}