From 82a18d0618f64c207c95e1d2b209de4c3adf0071 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 6 Mar 2011 15:34:12 +0000 Subject: [PATCH] sectionsd: improve time acquisition from DVB stream * during startup, get time from TDT, to get *any* time information quickly * after startup, immediately (after 5 seconds) retry with TDT * later calls only use TOT. TOT is not broadcast on all channels, but the channels that broadcast a TOT usually are much more "trustworthy" wrt time setting Comments welcome, also reports if this works worse than before git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1256 e54a6e83-5905-42d5-8d5c-058d10e6a962 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/53744ed62210176e75bac4d0375515a60c0ea922 Author: Stefan Seyfried Date: 2011-03-06 (Sun, 06 Mar 2011) Origin message was: ------------------ sectionsd: improve time acquisition from DVB stream * during startup, get time from TDT, to get *any* time information quickly * after startup, immediately (after 5 seconds) retry with TDT * later calls only use TOT. TOT is not broadcast on all channels, but the channels that broadcast a TOT usually are much more "trustworthy" wrt time setting Comments welcome, also reports if this works worse than before git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1256 e54a6e83-5905-42d5-8d5c-058d10e6a962 ------------------ This commit was generated by Migit --- src/sectionsd/sectionsd.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sectionsd/sectionsd.cpp b/src/sectionsd/sectionsd.cpp index ac39977a8..07cfd8051 100644 --- a/src/sectionsd/sectionsd.cpp +++ b/src/sectionsd/sectionsd.cpp @@ -6750,6 +6750,7 @@ static void *timeThread(void *) struct timespec restartWait; struct timeval now; bool time_ntp = false; + bool success = true; pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); @@ -6789,7 +6790,8 @@ static void *timeThread(void *) eventServer->sendEvent(CSectionsdClient::EVT_TIMESET, CEventServer::INITID_SECTIONSD, &actTime, sizeof(actTime) ); } else { if (dvb_time_update) { - if (getUTC(&UTC, true)) // always use TDT, a lot of transponders don't provide a TOT + success = getUTC(&UTC, first_time); // for first time, get TDT, then TOT + if (success) { tim = changeUTCtoCtime((const unsigned char *) &UTC); @@ -6810,7 +6812,6 @@ static void *timeThread(void *) actTime=time(NULL); tmTime = localtime(&actTime); xprintf("[%sThread] - %02d.%02d.%04d %02d:%02d:%02d, tim: %s", "time", tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, tmTime->tm_hour, tmTime->tm_min, tmTime->tm_sec, ctime(&tim)); - first_time = false; pthread_mutex_lock(&timeIsSetMutex); timeset = true; time_ntp= false; @@ -6822,15 +6823,19 @@ static void *timeThread(void *) } if (timeset && dvb_time_update) { - first_time = false; - seconds = ntprefresh * 60; + if (first_time) + seconds = 5; /* retry a second time immediately */ + else + seconds = ntprefresh * 60; if(time_ntp){ xprintf("[%sThread] Time set via NTP, going to sleep for %d seconds.\n", "time", seconds); } else { - xprintf("[%sThread] Time set via DVB, going to sleep for %d seconds.\n", "time", seconds); + xprintf("[%sThread] Time %sset via DVB(%s), going to sleep for %d seconds.\n", + "time", success?"":"not ", first_time?"TDT":"TOT", seconds); } + first_time = false; } else { if (!first_time){