neutrino: port "do not step time for small differences" from tuxbox

When receiving new system time data from the DVB stream, and the
difference to the current time is less than 120 seconds, do not step
the time but call adjtime(3) instead to do a continuous time correction.

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@762 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Branch: ni/coolstream
Commit: 82fd0787ee
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2010-09-12 (Sun, 12 Sep 2010)



------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2010-09-12 14:42:40 +00:00
parent 5dde3975e4
commit bf908b613a

View File

@@ -827,35 +827,48 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
switch(emsg.eventID)
{
case CSectionsdClient::EVT_TIMESET:
{
struct timeval ltv;
gettimeofday( &ltv, NULL );
int64_t timeOld = (int64_t) ltv.tv_usec + (int64_t)((int64_t) ltv.tv_sec * (int64_t) 1000000);
//printf("[neutrino] event TIMESET from SECTIONSD %x %x\n", emsg.eventID, *(unsigned*) p);
//g_Sectionsd->registerEvent(CSectionsdClient::EVT_TIMESET, 222, NEUTRINO_UDS_NAME);
stime((time_t*) p);
gettimeofday( &ltv, NULL );
int64_t timeNew = (int64_t) ltv.tv_usec + (int64_t)((int64_t) ltv.tv_sec * (int64_t) 1000000);
delete[] p;//new [] delete []
p= new unsigned char[ sizeof(int64_t) ];
*(int64_t*) p = timeNew - timeOld;
if ((int64_t)last_keypress > *(int64_t*)p)
last_keypress += *(int64_t *)p;
// Timer anpassen
for(std::vector<timer>::iterator e = timers.begin(); e != timers.end(); ++e)
if (e->correct_time)
e->times_out+= *(int64_t*) p;
*msg = NeutrinoMessages::EVT_TIMESET;
*data = (neutrino_msg_data_t) p;
dont_delete_p = true;
{
struct timeval ltv;
gettimeofday(&ltv, NULL);
int64_t timeOld = ltv.tv_usec + ltv.tv_sec * (int64_t)1000000;
time_t dvbtime = *((time_t*)p);
if (dvbtime) {
printf("[neutrino] timeset event. ");
time_t difftime = dvbtime - ltv.tv_sec;
if (abs(difftime) > 120) {
printf("difference is %ld s, stepping...\n", difftime);
if (stime(&dvbtime))
perror("stime");
} else if (difftime != 0) {
struct timeval oldd;
ltv.tv_sec = difftime;
ltv.tv_usec = 0;
if (adjtime(&ltv, &oldd))
perror("adjtime");
int64_t t = oldd.tv_sec * 1000000LL + oldd.tv_usec;
printf("difference is %ld s, using adjtime(). oldd: %lld us\n", difftime, t);
} else
printf("difference is 0 s, nothing to do...\n");
}
gettimeofday( &ltv, NULL );
int64_t timeNew = ltv.tv_usec + ltv.tv_sec * (int64_t)1000000;
delete[] p;//new [] delete []
p = new unsigned char[sizeof(int64_t)];
*(int64_t*) p = timeNew - timeOld;
if ((int64_t)last_keypress > *(int64_t*)p)
last_keypress += *(int64_t *)p;
// Timer anpassen
for(std::vector<timer>::iterator e = timers.begin(); e != timers.end(); ++e)
if (e->correct_time)
e->times_out+= *(int64_t*) p;
*msg = NeutrinoMessages::EVT_TIMESET;
*data = (neutrino_msg_data_t) p;
dont_delete_p = true;
break;
}
case CSectionsdClient::EVT_GOT_CN_EPG:
printf("[neutrino] CSectionsdClient::EVT_GOT_CN_EPG\n");
*msg = NeutrinoMessages::EVT_CURRENTNEXT_EPG;