Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change functions mono4sec/ms to ms/sec2mono
  • Loading branch information
perexg committed Mar 5, 2016
1 parent a6a23e1 commit f4c42ab
Show file tree
Hide file tree
Showing 46 changed files with 131 additions and 131 deletions.
2 changes: 1 addition & 1 deletion src/bouquet.c
Expand Up @@ -1030,7 +1030,7 @@ bouquet_download_trigger0(void *aux)

download_start(&bqd->download, bq->bq_ext_url, bqd);
mtimer_arm_rel(&bqd->timer, bouquet_download_trigger0, bqd,
mono4sec(MAX(1, bq->bq_ext_url_period) * 60));
sec2mono(MAX(1, bq->bq_ext_url_period) * 60));
}

static void
Expand Down
8 changes: 4 additions & 4 deletions src/clock.h
Expand Up @@ -45,25 +45,25 @@ extern time_t gdispatch_clock;
#define MONOCLOCK_RESOLUTION 1000000LL /* microseconds */

static inline int64_t
mono4sec(int64_t sec)
sec2mono(int64_t sec)
{
return sec * MONOCLOCK_RESOLUTION;
}

static inline int64_t
sec4mono(int64_t monosec)
mono2sec(int64_t monosec)
{
return monosec / MONOCLOCK_RESOLUTION;
}

static inline int64_t
mono4ms(int64_t ms)
ms2mono(int64_t ms)
{
return ms * (MONOCLOCK_RESOLUTION / 1000LL);
}

static inline int64_t
ms4mono(int64_t monosec)
mono2ms(int64_t monosec)
{
return monosec / (MONOCLOCK_RESOLUTION / 1000LL);
}
Expand Down
2 changes: 1 addition & 1 deletion src/descrambler/capmt.c
Expand Up @@ -1772,7 +1772,7 @@ capmt_thread(void *aux)

tvhlog(LOG_INFO, "capmt", "%s: Automatic reconnection attempt in in %d seconds", idnode_get_title(&capmt->cac_id, NULL), d);

mono = mdispatch_clock + mono4sec(d);
mono = mdispatch_clock + sec2mono(d);
do {
i = tvh_cond_timedwait(&capmt->capmt_cond, &capmt->capmt_mutex, mono);
if (i == ETIMEDOUT)
Expand Down
6 changes: 3 additions & 3 deletions src/descrambler/cwc.c
Expand Up @@ -1068,7 +1068,7 @@ cwc_writer_thread(void *aux)

/* If nothing is to be sent in CWC_KEEPALIVE_INTERVAL seconds we
need to send a keepalive */
mono = mdispatch_clock + mono4sec(CWC_KEEPALIVE_INTERVAL);
mono = mdispatch_clock + sec2mono(CWC_KEEPALIVE_INTERVAL);
do {
r = tvh_cond_timedwait(&cwc->cwc_writer_cond, &cwc->cwc_writer_mutex, mono);
if(r == ETIMEDOUT) {
Expand Down Expand Up @@ -1247,7 +1247,7 @@ cwc_thread(void *aux)
"%s:%i: Automatic connection attempt in %d seconds",
cwc->cwc_hostname, cwc->cwc_port, d-1);

mono = mdispatch_clock + mono4sec(d);
mono = mdispatch_clock + sec2mono(d);
do {
r = tvh_cond_timedwait(&cwc->cwc_cond, &cwc->cwc_mutex, mono);
if (r == ETIMEDOUT)
Expand Down Expand Up @@ -1316,7 +1316,7 @@ cwc_emm(void *opaque, int pid, const uint8_t *data, int len, int emm)
if (pcard->running && cwc->cwc_forward_emm && cwc->cwc_writer_running) {
if (cwc->cwc_emmex) {
if (cwc->cwc_mux != mux) {
if (cwc->cwc_update_time + mono4sec(25) < mdispatch_clock)
if (cwc->cwc_update_time + sec2mono(25) < mdispatch_clock)
goto end_of_job;
}
cwc->cwc_update_time = mdispatch_clock;
Expand Down
24 changes: 12 additions & 12 deletions 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 && sec4mono(dd->dd_timestamp) == sec4mono(mdispatch_clock) &&
if (dd && mono2sec(dd->dd_timestamp) == mono2sec(mdispatch_clock) &&
(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 Expand Up @@ -276,7 +276,7 @@ descrambler_service_start ( service_t *t )
dr->dr_service = t;
TAILQ_INIT(&dr->dr_queue);
dr->dr_key_index = 0xff;
dr->dr_key_interval = mono4sec(10);
dr->dr_key_interval = sec2mono(10);
dr->dr_key_const = constcw;
if (constcw)
tvhtrace("descrambler", "using constcw for \"%s\"", t->s_nicename);
Expand Down Expand Up @@ -574,20 +574,20 @@ key_update( th_descrambler_runtime_t *dr, uint8_t key, int64_t timestamp )
/* set the even (0) or odd (0x40) key index */
dr->dr_key_index = key & 0x40;
if (dr->dr_key_start) {
dr->dr_key_interval = dr->dr_key_start + mono4sec(50) < timestamp ?
mono4sec(10) : timestamp - dr->dr_key_start;
dr->dr_key_interval = dr->dr_key_start + sec2mono(50) < timestamp ?
sec2mono(10) : timestamp - dr->dr_key_start;
dr->dr_key_start = timestamp;
} else {
/* We don't know the exact start key switch time */
dr->dr_key_start = timestamp - mono4sec(60);
dr->dr_key_start = timestamp - sec2mono(60);
}
}

static inline int
key_changed ( th_descrambler_runtime_t *dr, uint8_t ki, int64_t timestamp )
{
return dr->dr_key_index != (ki & 0x40) &&
dr->dr_key_start + mono4sec(2) < timestamp;
dr->dr_key_start + sec2mono(2) < timestamp;
}

static inline int
Expand All @@ -612,7 +612,7 @@ key_late( th_descrambler_runtime_t *dr, uint8_t ki, int64_t timestamp )
goto late;
}
/* ECM was sent, but no new key was received */
if (dr->dr_ecm_last_key_time + mono4sec(2) < dr->dr_key_start &&
if (dr->dr_ecm_last_key_time + sec2mono(2) < dr->dr_key_start &&
(!dr->dr_quick_ecm || dr->dr_ecm_start[kidx] + 4 < dr->dr_key_start)) {
late:
dr->dr_key_valid &= ~((ki & 0x40) + 0x40);
Expand All @@ -625,7 +625,7 @@ static inline int
key_started( th_descrambler_runtime_t *dr, uint8_t ki )
{
uint8_t kidx = (ki & 0x40) >> 6;
return mdispatch_clock - dr->dr_ecm_start[kidx] < mono4sec(5);
return mdispatch_clock - dr->dr_ecm_start[kidx] < sec2mono(5);
}

static int
Expand Down Expand Up @@ -699,7 +699,7 @@ descrambler_descramble ( service_t *t,

/* process the queued TS packets */
if (dr->dr_queue_total > 0) {
descrambler_data_time_flush(dr, mdispatch_clock - (dr->dr_key_interval - mono4sec(2)));
descrambler_data_time_flush(dr, mdispatch_clock - (dr->dr_key_interval - sec2mono(2)));
for (dd = TAILQ_FIRST(&dr->dr_queue); dd; dd = dd_next) {
dd_next = TAILQ_NEXT(dd, dd_link);
sb = &dd->dd_sbuf;
Expand Down Expand Up @@ -751,7 +751,7 @@ descrambler_descramble ( service_t *t,
((mpegts_service_t *)t)->s_dvb_svcname);
if (key_late(dr, ki, mdispatch_clock)) {
tvherror("descrambler", "ECM - key late (%ld ms) for service \"%s\"",
ms4mono(mdispatch_clock - dr->dr_ecm_last_key_time),
mono2ms(mdispatch_clock - dr->dr_ecm_last_key_time),
((mpegts_service_t *)t)->s_dvb_svcname);
descrambler_notify_nokey(dr);
if (ecm_reset(t, dr)) {
Expand Down Expand Up @@ -785,7 +785,7 @@ descrambler_descramble ( service_t *t,
}
}
} else if (dr->dr_key_index != (ki & 0x40) &&
dr->dr_key_start + mono4sec(2) < mdispatch_clock) {
dr->dr_key_start + sec2mono(2) < mdispatch_clock) {
tvhtrace("descrambler", "stream key changed to %s for service \"%s\"",
(ki & 0x40) ? "odd" : "even",
((mpegts_service_t *)t)->s_dvb_svcname);
Expand All @@ -800,7 +800,7 @@ descrambler_descramble ( service_t *t,
dbuflen = MAX(300, config.descrambler_buffer);
if (dr->dr_queue_total >= dbuflen * 188) {
descrambler_data_cut(dr, MAX((dbuflen / 10) * 188, len));
if (dr->dr_last_err + mono4sec(10) < mdispatch_clock) {
if (dr->dr_last_err + sec2mono(10) < mdispatch_clock) {
dr->dr_last_err = mdispatch_clock;
tvherror("descrambler", "cannot decode packets for service \"%s\"",
((mpegts_service_t *)t)->s_dvb_svcname);
Expand Down
4 changes: 2 additions & 2 deletions src/download.c
Expand Up @@ -193,7 +193,7 @@ download_pipe_read(void *aux)
}
}

mtimer_arm_rel(&dn->pipe_read_timer, download_pipe_read, dn, mono4ms(250));
mtimer_arm_rel(&dn->pipe_read_timer, download_pipe_read, dn, ms2mono(250));
}

/*
Expand Down Expand Up @@ -228,7 +228,7 @@ download_pipe(download_t *dn, const char *args)

fcntl(dn->pipe_fd, F_SETFL, fcntl(dn->pipe_fd, F_GETFL) | O_NONBLOCK);

mtimer_arm_rel(&dn->pipe_read_timer, download_pipe_read, dn, mono4ms(250));
mtimer_arm_rel(&dn->pipe_read_timer, download_pipe_read, dn, ms2mono(250));
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/dvr/dvr_db.c
Expand Up @@ -631,7 +631,7 @@ dvr_entry_set_timer(dvr_entry_t *de)
tvhtrace("dvr", "entry timer scheduled for %"PRItime_t, start);
gtimer_arm_absn(&de->de_timer, dvr_timer_start_recording, de, start);
#if ENABLE_DBUS_1
mtimer_arm_rel(&dvr_dbus_timer, dvr_dbus_timer_cb, NULL, mono4sec(5));
mtimer_arm_rel(&dvr_dbus_timer, dvr_dbus_timer_cb, NULL, sec2mono(5));
#endif

} else {
Expand Down Expand Up @@ -1349,7 +1349,7 @@ dvr_entry_destroy(dvr_entry_t *de, int delconf)
gtimer_disarm(&de->de_timer);
mtimer_disarm(&de->de_deferred_timer);
#if ENABLE_DBUS_1
mtimer_arm_rel(&dvr_dbus_timer, dvr_dbus_timer_cb, NULL, mono4sec(2));
mtimer_arm_rel(&dvr_dbus_timer, dvr_dbus_timer_cb, NULL, sec2mono(2));
#endif

if (de->de_channel)
Expand Down
2 changes: 1 addition & 1 deletion src/dvr/dvr_rec.c
Expand Up @@ -878,7 +878,7 @@ dvr_rec_fatal_error(dvr_entry_t *de, const char *fmt, ...)
static void
dvr_notify(dvr_entry_t *de)
{
if (de->de_last_notify + mono4sec(5) < mdispatch_clock) {
if (de->de_last_notify + sec2mono(5) < mdispatch_clock) {
idnode_notify_changed(&de->de_id);
de->de_last_notify = mdispatch_clock;
htsp_dvr_entry_update(de);
Expand Down
2 changes: 1 addition & 1 deletion src/dvr/dvr_timerec.c
Expand Up @@ -716,7 +716,7 @@ dvr_timerec_timer_cb(void *aux)
}

/* load the timer */
mtimer_arm_rel(&dvr_timerec_timer, dvr_timerec_timer_cb, NULL, mono4sec(3550));
mtimer_arm_rel(&dvr_timerec_timer, dvr_timerec_timer_cb, NULL, sec2mono(3550));
}

void
Expand Down
6 changes: 3 additions & 3 deletions src/dvr/dvr_vfsmgr.c
Expand Up @@ -204,7 +204,7 @@ dvr_disk_space_cleanup(dvr_config_t *cfg)
/* When deleting a file from the disk, the system needs some time to actually do this */
/* If calling this function to fast after the previous call, statvfs might be wrong/not updated yet */
/* So we are risking to delete more files than needed, so allow 10s for the system to handle previous deletes */
if (dvr_disk_space_config_lastdelete + mono4sec(10) > mdispatch_clock) {
if (dvr_disk_space_config_lastdelete + sec2mono(10) > mdispatch_clock) {
tvhlog(LOG_WARNING, "dvr","disk space cleanup for config \"%s\" is not allowed now", configName);
return -1;
}
Expand Down Expand Up @@ -429,7 +429,7 @@ dvr_get_disk_space_cb(void *aux)
path = strdup(cfg->dvr_storage);
tasklet_arm(&dvr_disk_space_tasklet, dvr_get_disk_space_tcb, path);
}
mtimer_arm_rel(&dvr_disk_space_timer, dvr_get_disk_space_cb, NULL, mono4sec(15));
mtimer_arm_rel(&dvr_disk_space_timer, dvr_get_disk_space_cb, NULL, sec2mono(15));
}

/**
Expand All @@ -450,7 +450,7 @@ dvr_disk_space_init(void)
dvr_config_t *cfg = dvr_config_find_by_name_default(NULL);
pthread_mutex_init(&dvr_disk_space_mutex, NULL);
dvr_get_disk_space_update(cfg->dvr_storage, 1);
mtimer_arm_rel(&dvr_disk_space_timer, dvr_get_disk_space_cb, NULL, mono4sec(5));
mtimer_arm_rel(&dvr_disk_space_timer, dvr_get_disk_space_cb, NULL, sec2mono(5));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/epggrab/module/psip.c
Expand Up @@ -203,7 +203,7 @@ psip_reschedule_tables(psip_status_t *ps)
total = 0;
TAILQ_FOREACH(pt, &ps->ps_tables, pt_link) {
total++;
if (pt->pt_table && pt->pt_start + mono4sec(10) < mdispatch_clock) {
if (pt->pt_table && pt->pt_start + sec2mono(10) < mdispatch_clock) {
tvhtrace("psip", "table late: pid = 0x%04X, type = 0x%04X\n", pt->pt_pid, pt->pt_type);
mpegts_table_destroy(pt->pt_table);
pt->pt_table = NULL;
Expand Down Expand Up @@ -268,7 +268,7 @@ psip_complete_table(psip_status_t *ps, mpegts_table_t *mt)
if (ps->ps_complete) {
if (!ps->ps_armed) {
ps->ps_armed = 1;
mtimer_arm_rel(&ps->ps_reschedule_timer, psip_reschedule_tables_cb, ps, mono4sec(10));
mtimer_arm_rel(&ps->ps_reschedule_timer, psip_reschedule_tables_cb, ps, sec2mono(10));
}
return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/epggrab/otamux.c
Expand Up @@ -161,7 +161,7 @@ epggrab_ota_kick ( int delay )
if (TAILQ_EMPTY(&epggrab_ota_pending))
return;

mtimer_arm_rel(&epggrab_ota_kick_timer, epggrab_ota_kick_cb, NULL, mono4sec(delay));
mtimer_arm_rel(&epggrab_ota_kick_timer, epggrab_ota_kick_cb, NULL, sec2mono(delay));
}

static void
Expand Down Expand Up @@ -244,9 +244,9 @@ epggrab_ota_start ( epggrab_ota_mux_t *om, mpegts_mux_t *mm )
om->om_q_type = EPGGRAB_OTA_MUX_ACTIVE;
grace = mpegts_input_grace(mmi->mmi_input, mm);
mtimer_arm_rel(&om->om_timer, epggrab_ota_timeout_cb, om,
mono4sec(epggrab_ota_timeout_get() + grace));
sec2mono(epggrab_ota_timeout_get() + grace));
mtimer_arm_rel(&om->om_data_timer, epggrab_ota_data_timeout_cb, om,
mono4sec(30 + grace)); /* 30 seconds to receive any EPG info */
sec2mono(30 + grace)); /* 30 seconds to receive any EPG info */
if (modname) {
LIST_FOREACH(m, &epggrab_modules, link)
if (!strcmp(m->id, modname)) {
Expand Down
8 changes: 4 additions & 4 deletions src/htsp_server.c
Expand Up @@ -2331,7 +2331,7 @@ static void _bytes_out_cb(void *aux)
htsp_subscription_t *hs = aux;
if (hs->hs_s) {
subscription_add_bytes_out(hs->hs_s, atomic_exchange(&hs->hs_s_bytes_out, 0));
mtimer_arm_rel(&hs->hs_s_bytes_out_timer, _bytes_out_cb, hs, mono4ms(200));
mtimer_arm_rel(&hs->hs_s_bytes_out_timer, _bytes_out_cb, hs, ms2mono(200));
}
}

Expand Down Expand Up @@ -2446,7 +2446,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
htsp->htsp_clientname,
NULL);
if (hs->hs_s)
mtimer_arm_rel(&hs->hs_s_bytes_out_timer, _bytes_out_cb, hs, mono4ms(200));
mtimer_arm_rel(&hs->hs_s_bytes_out_timer, _bytes_out_cb, hs, ms2mono(200));
return NULL;
}

Expand Down Expand Up @@ -3680,7 +3680,7 @@ htsp_epg_send_waiting(htsp_connection_t *htsp, int64_t mintime)
/* Keep the epg window up to date */
if (htsp->htsp_epg_window)
mtimer_arm_rel(&htsp->htsp_epg_timer, htsp_epg_window_cb,
htsp, mono4sec(HTSP_ASYNC_EPG_INTERVAL));
htsp, sec2mono(HTSP_ASYNC_EPG_INTERVAL));
}

/**
Expand Down Expand Up @@ -3809,7 +3809,7 @@ htsp_stream_deliver(htsp_subscription_t *hs, th_pkt_t *pkt)
htsp_send_subscription(htsp, m, pkt->pkt_payload, hs, payloadlen);
atomic_add(&hs->hs_s_bytes_out, payloadlen);

if(sec4mono(hs->hs_last_report) != sec4mono(mdispatch_clock)) {
if(mono2sec(hs->hs_last_report) != mono2sec(mdispatch_clock)) {

/* Send a queue and signal status report every second */

Expand Down
4 changes: 2 additions & 2 deletions src/imagecache.c
Expand Up @@ -463,7 +463,7 @@ imagecache_init ( void )
// TODO: this could be more efficient by being targetted, however
// the reality its not necessary and I'd prefer to avoid dumping
// 100's of timers into the global pool
mtimer_arm_rel(&imagecache_timer, imagecache_timer_cb, NULL, mono4sec(600));
mtimer_arm_rel(&imagecache_timer, imagecache_timer_cb, NULL, sec2mono(600));
#endif
}

Expand Down Expand Up @@ -668,7 +668,7 @@ imagecache_open ( uint32_t id )

/* Wait */
} else if (i->state == FETCHING) {
mono = mdispatch_clock + mono4sec(5);
mono = mdispatch_clock + sec2mono(5);
do {
e = tvh_cond_timedwait(&imagecache_cond, &global_lock, mono);
if (e == ETIMEDOUT)
Expand Down
6 changes: 3 additions & 3 deletions src/input/mpegts/iptv/iptv.c
Expand Up @@ -117,7 +117,7 @@ iptv_bouquet_update(void *aux)
void
iptv_bouquet_trigger(iptv_network_t *in, int timeout)
{
mtimer_arm_rel(&in->in_bouquet_timer, iptv_bouquet_update, in, mono4sec(timeout));
mtimer_arm_rel(&in->in_bouquet_timer, iptv_bouquet_update, in, sec2mono(timeout));
}

void
Expand Down Expand Up @@ -446,7 +446,7 @@ iptv_input_unpause ( void *aux )
}
pthread_mutex_unlock(&iptv_lock);
if (pause)
mtimer_arm_rel(&im->im_pause_timer, iptv_input_unpause, im, mono4sec(1));
mtimer_arm_rel(&im->im_pause_timer, iptv_input_unpause, im, sec2mono(1));
}

static void *
Expand Down Expand Up @@ -492,7 +492,7 @@ iptv_input_thread ( void *aux )
if (r == 1) {
pthread_mutex_lock(&global_lock);
if (im->mm_active)
mtimer_arm_rel(&im->im_pause_timer, iptv_input_unpause, im, mono4sec(1));
mtimer_arm_rel(&im->im_pause_timer, iptv_input_unpause, im, sec2mono(1));
pthread_mutex_unlock(&global_lock);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -398,7 +398,7 @@ iptv_auto_network_trigger0(void *aux)

download_start(&ap->in_download, in->in_url, ap);
mtimer_arm_rel(&ap->in_auto_timer, iptv_auto_network_trigger0, ap,
mono4sec(MAX(1, in->in_refetch_period) * 60));
sec2mono(MAX(1, in->in_refetch_period) * 60));
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/iptv/iptv_file.c
Expand Up @@ -55,7 +55,7 @@ iptv_file_thread ( void *aux )
pthread_mutex_lock(&iptv_lock);
while (!fp->shutdown && fd > 0) {
while (!fp->shutdown && pause) {
mono = mdispatch_clock + mono4sec(1);
mono = mdispatch_clock + sec2mono(1);
do {
e = tvh_cond_timedwait(&fp->cond, &iptv_lock, mono);
if (e == ETIMEDOUT)
Expand Down

0 comments on commit f4c42ab

Please sign in to comment.