From: Jaroslav Kysela Date: Sat, 5 Mar 2016 15:23:47 +0000 (+0100) Subject: change functions mono4sec/ms to ms/sec2mono X-Git-Tag: v4.2.1~963 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4c42ab11fc4a993716c87edff3b06ba4382822b;p=thirdparty%2Ftvheadend.git change functions mono4sec/ms to ms/sec2mono --- diff --git a/src/bouquet.c b/src/bouquet.c index 50749a2b3..0a95d0337 100644 --- a/src/bouquet.c +++ b/src/bouquet.c @@ -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 diff --git a/src/clock.h b/src/clock.h index 849c9e842..79d8db096 100644 --- a/src/clock.h +++ b/src/clock.h @@ -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); } diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 490f04032..7acfae83c 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -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) diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index a39510757..289fefe12 100644 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -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) { @@ -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) @@ -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; diff --git a/src/descrambler/descrambler.c b/src/descrambler/descrambler.c index a6968a69a..99bef606b 100644 --- a/src/descrambler/descrambler.c +++ b/src/descrambler/descrambler.c @@ -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; @@ -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); @@ -574,12 +574,12 @@ 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); } } @@ -587,7 +587,7 @@ 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 @@ -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); @@ -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 @@ -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; @@ -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)) { @@ -785,7 +785,7 @@ next: } } } 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); @@ -800,7 +800,7 @@ next: 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); diff --git a/src/download.c b/src/download.c index 4303656e4..b63215795 100644 --- a/src/download.c +++ b/src/download.c @@ -193,7 +193,7 @@ failed: } } - 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)); } /* @@ -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; } diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index b00f981ea..dff533104 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -631,7 +631,7 @@ recording: 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 { @@ -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) diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index cea27874f..d107d7b7f 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -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); diff --git a/src/dvr/dvr_timerec.c b/src/dvr/dvr_timerec.c index f1ff17883..c6d053624 100644 --- a/src/dvr/dvr_timerec.c +++ b/src/dvr/dvr_timerec.c @@ -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 diff --git a/src/dvr/dvr_vfsmgr.c b/src/dvr/dvr_vfsmgr.c index bd7e0d45d..aa3d6b142 100644 --- a/src/dvr/dvr_vfsmgr.c +++ b/src/dvr/dvr_vfsmgr.c @@ -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; } @@ -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)); } /** @@ -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)); } /** diff --git a/src/epggrab/module/psip.c b/src/epggrab/module/psip.c index 32b52a7ea..f85e2d38c 100644 --- a/src/epggrab/module/psip.c +++ b/src/epggrab/module/psip.c @@ -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; @@ -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; } diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c index a1293ee1d..06f108447 100644 --- a/src/epggrab/otamux.c +++ b/src/epggrab/otamux.c @@ -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 @@ -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)) { diff --git a/src/htsp_server.c b/src/htsp_server.c index ce8b9f330..c47b50c2d 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -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)); } } @@ -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; } @@ -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)); } /** @@ -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 */ diff --git a/src/imagecache.c b/src/imagecache.c index 634c8a9e0..26d76ff5c 100644 --- a/src/imagecache.c +++ b/src/imagecache.c @@ -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 } @@ -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) diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 1cb88cf03..3fddd71a0 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -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 @@ -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 * @@ -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); } } diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index 7519aeac2..4e3d8c264 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -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)); } /* diff --git a/src/input/mpegts/iptv/iptv_file.c b/src/input/mpegts/iptv/iptv_file.c index ee9ff4bd0..6d18765ec 100644 --- a/src/input/mpegts/iptv/iptv_file.c +++ b/src/input/mpegts/iptv/iptv_file.c @@ -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) diff --git a/src/input/mpegts/iptv/iptv_http.c b/src/input/mpegts/iptv/iptv_http.c index 7898b77ec..71282ad5b 100644 --- a/src/input/mpegts/iptv/iptv_http.c +++ b/src/input/mpegts/iptv/iptv_http.c @@ -323,7 +323,7 @@ iptv_http_data memcpy(hp->hls_si, buf, 2*188); } - if (hp->hls_last_si + mono4sec(1) <= mdispatch_clock && hp->hls_si) { + if (hp->hls_last_si + sec2mono(1) <= mdispatch_clock && hp->hls_si) { /* do rounding to start of the last MPEG-TS packet */ rem = 188 - (hp->off % 188); if (im->mm_iptv_buffer.sb_ptr >= rem) { @@ -344,7 +344,7 @@ iptv_http_data if (pause && iptv_http_safe_global_lock(hp)) { if (im->mm_active && !hp->shutdown) - 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); } return 0; diff --git a/src/input/mpegts/iptv/iptv_pipe.c b/src/input/mpegts/iptv/iptv_pipe.c index 2fc52717e..bdb8640fb 100644 --- a/src/input/mpegts/iptv/iptv_pipe.c +++ b/src/input/mpegts/iptv/iptv_pipe.c @@ -123,7 +123,7 @@ iptv_pipe_read ( iptv_mux_t *im ) spawn_kill(pid, iptv_pipe_kill_sig(im), im->mm_iptv_kill_timeout); im->mm_iptv_fd = -1; im->im_data = NULL; - if (mdispatch_clock < im->mm_iptv_respawn_last + mono4sec(2)) { + if (mdispatch_clock < im->mm_iptv_respawn_last + sec2mono(2)) { tvherror("iptv", "stdin pipe unexpectedly closed: %s", r < 0 ? strerror(errno) : "No data"); } else { diff --git a/src/input/mpegts/iptv/iptv_rtsp.c b/src/input/mpegts/iptv/iptv_rtsp.c index b70d798f3..e56084b03 100644 --- a/src/input/mpegts/iptv/iptv_rtsp.c +++ b/src/input/mpegts/iptv/iptv_rtsp.c @@ -55,7 +55,7 @@ iptv_rtsp_alive_cb ( void *aux ) rtsp_send(rp->hc, RTSP_CMD_OPTIONS, rp->path, rp->query, NULL); mtimer_arm_rel(&rp->alive_timer, iptv_rtsp_alive_cb, im, - mono4sec(MAX(1, (rp->hc->hc_rtp_timeout / 2) - 1))); + sec2mono(MAX(1, (rp->hc->hc_rtp_timeout / 2) - 1))); } /* @@ -103,7 +103,7 @@ iptv_rtsp_header ( http_client_t *hc ) pthread_mutex_lock(&global_lock); iptv_input_mux_started(hc->hc_aux); mtimer_arm_rel(&rp->alive_timer, iptv_rtsp_alive_cb, im, - mono4sec(MAX(1, (hc->hc_rtp_timeout / 2) - 1))); + sec2mono(MAX(1, (hc->hc_rtp_timeout / 2) - 1))); pthread_mutex_unlock(&global_lock); break; default: diff --git a/src/input/mpegts/linuxdvb/linuxdvb_ca.c b/src/input/mpegts/linuxdvb/linuxdvb_ca.c index c14d22964..41b586592 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_ca.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_ca.c @@ -765,7 +765,7 @@ linuxdvb_ca_monitor ( void *aux ) } - mtimer_arm_rel(&lca->lca_monitor_timer, linuxdvb_ca_monitor, lca, mono4ms(250)); + mtimer_arm_rel(&lca->lca_monitor_timer, linuxdvb_ca_monitor, lca, ms2mono(250)); } linuxdvb_ca_t * @@ -806,7 +806,7 @@ linuxdvb_ca_create TAILQ_INIT(&lca->lca_capmt_queue); - mtimer_arm_rel(&lca->lca_monitor_timer, linuxdvb_ca_monitor, lca, mono4ms(250)); + mtimer_arm_rel(&lca->lca_monitor_timer, linuxdvb_ca_monitor, lca, ms2mono(250)); return lca; } @@ -869,7 +869,7 @@ done: if (!TAILQ_EMPTY(&lca->lca_capmt_queue)) { mtimer_arm_rel(&lca->lca_capmt_queue_timer, - linuxdvb_ca_process_capmt_queue, lca, mono4ms(i)); + linuxdvb_ca_process_capmt_queue, lca, ms2mono(i)); } } @@ -906,7 +906,7 @@ linuxdvb_ca_enqueue_capmt(linuxdvb_ca_t *lca, uint8_t slot, const uint8_t *ptr, } mtimer_arm_rel(&lca->lca_capmt_queue_timer, - linuxdvb_ca_process_capmt_queue, lca, mono4ms(50)); + linuxdvb_ca_process_capmt_queue, lca, ms2mono(50)); } void linuxdvb_ca_save( linuxdvb_ca_t *lca, htsmsg_t *msg ) diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index a2a4e5bdc..1437e9271 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -529,7 +529,7 @@ linuxdvb_frontend_stop_mux lfe->lfe_status2 = 0; /* Ensure it won't happen immediately */ - mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, mono4sec(2)); + mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, sec2mono(2)); if (lfe->lfe_satconf && lfe->lfe_refcount == 1) linuxdvb_satconf_post_stop_mux(lfe->lfe_satconf); @@ -546,7 +546,7 @@ linuxdvb_frontend_stop_mux lfe2->lfe_status = 0; lfe2->lfe_status2 = 0; /* Ensure it won't happen immediately */ - mtimer_arm_rel(&lfe2->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, mono4sec(2)); + mtimer_arm_rel(&lfe2->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, sec2mono(2)); if (lfe2->lfe_satconf) linuxdvb_satconf_post_stop_mux(lfe2->lfe_satconf); lfe2->lfe_in_setup = 0; @@ -711,7 +711,7 @@ linuxdvb_frontend_monitor ( void *aux ) if (!mmi || !lfe->lfe_ready) return; /* re-arm */ - mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, mono4ms(period)); + mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, ms2mono(period)); /* Get current status */ if (ioctl(lfe->lfe_fe_fd, FE_READ_STATUS, &fe_status) == -1) { @@ -751,7 +751,7 @@ linuxdvb_frontend_monitor ( void *aux ) if (lfe->lfe_locked && lfe->lfe_freq > 0) { tvhlog(LOG_WARNING, "linuxdvb", "%s - %s", buf, retune ? "retune" : "retune nodata"); linuxdvb_frontend_tune0(lfe, mmi, lfe->lfe_freq); - mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, mono4ms(50)); + mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, ms2mono(50)); lfe->lfe_locked = 1; } } @@ -786,17 +786,17 @@ linuxdvb_frontend_monitor ( void *aux ) /* Re-arm (quick) */ } else { mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, - lfe, mono4ms(50)); + lfe, ms2mono(50)); /* Monitor 1 per sec */ if (mdispatch_clock < lfe->lfe_monitor) return; - lfe->lfe_monitor = mdispatch_clock + mono4sec(1); + lfe->lfe_monitor = mdispatch_clock + sec2mono(1); } } else { if (mdispatch_clock < lfe->lfe_monitor) return; - lfe->lfe_monitor = mdispatch_clock + mono4sec((period + 999) / 1000); + lfe->lfe_monitor = mdispatch_clock + ms2mono(period); } /* Statistics - New API */ @@ -1766,7 +1766,7 @@ linuxdvb_frontend_tune1 if (!r) { time(&lfe->lfe_monitor); lfe->lfe_monitor += 4; - mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, mono4ms(50)); + mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, ms2mono(50)); lfe->lfe_ready = 1; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index 6b1080ad2..53f95503a 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -825,7 +825,7 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) /* Pending */ if (r != 0) { tvhtrace("diseqc", "waiting %d seconds to finish setup for %s", r, lds[i]->ld_type); - mtimer_arm_rel(&ls->ls_diseqc_timer, linuxdvb_satconf_ele_tune_cb, lse, mono4sec(r)); + mtimer_arm_rel(&ls->ls_diseqc_timer, linuxdvb_satconf_ele_tune_cb, lse, sec2mono(r)); ls->ls_diseqc_idx = i + 1; return 0; } diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 37832eb09..43c5f9d48 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -861,7 +861,7 @@ mpegts_input_started_mux /* Arm timer */ if (LIST_FIRST(&mi->mi_mux_active) == NULL) - mtimer_arm_rel(&mi->mi_status_timer, mpegts_input_status_timer, mi, mono4sec(1)); + mtimer_arm_rel(&mi->mi_status_timer, mpegts_input_status_timer, mi, sec2mono(1)); /* Update */ mmi->mmi_mux->mm_active = mmi; @@ -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 (sec4mono(mdispatch_clock) == sec4mono(mi->mi_last_dispatch)) + if (mono2sec(mdispatch_clock) == mono2sec(mi->mi_last_dispatch)) return; } mi->mi_last_dispatch = mdispatch_clock; @@ -1737,7 +1737,7 @@ mpegts_input_status_timer ( void *p ) tvh_input_stream_destroy(&st); } pthread_mutex_unlock(&mi->mi_output_lock); - mtimer_arm_rel(&mi->mi_status_timer, mpegts_input_status_timer, mi, mono4sec(1)); + mtimer_arm_rel(&mi->mi_status_timer, mpegts_input_status_timer, mi, sec2mono(1)); mpegts_input_dbus_notify(mi, subs); } diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index b646311da..971d4faed 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -95,7 +95,7 @@ mpegts_mux_scan_active t = mpegts_input_grace(mi, mm); /* Setup timeout */ - mtimer_arm_rel(&mm->mm_scan_timeout, mpegts_mux_scan_timeout, mm, mono4sec(t)); + mtimer_arm_rel(&mm->mm_scan_timeout, mpegts_mux_scan_timeout, mm, sec2mono(t)); } } @@ -1090,7 +1090,7 @@ again: /* Pending tables (another 20s or 30s - bit arbitrary) */ } else if (q) { tvhtrace("mpegts", "%s - scan needs more time", buf); - mtimer_arm_rel(&mm->mm_scan_timeout, mpegts_mux_scan_timeout, mm, mono4sec(w ? 30 : 20)); + mtimer_arm_rel(&mm->mm_scan_timeout, mpegts_mux_scan_timeout, mm, sec2mono(w ? 30 : 20)); return; /* Complete */ diff --git a/src/input/mpegts/mpegts_network_dvb.c b/src/input/mpegts/mpegts_network_dvb.c index 22b144db1..1804beb49 100644 --- a/src/input/mpegts/mpegts_network_dvb.c +++ b/src/input/mpegts/mpegts_network_dvb.c @@ -740,7 +740,7 @@ dvb_network_create_mux save: if (mm && save) { mm->mm_dmc_origin = origin; - mm->mm_dmc_origin_expire = mdispatch_clock + mono4sec(3600 * 24); /* one day */ + mm->mm_dmc_origin_expire = mdispatch_clock + sec2mono(3600 * 24); /* one day */ idnode_changed(&mm->mm_id); } noop: diff --git a/src/input/mpegts/mpegts_network_scan.c b/src/input/mpegts/mpegts_network_scan.c index f5798dbca..ff522a5c4 100644 --- a/src/input/mpegts/mpegts_network_scan.c +++ b/src/input/mpegts/mpegts_network_scan.c @@ -89,7 +89,7 @@ mpegts_network_scan_timer_cb ( void *p ) /* Re-arm timer. Really this is just a safety measure as we'd normally * expect the timer to be forcefully triggered on finish of a mux scan */ - mtimer_arm_rel(&mn->mn_scan_timer, mpegts_network_scan_timer_cb, mn, mono4sec(120)); + mtimer_arm_rel(&mn->mn_scan_timer, mpegts_network_scan_timer_cb, mn, sec2mono(120)); } /****************************************************************************** @@ -111,7 +111,7 @@ mpegts_network_scan_mux_done0 TAILQ_REMOVE(&mn->mn_scan_pend, mm, mm_scan_link); TAILQ_INSERT_SORTED_R(&mn->mn_scan_pend, mpegts_mux_queue, mm, mm_scan_link, mm_cmp); - mtimer_arm_rel(&mn->mn_scan_timer, mpegts_network_scan_timer_cb, mn, mono4sec(10)); + mtimer_arm_rel(&mn->mn_scan_timer, mpegts_network_scan_timer_cb, mn, sec2mono(10)); weight = 0; } else { mpegts_network_scan_queue_del(mm); @@ -245,7 +245,7 @@ mpegts_network_scan_queue_add mm->mm_scan_flags = SUBSCRIPTION_IDLESCAN; TAILQ_INSERT_SORTED_R(&mn->mn_scan_pend, mpegts_mux_queue, mm, mm_scan_link, mm_cmp); - mtimer_arm_rel(&mn->mn_scan_timer, mpegts_network_scan_timer_cb, mn, mono4sec(delay)); + mtimer_arm_rel(&mn->mn_scan_timer, mpegts_network_scan_timer_cb, mn, sec2mono(delay)); mpegts_network_scan_notify(mm); } diff --git a/src/input/mpegts/satip/satip.c b/src/input/mpegts/satip/satip.c index 9fa53e27d..655f31d45 100644 --- a/src/input/mpegts/satip/satip.c +++ b/src/input/mpegts/satip/satip.c @@ -764,7 +764,7 @@ satip_device_destroy_cb( void *aux ) void satip_device_destroy_later( satip_device_t *sd, int after ) { - mtimer_arm_rel(&sd->sd_destroy_timer, satip_device_destroy_cb, sd, mono4ms(after)); + mtimer_arm_rel(&sd->sd_destroy_timer, satip_device_destroy_cb, sd, ms2mono(after)); } /* @@ -1006,7 +1006,7 @@ satip_discovery_timerq_cb(void *aux) d = next; next = TAILQ_NEXT(d, disc_link); if (d->http_client) { - if (mdispatch_clock - d->http_start > mono4sec(4)) + if (mdispatch_clock - d->http_start > sec2mono(4)) satip_discovery_destroy(d, 1); continue; } @@ -1025,7 +1025,7 @@ satip_discovery_timerq_cb(void *aux) } } if (TAILQ_FIRST(&satip_discoveries)) - mtimer_arm_rel(&satip_discovery_timerq, satip_discovery_timerq_cb, NULL, mono4sec(5)); + mtimer_arm_rel(&satip_discovery_timerq, satip_discovery_timerq_cb, NULL, sec2mono(5)); } static void @@ -1134,7 +1134,7 @@ satip_discovery_service_received if (!satip_discovery_find(d) && !satip_device_find(d->uuid)) { TAILQ_INSERT_TAIL(&satip_discoveries, d, disc_link); satip_discoveries_count++; - mtimer_arm_rel(&satip_discovery_timerq, satip_discovery_timerq_cb, NULL, mono4ms(250)); + mtimer_arm_rel(&satip_discovery_timerq, satip_discovery_timerq_cb, NULL, ms2mono(250)); i = 0; } pthread_mutex_unlock(&global_lock); @@ -1148,7 +1148,7 @@ add_uuid: /* if new uuid was discovered, retrigger MSEARCH */ pthread_mutex_lock(&global_lock); if (!satip_device_find(uuid)) - mtimer_arm_rel(&satip_discovery_timer, satip_discovery_timer_cb, NULL, mono4sec(5)); + mtimer_arm_rel(&satip_discovery_timer, satip_discovery_timer_cb, NULL, sec2mono(5)); pthread_mutex_unlock(&global_lock); } @@ -1211,7 +1211,7 @@ ST: urn:ses-com:device:SatIPServer:1\r\n" htsbuf_queue_flush(&q); mtimer_arm_rel(&satip_discovery_msearch_timer, satip_discovery_send_msearch, - (void *)(intptr_t)(attempt + 1), mono4ms(attempt * 11)); + (void *)(intptr_t)(attempt + 1), ms2mono(attempt * 11)); #undef MSG } @@ -1224,7 +1224,7 @@ satip_discovery_static_timer_cb(void *aux) return; for (i = 0; i < satip_static_clients->num; i++) satip_discovery_static(satip_static_clients->str[i]); - mtimer_arm_rel(&satip_discovery_static_timer, satip_discovery_static_timer_cb, NULL, mono4sec(3600)); + mtimer_arm_rel(&satip_discovery_static_timer, satip_discovery_static_timer_cb, NULL, sec2mono(3600)); } static void @@ -1234,7 +1234,7 @@ satip_discovery_timer_cb(void *aux) return; if (!upnp_running) { mtimer_arm_rel(&satip_discovery_timer, satip_discovery_timer_cb, - NULL, mono4sec(1)); + NULL, sec2mono(1)); return; } if (satip_discovery_service == NULL) { @@ -1247,7 +1247,7 @@ satip_discovery_timer_cb(void *aux) if (satip_discovery_service) satip_discovery_send_msearch((void *)1); mtimer_arm_rel(&satip_discovery_timer, satip_discovery_timer_cb, - NULL, mono4sec(3600)); + NULL, sec2mono(3600)); } void @@ -1256,9 +1256,9 @@ satip_device_discovery_start( void ) if (!satip_enabled) return; mtimer_arm_rel(&satip_discovery_timer, satip_discovery_timer_cb, - NULL, mono4sec(1)); + NULL, sec2mono(1)); mtimer_arm_rel(&satip_discovery_static_timer, satip_discovery_static_timer_cb, - NULL, mono4sec(1)); + NULL, sec2mono(1)); } /* diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index 0bfec3289..703195b4d 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -87,7 +87,7 @@ satip_frontend_signal_cb( void *aux ) pthread_mutex_unlock(&svc->s_stream_mutex); } mtimer_arm_rel(&lfe->sf_monitor_timer, satip_frontend_signal_cb, - lfe, mono4ms(250)); + lfe, ms2mono(250)); } /* ************************************************************************** @@ -593,7 +593,7 @@ satip_frontend_start_mux tvh_write(lfe->sf_dvr_pipe.wr, "s", 1); mtimer_arm_rel(&lfe->sf_monitor_timer, satip_frontend_signal_cb, - lfe, mono4ms(50)); + lfe, ms2mono(50)); return 0; } @@ -1123,7 +1123,7 @@ wrdata: } if (lfe->sf_sbuf.sb_ptr > 64 * 1024 || - lfe->sf_last_data_tstamp + mono4sec(1) <= mdispatch_clock) { + lfe->sf_last_data_tstamp + sec2mono(1) <= mdispatch_clock) { pthread_mutex_lock(&lfe->sf_dvr_lock); if (lfe->sf_req == lfe->sf_req_thread) { mmi = lfe->sf_req->sf_mmi; @@ -1607,7 +1607,7 @@ new_tune: } /* We need to keep the session alive */ - if (rtsp->hc_ping_time + mono4sec(rtsp->hc_rtp_timeout / 2) < mdispatch_clock && + if (rtsp->hc_ping_time + sec2mono(rtsp->hc_rtp_timeout / 2) < mdispatch_clock && rtsp->hc_cmd == HTTP_CMD_NONE) { rtsp_options(rtsp); reply = 1; diff --git a/src/input/mpegts/tsdemux.c b/src/input/mpegts/tsdemux.c index f5dbe2904..a417f23c3 100644 --- a/src/input/mpegts/tsdemux.c +++ b/src/input/mpegts/tsdemux.c @@ -73,7 +73,7 @@ ts_recv_packet0 cc = tsb2[3] & 0xf; if(st->es_cc != -1 && cc != st->es_cc) { /* Let the hardware to stabilize and don't flood the log */ - if (t->s_start_time + mono4sec(1) < mdispatch_clock && + if (t->s_start_time + sec2mono(1) < mdispatch_clock && tvhlog_limit(&st->es_cc_log, 10)) tvhwarn("TS", "%s Continuity counter error (total %zi)", service_component_nicename(st), st->es_cc_log.count); @@ -141,7 +141,7 @@ ts_recv_skipped0 cc = tsb2[3] & 0xf; if(st->es_cc != -1 && cc != st->es_cc) { /* Let the hardware to stabilize and don't flood the log */ - if (t->s_start_time + mono4sec(1) < mdispatch_clock && + if (t->s_start_time + sec2mono(1) < mdispatch_clock && tvhlog_limit(&st->es_cc_log, 10)) tvhwarn("TS", "%s Continuity counter error (total %zi)", service_component_nicename(st), st->es_cc_log.count); @@ -356,7 +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(sec4mono(mdispatch_clock) == sec4mono(t->s_tsbuf_last) && + if(mono2sec(mdispatch_clock) == mono2sec(t->s_tsbuf_last) && sb->sb_ptr < TS_REMUX_BUFSIZE) return; @@ -379,7 +379,7 @@ ts_skip(mpegts_service_t *t, const uint8_t *src, int len) sb->sb_err += len / 188; - if(sec4mono(mdispatch_clock) == sec4mono(t->s_tsbuf_last) && + if(mono2sec(mdispatch_clock) == mono2sec(t->s_tsbuf_last) && sb->sb_err < (TS_REMUX_BUFSIZE / 188)) return; diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun.c index fdec56d6d..cdbb2358f 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun.c @@ -379,7 +379,7 @@ tvhdhomerun_device_discovery_thread( void *aux ) if (tvheadend_running) { brk = tvh_cond_timedwait(&tvhdhomerun_discovery_cond, &tvhdhomerun_discovery_lock, - mdispatch_clock + mono4sec(15)); + mdispatch_clock + sec2mono(15)); brk = !ERRNO_AGAIN(brk) && brk != ETIMEDOUT; } pthread_mutex_unlock(&tvhdhomerun_discovery_lock); diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c index fb308df76..48459eb89 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c @@ -229,7 +229,7 @@ tvhdhomerun_frontend_monitor_cb( void *aux ) /* re-arm */ mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, - hfe, mono4sec(1)); + hfe, sec2mono(1)); /* Get current status */ pthread_mutex_lock(&hfe->hf_hdhomerun_device_mutex); @@ -268,7 +268,7 @@ tvhdhomerun_frontend_monitor_cb( void *aux ) ((dvb_mux_t *)mm)->lm_tuning.dmc_fe_delsys); } else { // quick re-arm the timer to wait for signal lock - mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, mono4ms(50)); + mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, ms2mono(50)); } } @@ -420,7 +420,7 @@ static int tvhdhomerun_frontend_tune(tvhdhomerun_frontend_t *hfe, mpegts_mux_ins hfe->hf_status = SIGNAL_NONE; /* start the monitoring */ - mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, mono4ms(50)); + mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, ms2mono(50)); hfe->hf_ready = 1; return 0; @@ -477,7 +477,7 @@ tvhdhomerun_frontend_stop_mux hfe->hf_status = 0; hfe->hf_ready = 0; - mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, mono4sec(2)); + mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, sec2mono(2)); } static void tvhdhomerun_frontend_update_pids( mpegts_input_t *mi, mpegts_mux_t *mm ) diff --git a/src/main.c b/src/main.c index b40dccb58..4e84701f7 100644 --- a/src/main.c +++ b/src/main.c @@ -548,7 +548,7 @@ mtimer_thread(void *aux) /* Global monoclock timers */ pthread_mutex_lock(&global_lock); - next = now + mono4sec(3600); + next = now + sec2mono(3600); while((mti = LIST_FIRST(&mtimers)) != NULL) { diff --git a/src/muxer/muxer_mkv.c b/src/muxer/muxer_mkv.c index 3ab11c189..89221c734 100644 --- a/src/muxer/muxer_mkv.c +++ b/src/muxer/muxer_mkv.c @@ -992,12 +992,12 @@ mk_write_frame_i(mk_muxer_t *mk, mk_track_t *t, th_pkt_t *pkt) if(vkeyframe && mk->cluster && (mk->cluster->hq_size > mk->cluster_maxsize || - mk->cluster_last_close + mono4sec(1) < mdispatch_clock)) + mk->cluster_last_close + sec2mono(1) < mdispatch_clock)) mk_close_cluster(mk); else if(!mk->has_video && mk->cluster && (mk->cluster->hq_size > clusersizemax/40 || - mk->cluster_last_close + mono4sec(1) < mdispatch_clock)) + mk->cluster_last_close + sec2mono(1) < mdispatch_clock)) mk_close_cluster(mk); else if(mk->cluster && mk->cluster->hq_size > clusersizemax) diff --git a/src/parsers/parser_h264.c b/src/parsers/parser_h264.c index cc5936e9d..bd7986e7c 100644 --- a/src/parsers/parser_h264.c +++ b/src/parsers/parser_h264.c @@ -427,7 +427,7 @@ h264_decode_slice_header(elementary_stream_t *st, bitstream_t *bs, int *pkttype, d = 0; if (sps->time_scale) d = 180000 * (uint64_t)sps->units_in_tick / (uint64_t)sps->time_scale; - if (d == 0 && st->es_frame_duration < 2 && p->start + mono4sec(4) < mdispatch_clock) { + if (d == 0 && st->es_frame_duration < 2 && p->start + sec2mono(4) < mdispatch_clock) { tvhwarn("parser", "H264 stream has not timing information, using 30fps"); d = 3000; /* 90000/30 = 3000 : 30fps */ } diff --git a/src/satip/rtp.c b/src/satip/rtp.c index 9173165de..8d6a0078d 100644 --- a/src/satip/rtp.c +++ b/src/satip/rtp.c @@ -140,7 +140,7 @@ static void satip_rtp_header(satip_rtp_session_t *rtp, struct iovec *v, uint32_t off) { uint8_t *data = v->iov_base; - uint32_t tstamp = sec4mono(mdispatch_clock) + rtp->seq; + uint32_t tstamp = mono2sec(mdispatch_clock) + rtp->seq; rtp->seq++; diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index 05a08c3c7..87d2bad11 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -220,7 +220,7 @@ rtsp_rearm_session_timer(session_t *rs) { if (!rs->shutdown_on_close) { pthread_mutex_lock(&global_lock); - mtimer_arm_rel(&rs->timer, rtsp_session_timer_cb, rs, mono4sec(RTSP_TIMEOUT)); + mtimer_arm_rel(&rs->timer, rtsp_session_timer_cb, rs, sec2mono(RTSP_TIMEOUT)); pthread_mutex_unlock(&global_lock); } } diff --git a/src/service.c b/src/service.c index 5887eebbd..cd06f3cb3 100644 --- a/src/service.c +++ b/src/service.c @@ -678,7 +678,7 @@ service_start(service_t *t, int instance, int weight, int flags, t->s_grace_delay = stimeout; if (stimeout > 0) mtimer_arm_rel(&t->s_receive_timer, service_data_timeout, t, - mono4sec(stimeout)); + sec2mono(stimeout)); return 0; } @@ -1137,7 +1137,7 @@ service_data_timeout(void *aux) if (t->s_timeout > 0) mtimer_arm_rel(&t->s_receive_timer, service_data_timeout, t, - mono4sec(t->s_timeout)); + sec2mono(t->s_timeout)); } /** diff --git a/src/spawn.c b/src/spawn.c index 2cab4c841..4c293c61d 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -326,7 +326,7 @@ spawn_kill(pid_t pid, int sig, int timeout) break; if (s) { if (!s->killed) - s->killed = mdispatch_clock_update() + mono4sec(MINMAX(timeout, 5, 3600)); + s->killed = mdispatch_clock_update() + sec2mono(MINMAX(timeout, 5, 3600)); /* kill the whole process group */ r = kill(-pid, sig); if (r < 0) diff --git a/src/subscriptions.c b/src/subscriptions.c index b1cec282c..778faa2e0 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -286,7 +286,7 @@ subscription_start_instance &s->ths_instances, error, s->ths_weight, s->ths_flags, s->ths_timeout, mdispatch_clock > s->ths_postpone_end ? - 0 : sec4mono(s->ths_postpone_end - mdispatch_clock)); + 0 : mono2sec(s->ths_postpone_end - mdispatch_clock)); return s->ths_current_instance = si; } @@ -314,7 +314,7 @@ subscription_reschedule(void) /* Postpone the tuner decision */ /* Leave some time to wakeup tuners through DBus or so */ if (s->ths_postpone_end > mdispatch_clock) { - postpone2 = sec4mono(s->ths_postpone_end - mdispatch_clock); + postpone2 = mono2sec(s->ths_postpone_end - mdispatch_clock); if (postpone > postpone2) postpone = postpone2; sm = streaming_msg_create_code(SMT_GRACE, postpone + 5); @@ -354,7 +354,7 @@ subscription_reschedule(void) s->ths_current_instance = si; if(si == NULL) { - if (s->ths_last_error != error || s->ths_last_find + mono4sec(2) >= mdispatch_clock) { + if (s->ths_last_error != error || s->ths_last_find + sec2mono(2) >= mdispatch_clock) { tvhtrace("subscription", "%04X: instance not available, retrying", shortid(s)); if (s->ths_last_error != error) s->ths_last_find = mdispatch_clock; @@ -392,7 +392,7 @@ subscription_reschedule(void) if (postpone <= 0 || postpone == INT_MAX) postpone = 2; mtimer_arm_rel(&subscription_reschedule_timer, - subscription_reschedule_cb, NULL, mono4sec(postpone)); + subscription_reschedule_cb, NULL, sec2mono(postpone)); reenter = 0; } @@ -421,7 +421,7 @@ subscription_set_postpone(void *aux, const char *path, int64_t postpone) return -1; /* some limits that make sense */ postpone = MINMAX(postpone, 0, 120); - postpone2 = mono4sec(postpone); + postpone2 = sec2mono(postpone); pthread_mutex_lock(&global_lock); if (subscription_postpone != postpone) { subscription_postpone = postpone; @@ -706,7 +706,7 @@ subscription_create s->ths_flags = flags; s->ths_timeout = pro ? pro->pro_timeout : 0; s->ths_postpone = subscription_postpone; - s->ths_postpone_end = mdispatch_clock + mono4sec(s->ths_postpone); + s->ths_postpone_end = mdispatch_clock + sec2mono(s->ths_postpone); if (s->ths_prch) s->ths_weight = profile_chain_weight(s->ths_prch, weight); @@ -966,7 +966,7 @@ subscription_status_callback ( void *p ) static int64_t old_count = -1; mtimer_arm_rel(&subscription_status_timer, - subscription_status_callback, NULL, mono4sec(1)); + subscription_status_callback, NULL, sec2mono(1)); LIST_FOREACH(s, &subscriptions, ths_global_link) { /* Store the difference between total bytes from the last round */ @@ -1150,7 +1150,7 @@ subscription_dummy_join(const char *id, int first) th_subscription_t *s; if(first) { - mtimer_arm_rel(&dummy_sub_timer, dummy_retry, strdup(id), mono4sec(2)); + mtimer_arm_rel(&dummy_sub_timer, dummy_retry, strdup(id), sec2mono(2)); return; } @@ -1158,7 +1158,7 @@ subscription_dummy_join(const char *id, int first) tvhlog(LOG_ERR, "subscription", "Unable to dummy join %s, service not found, retrying...", id); - mtimer_arm_rel(&dummy_sub_timer, dummy_retry, strdup(id), mono4sec(1)); + mtimer_arm_rel(&dummy_sub_timer, dummy_retry, strdup(id), sec2mono(1)); return; } diff --git a/src/tcp.c b/src/tcp.c index 0235b2462..bdb8e3808 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -539,7 +539,7 @@ try_again: c2 = aa->aa_conn_limit_streaming ? used >= aa->aa_conn_limit_streaming : -1; if (c1 && c2) { - if (started + mono4sec(3) < mdispatch_clock) { + if (started + sec2mono(3) < mdispatch_clock) { tvherror("tcp", "multiple connections are not allowed for user '%s' from '%s' " "(limit %u, streaming limit %u, active streaming %u, DVR %u)", aa->aa_username ?: "", aa->aa_representative ?: "", @@ -1114,7 +1114,7 @@ tcp_server_done(void) t = getfastmonoclock(); while (LIST_FIRST(&tcp_server_active) != NULL) { - if (t + mono4sec(5) < getfastmonoclock()) + if (t + sec2mono(5) < getfastmonoclock()) tvhtrace("tcp", "tcp server %p active too long", LIST_FIRST(&tcp_server_active)); usleep(20000); } diff --git a/src/timeshift/timeshift_filemgr.c b/src/timeshift/timeshift_filemgr.c index 57d4b9964..985854044 100644 --- a/src/timeshift/timeshift_filemgr.c +++ b/src/timeshift/timeshift_filemgr.c @@ -239,7 +239,7 @@ static timeshift_file_t * timeshift_filemgr_file_init timeshift_file_t *tsf; tsf = calloc(1, sizeof(timeshift_file_t)); - tsf->time = sec4mono(start_time) / TIMESHIFT_FILE_PERIOD; + tsf->time = mono2sec(start_time) / TIMESHIFT_FILE_PERIOD; tsf->last = start_time; tsf->wfd = -1; tsf->rfd = -1; @@ -272,7 +272,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) /* Store to file */ tsf_tl = TAILQ_LAST(&ts->files, timeshift_file_list); - time = sec4mono(start_time) / TIMESHIFT_FILE_PERIOD; + time = mono2sec(start_time) / TIMESHIFT_FILE_PERIOD; if (!tsf_tl || tsf_tl->time < time || (tsf_tl->ram && tsf_tl->woff >= timeshift_conf.ram_segment_size)) { tsf_hd = TAILQ_FIRST(&ts->files); diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index 31ee524e5..ca9663a25 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -281,7 +281,7 @@ static int _timeshift_skip { timeshift_index_iframe_t *tsi = seek->frame; timeshift_file_t *tsf = seek->file, *tsf_last; - int64_t sec = sec4mono(req_time) / TIMESHIFT_FILE_PERIOD; + int64_t sec = mono2sec(req_time) / TIMESHIFT_FILE_PERIOD; int back = (req_time < cur_time) ? 1 : 0; int end = 0; @@ -773,7 +773,7 @@ void *timeshift_reader ( void *p ) /* Done */ if (!run || !seek->file || ((ts->state != TS_PLAY && !skip))) { - if (mono_now >= (mono_last_status + mono4sec(1))) { + if (mono_now >= (mono_last_status + sec2mono(1))) { timeshift_status(ts, last_time); mono_last_status = mono_now; } @@ -865,7 +865,7 @@ void *timeshift_reader ( void *p ) } /* Periodic timeshift status */ - if (mono_now >= (mono_last_status + mono4sec(1))) { + if (mono_now >= (mono_last_status + sec2mono(1))) { timeshift_status(ts, last_time); mono_last_status = mono_now; } diff --git a/src/webui/comet.c b/src/webui/comet.c index 3f7ed2191..176754dc9 100644 --- a/src/webui/comet.c +++ b/src/webui/comet.c @@ -95,7 +95,7 @@ comet_flush(void) for(cmb = LIST_FIRST(&mailboxes); cmb != NULL; cmb = next) { next = LIST_NEXT(cmb, cmb_link); - if(cmb->cmb_last_used && cmb->cmb_last_used + mono4sec(60) < mdispatch_clock) + if(cmb->cmb_last_used && cmb->cmb_last_used + sec2mono(60) < mdispatch_clock) cmb_destroy(cmb); } pthread_mutex_unlock(&comet_mutex); @@ -264,7 +264,7 @@ comet_mailbox_poll(http_connection_t *hc, const char *remain, void *opaque) cmb->cmb_last_used = 0; /* Make sure we're not flushed out */ if(!im && cmb->cmb_messages == NULL) { - mono = mdispatch_clock + mono4sec(10); + mono = mdispatch_clock + sec2mono(10); do { e = tvh_cond_timedwait(&comet_cond, &comet_mutex, mono); if (e == ETIMEDOUT) diff --git a/src/webui/webui.c b/src/webui/webui.c index f07c3817d..49b493865 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -342,7 +342,7 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, pthread_mutex_lock(&sq->sq_mutex); sm = TAILQ_FIRST(&sq->sq_queue); if(sm == NULL) { - mono = mdispatch_clock + mono4sec(1); + mono = mdispatch_clock + sec2mono(1); do { r = tvh_cond_timedwait(&sq->sq_cond, &sq->sq_mutex, mono); if (r == ETIMEDOUT) { @@ -350,8 +350,8 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, if (tcp_socket_dead(hc->hc_fd)) { tvhlog(LOG_DEBUG, "webui", "Stop streaming %s, client hung up", hc->hc_url_orig); run = 0; - } else if((!started && mdispatch_clock - lastpkt > mono4sec(grace)) || - (started && ptimeout > 0 && mdispatch_clock - lastpkt > mono4sec(ptimeout))) { + } else if((!started && mdispatch_clock - lastpkt > sec2mono(grace)) || + (started && ptimeout > 0 && mdispatch_clock - lastpkt > sec2mono(ptimeout))) { tvhlog(LOG_WARNING, "webui", "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig); run = 0; } @@ -396,7 +396,7 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, if (hc->hc_no_output) { streaming_msg_free(sm); - mono = getfastmonoclock() + mono4sec(2); + mono = getfastmonoclock() + sec2mono(2); while (getfastmonoclock() < mono) { if (tcp_socket_dead(hc->hc_fd)) break; @@ -429,8 +429,8 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, tvhlog(LOG_DEBUG, "webui", "Stop streaming %s, client hung up", hc->hc_url_orig); run = 0; - } else if((!started && mdispatch_clock - lastpkt > mono4sec(grace)) || - (started && ptimeout > 0 && mdispatch_clock - lastpkt > mono4sec(ptimeout))) { + } else if((!started && mdispatch_clock - lastpkt > sec2mono(grace)) || + (started && ptimeout > 0 && mdispatch_clock - lastpkt > sec2mono(ptimeout))) { tvhlog(LOG_WARNING, "webui", "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig); run = 0; } diff --git a/src/wrappers.c b/src/wrappers.c index 596ad681e..f08c28e13 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -78,7 +78,7 @@ tvh_pipe_close(th_pipe_t *p) int tvh_write(int fd, const void *buf, size_t len) { - int64_t limit = mdispatch_clock + mono4sec(25); + int64_t limit = mdispatch_clock + sec2mono(25); ssize_t c; while (len) {