Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
clock: introduce +monocmpfastsec()
  • Loading branch information
perexg committed Mar 15, 2016
1 parent 647cb6a commit 42c9423
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/clock.h
Expand Up @@ -54,6 +54,7 @@ static inline time_t gclk(void)
}

#define MONOCLOCK_RESOLUTION 1000000LL /* microseconds */
#define MONOCLOCK_FASTSEC 0xfffffLL /* 1048575 */

static inline int64_t
sec2mono(int64_t sec)
Expand Down Expand Up @@ -101,6 +102,12 @@ getfastmonoclock(void)
(tp.tv_nsec / (1000000000LL/MONOCLOCK_RESOLUTION));
}

static inline int
monocmpfastsec(int64_t m1, int64_t m2)
{
return (m1 & ~MONOCLOCK_FASTSEC) == (m2 & ~MONOCLOCK_FASTSEC);
}

void time_t_out_of_range_notify(int64_t val);

static inline time_t time_t_out_of_range(uint64_t val)
Expand Down
2 changes: 1 addition & 1 deletion src/descrambler/descrambler.c
Expand Up @@ -84,7 +84,7 @@ descrambler_data_append(th_descrambler_runtime_t *dr, const uint8_t *tsb, int le
if (len == 0)
return;
dd = TAILQ_LAST(&dr->dr_queue, th_descrambler_queue);
if (dd && mono2sec(dd->dd_timestamp) == mono2sec(mclk()) &&
if (dd && monocmpfastsec(dd->dd_timestamp, mclk()) &&
(dd->dd_sbuf.sb_data[3] & 0x40) == (tsb[3] & 0x40)) { /* key match */
sbuf_append(&dd->dd_sbuf, tsb, len);
dr->dr_queue_total += len;
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/mpegts_input.c
Expand Up @@ -1053,7 +1053,7 @@ mpegts_input_recv_packets

if (len < (MIN_TS_PKT * 188) && (flags & MPEGTS_DATA_CC_RESTART) == 0) {
/* For slow streams, check also against the clock */
if (mono2sec(mclk()) == mono2sec(mi->mi_last_dispatch))
if (monocmpfastsec(mclk(), mi->mi_last_dispatch))
return;
}
mi->mi_last_dispatch = mclk();
Expand Down
5 changes: 2 additions & 3 deletions src/input/mpegts/tsdemux.c
Expand Up @@ -356,8 +356,7 @@ ts_remux(mpegts_service_t *t, const uint8_t *src, int len, int errors)
sbuf_append(sb, src, len);
sb->sb_err += errors;

if(mono2sec(mclk()) == mono2sec(t->s_tsbuf_last) &&
sb->sb_ptr < TS_REMUX_BUFSIZE)
if(monocmpfastsec(mclk(), t->s_tsbuf_last) && sb->sb_ptr < TS_REMUX_BUFSIZE)
return;

ts_flush(t, sb);
Expand All @@ -379,7 +378,7 @@ ts_skip(mpegts_service_t *t, const uint8_t *src, int len)

sb->sb_err += len / 188;

if(mono2sec(mclk()) == mono2sec(t->s_tsbuf_last) &&
if(monocmpfastsec(mclk(), t->s_tsbuf_last) &&
sb->sb_err < (TS_REMUX_BUFSIZE / 188))
return;

Expand Down

0 comments on commit 42c9423

Please sign in to comment.