mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Synchronizing system time to the transponder time is now done using adjtime() in order to avoid discontinuities
This commit is contained in:
parent
f1603e9128
commit
f61645b4d2
@ -2731,6 +2731,8 @@ Manuel Reimer <Manuel.Reimer@gmx.de>
|
||||
contains only the address of the local host
|
||||
for a patch that was used as a base for making editing marks be updated every 10
|
||||
seconds during replay
|
||||
for suggesting to synchronize system time to the transponder time using adjtime() in
|
||||
order to avoid discontinuities
|
||||
|
||||
Rene van den Braken <rene@vandenbraken.name>
|
||||
for reporting a bug in writing the PCR pid into the PMT in
|
||||
|
5
HISTORY
5
HISTORY
@ -7339,7 +7339,7 @@ Video Disk Recorder Revision History
|
||||
- Modified editing marks are now written to disk whenever the replay progress display
|
||||
gets hidden (thanks to Christoph Haubrich).
|
||||
|
||||
2012-12-03: Version 1.7.33
|
||||
2012-12-04: Version 1.7.33
|
||||
|
||||
- In order to be able to play TS recordings from other sources, in which there is
|
||||
more than one PMT PID in the PAT, 'int cPatPmtParser::PatPmt(void)' has been changed
|
||||
@ -7366,3 +7366,6 @@ Video Disk Recorder Revision History
|
||||
- Fixed some spellings in osd.h and svdrp.c (thanks to Ville Skyttä).
|
||||
- Fixed handling lowercase polarization characters in channel definitions if no DiSEqC
|
||||
is used (reported by Mike Hay, actual bug pointed out by Stefan Huelswitt).
|
||||
- Synchronizing system time to the transponder time is now done using adjtime() in order
|
||||
to avoid discontinuities (suggested by Manuel Reimer). If the time difference is more
|
||||
than 10 seconds, stime() is still used to do the initial sync.
|
||||
|
34
eit.c
34
eit.c
@ -8,10 +8,11 @@
|
||||
* Robert Schneider <Robert.Schneider@web.de> and Rolf Hakenes <hakenes@hippomi.de>.
|
||||
* Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg <marcel.wiesweg@gmx.de>.
|
||||
*
|
||||
* $Id: eit.c 2.21 2012/08/25 11:13:00 kls Exp $
|
||||
* $Id: eit.c 2.22 2012/12/04 09:33:20 kls Exp $
|
||||
*/
|
||||
|
||||
#include "eit.h"
|
||||
#include <sys/time.h>
|
||||
#include "epg.h"
|
||||
#include "i18n.h"
|
||||
#include "libsi/section.h"
|
||||
@ -313,35 +314,48 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo
|
||||
|
||||
// --- cTDT ------------------------------------------------------------------
|
||||
|
||||
#define MAX_TIME_DIFF 1 // number of seconds the local time may differ from dvb time before making any corrections
|
||||
#define MAX_ADJ_DIFF 10 // number of seconds the local time may differ from dvb time to allow smooth adjustment
|
||||
#define ADJ_DELTA 300 // number of seconds between calls for smooth time adjustment
|
||||
|
||||
class cTDT : public SI::TDT {
|
||||
private:
|
||||
static cMutex mutex;
|
||||
static int lastDiff;
|
||||
static time_t lastAdj;
|
||||
public:
|
||||
cTDT(const u_char *Data);
|
||||
};
|
||||
|
||||
cMutex cTDT::mutex;
|
||||
int cTDT::lastDiff = 0;
|
||||
time_t cTDT::lastAdj = 0;
|
||||
|
||||
cTDT::cTDT(const u_char *Data)
|
||||
:SI::TDT(Data, false)
|
||||
{
|
||||
CheckParse();
|
||||
|
||||
time_t sattim = getTime();
|
||||
time_t dvbtim = getTime();
|
||||
time_t loctim = time(NULL);
|
||||
|
||||
int diff = abs(sattim - loctim);
|
||||
if (diff > 2) {
|
||||
int diff = dvbtim - loctim;
|
||||
if (abs(diff) > MAX_TIME_DIFF) {
|
||||
mutex.Lock();
|
||||
if (abs(diff - lastDiff) < 3) {
|
||||
if (stime(&sattim) == 0)
|
||||
isyslog("system time changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(sattim), sattim);
|
||||
if (abs(diff) > MAX_ADJ_DIFF) {
|
||||
if (stime(&dvbtim) == 0)
|
||||
isyslog("system time changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(dvbtim), dvbtim);
|
||||
else
|
||||
esyslog("ERROR while setting system time: %m");
|
||||
}
|
||||
lastDiff = diff;
|
||||
else if (time(NULL) - lastAdj > ADJ_DELTA) {
|
||||
lastAdj = time(NULL);
|
||||
timeval delta;
|
||||
delta.tv_sec = diff;
|
||||
delta.tv_usec = 0;
|
||||
if (adjtime(&delta, NULL) == 0)
|
||||
isyslog("system time adjustment initiated from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(dvbtim), dvbtim);
|
||||
else
|
||||
esyslog("ERROR while adjusting system time: %m");
|
||||
}
|
||||
mutex.Unlock();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user