mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
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
This commit is contained in:
@@ -830,14 +830,28 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
|||||||
{
|
{
|
||||||
struct timeval ltv;
|
struct timeval ltv;
|
||||||
gettimeofday(<v, NULL);
|
gettimeofday(<v, NULL);
|
||||||
int64_t timeOld = (int64_t) ltv.tv_usec + (int64_t)((int64_t) ltv.tv_sec * (int64_t) 1000000);
|
int64_t timeOld = ltv.tv_usec + ltv.tv_sec * (int64_t)1000000;
|
||||||
|
time_t dvbtime = *((time_t*)p);
|
||||||
//printf("[neutrino] event TIMESET from SECTIONSD %x %x\n", emsg.eventID, *(unsigned*) p);
|
if (dvbtime) {
|
||||||
//g_Sectionsd->registerEvent(CSectionsdClient::EVT_TIMESET, 222, NEUTRINO_UDS_NAME);
|
printf("[neutrino] timeset event. ");
|
||||||
stime((time_t*) p);
|
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(<v, &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( <v, NULL );
|
gettimeofday( <v, NULL );
|
||||||
int64_t timeNew = (int64_t) ltv.tv_usec + (int64_t)((int64_t) ltv.tv_sec * (int64_t) 1000000);
|
int64_t timeNew = ltv.tv_usec + ltv.tv_sec * (int64_t)1000000;
|
||||||
|
|
||||||
delete[] p;//new [] delete []
|
delete[] p;//new [] delete []
|
||||||
p = new unsigned char[sizeof(int64_t)];
|
p = new unsigned char[sizeof(int64_t)];
|
||||||
@@ -850,12 +864,11 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
|||||||
for(std::vector<timer>::iterator e = timers.begin(); e != timers.end(); ++e)
|
for(std::vector<timer>::iterator e = timers.begin(); e != timers.end(); ++e)
|
||||||
if (e->correct_time)
|
if (e->correct_time)
|
||||||
e->times_out+= *(int64_t*) p;
|
e->times_out+= *(int64_t*) p;
|
||||||
|
|
||||||
*msg = NeutrinoMessages::EVT_TIMESET;
|
*msg = NeutrinoMessages::EVT_TIMESET;
|
||||||
*data = (neutrino_msg_data_t) p;
|
*data = (neutrino_msg_data_t) p;
|
||||||
dont_delete_p = true;
|
dont_delete_p = true;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case CSectionsdClient::EVT_GOT_CN_EPG:
|
case CSectionsdClient::EVT_GOT_CN_EPG:
|
||||||
printf("[neutrino] CSectionsdClient::EVT_GOT_CN_EPG\n");
|
printf("[neutrino] CSectionsdClient::EVT_GOT_CN_EPG\n");
|
||||||
*msg = NeutrinoMessages::EVT_CURRENTNEXT_EPG;
|
*msg = NeutrinoMessages::EVT_CURRENTNEXT_EPG;
|
||||||
|
Reference in New Issue
Block a user