summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-09-21 19:25:34 +0200
committerAlfred E. Heggestad <aeh@db.org>2014-09-21 19:25:34 +0200
commitd0ae75c37e100f39013d9bf9aff2a36ee22ca12d (patch)
tree5d7559d64c4464143e7ee78b8b249a9f2af07757
parent8f04c0368a665039b11238673eb375201f54b013 (diff)
metric: add metric_init()
- metric_init calls tmr_start(). tmr_start must be called from the re_main() thread.
-rw-r--r--src/core.h1
-rw-r--r--src/metric.c13
-rw-r--r--src/stream.c3
3 files changed, 16 insertions, 1 deletions
diff --git a/src/core.h b/src/core.h
index ea2dc37..f8c21ac 100644
--- a/src/core.h
+++ b/src/core.h
@@ -226,6 +226,7 @@ struct metric {
uint32_t n_bytes_last;
};
+void metric_init(struct metric *metric);
void metric_reset(struct metric *metric);
void metric_add_packet(struct metric *metric, size_t packetsize);
uint32_t metric_avg_bitrate(const struct metric *metric);
diff --git a/src/metric.c b/src/metric.c
index f509805..f3e8d06 100644
--- a/src/metric.c
+++ b/src/metric.c
@@ -17,6 +17,9 @@ static void tmr_handler(void *arg)
tmr_start(&metric->tmr, TMR_INTERVAL * 1000, tmr_handler, metric);
+ if (!metric->started)
+ return;
+
if (now <= metric->ts_last)
return;
@@ -38,12 +41,20 @@ static void metric_start(struct metric *metric)
return;
metric->ts_start = tmr_jiffies();
- tmr_start(&metric->tmr, 1, tmr_handler, metric);
metric->started = true;
}
+void metric_init(struct metric *metric)
+{
+ if (!metric)
+ return;
+
+ tmr_start(&metric->tmr, 100, tmr_handler, metric);
+}
+
+
void metric_reset(struct metric *metric)
{
if (!metric)
diff --git a/src/stream.c b/src/stream.c
index e9cf871..07f51bd 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -310,6 +310,9 @@ int stream_alloc(struct stream **sp, const struct config_avt *cfg,
s->pt_enc = -1;
+ metric_init(&s->metric_tx);
+ metric_init(&s->metric_rx);
+
list_append(call_streaml(call), &s->le, s);
out: