mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +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
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:
@@ -827,35 +827,48 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
|||||||
switch(emsg.eventID)
|
switch(emsg.eventID)
|
||||||
{
|
{
|
||||||
case CSectionsdClient::EVT_TIMESET:
|
case CSectionsdClient::EVT_TIMESET:
|
||||||
{
|
{
|
||||||
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) {
|
||||||
gettimeofday( <v, NULL );
|
printf("difference is %ld s, stepping...\n", difftime);
|
||||||
int64_t timeNew = (int64_t) ltv.tv_usec + (int64_t)((int64_t) ltv.tv_sec * (int64_t) 1000000);
|
if (stime(&dvbtime))
|
||||||
|
perror("stime");
|
||||||
delete[] p;//new [] delete []
|
} else if (difftime != 0) {
|
||||||
p= new unsigned char[ sizeof(int64_t) ];
|
struct timeval oldd;
|
||||||
*(int64_t*) p = timeNew - timeOld;
|
ltv.tv_sec = difftime;
|
||||||
|
ltv.tv_usec = 0;
|
||||||
if ((int64_t)last_keypress > *(int64_t*)p)
|
if (adjtime(<v, &oldd))
|
||||||
last_keypress += *(int64_t *)p;
|
perror("adjtime");
|
||||||
|
int64_t t = oldd.tv_sec * 1000000LL + oldd.tv_usec;
|
||||||
// Timer anpassen
|
printf("difference is %ld s, using adjtime(). oldd: %lld us\n", difftime, t);
|
||||||
for(std::vector<timer>::iterator e = timers.begin(); e != timers.end(); ++e)
|
} else
|
||||||
if (e->correct_time)
|
printf("difference is 0 s, nothing to do...\n");
|
||||||
e->times_out+= *(int64_t*) p;
|
|
||||||
|
|
||||||
*msg = NeutrinoMessages::EVT_TIMESET;
|
|
||||||
*data = (neutrino_msg_data_t) p;
|
|
||||||
dont_delete_p = true;
|
|
||||||
}
|
}
|
||||||
|
gettimeofday( <v, 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;
|
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