Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dvb_psi: use monotonic clocks in dvb_time_update()
  • Loading branch information
perexg committed Mar 16, 2016
1 parent b972f75 commit 20cfeaf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/input/mpegts/dvb_psi.c
Expand Up @@ -2449,13 +2449,13 @@ psi_parse_pmt

static void dvb_time_update(const uint8_t *ptr, const char *srcname)
{
static time_t dvb_last_update = 0;
static int64_t dvb_last_update = 0;
time_t t;
if (dvb_last_update + 1800 < gclk()) {
if (dvb_last_update + sec2mono(1800) < mclk()) {
t = dvb_convert_date(ptr, 0);
if (t > 0) {
tvhtime_update(t, srcname);
dvb_last_update = gclk();
dvb_last_update = mclk();
}
}
}
Expand Down

2 comments on commit 20cfeaf

@rmillo
Copy link

@rmillo rmillo commented on 20cfeaf Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @perexg I'm using Tvheadend to get my digital TV signal using a DVB-T adapter implemented through linuxdvb API on a RaspberryPI. I have configured it to update the system clock, but when the system starts it don't update the time until 30 minutes after the system is up. I have fixed it checking for the first time update, using the condition

if (dvb_last_update == 0 || (dvb_last_update + sec2mono(1800) < mclk()))

I want to know what is the diference between use the global clock (gclk) as previous versions and the monotonic clock (mclk).

Best regards

@perexg
Copy link
Contributor Author

@perexg perexg commented on 20cfeaf Apr 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3a4e08a . Thanks.

Monotonic time is not modified from the external clock (NTP or so) where the clocks may be shifted backward. It's really bad for the code which assumes the continuous (monotonic) time line. Think about this code requirement - 'I want to wait 3 seconds without any time shifts'.

Please sign in to comment.