From 1c59bb6d6034880b7e372516b2b8c5deac84df61 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 20 Aug 2018 18:29:52 +0200 Subject: [PATCH] hooks: adapt to new signal code and separate node-type configuration into in/out sections --- lib/hooks/print.c | 26 ++++++++++++++++++++------ lib/hooks/scale.c | 8 ++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/hooks/print.c b/lib/hooks/print.c index 53e582fd8..9856fbef8 100644 --- a/lib/hooks/print.c +++ b/lib/hooks/print.c @@ -56,7 +56,22 @@ static int print_start(struct hook *h) struct print *p = (struct print *) h->_vd; int ret; - ret = io_init(&p->io, p->format, h->node, SAMPLE_HAS_ALL); + struct list *signals; + + if (h->node) + signals = &h->node->signals; + else if (h->path) + signals = &h->path->signals; + else + signals = NULL; + + ret = signals + ? io_init(&p->io, p->format, signals, SAMPLE_HAS_ALL) + : io_init_auto(&p->io, p->format, DEFAULT_SAMPLE_LENGTH, SAMPLE_HAS_ALL); + if (ret) + return ret; + + ret = io_check(&p->io); if (ret) return ret; @@ -76,6 +91,10 @@ static int print_stop(struct hook *h) if (ret) return ret; + ret = io_destroy(&p->io); + if (ret) + return ret; + return 0; } @@ -127,7 +146,6 @@ static int print_process(struct hook *h, struct sample *smps[], unsigned *cnt) static int print_destroy(struct hook *h) { - int ret; struct print *p = (struct print *) h->_vd; if (p->uri) @@ -136,10 +154,6 @@ static int print_destroy(struct hook *h) if (p->prefix) free(p->prefix); - ret = io_destroy(&p->io); - if (ret) - return ret; - return 0; } diff --git a/lib/hooks/scale.c b/lib/hooks/scale.c index 15c51ca26..9c0eba027 100644 --- a/lib/hooks/scale.c +++ b/lib/hooks/scale.c @@ -70,19 +70,19 @@ static int scale_process(struct hook *h, struct sample *smps[], unsigned *cnt) for (int k = 0; k < smps[i]->length; k++) { switch (sample_format(smps[i], k)) { - case SIGNAL_FORMAT_INTEGER: + case SIGNAL_TYPE_INTEGER: smps[i]->data[k].i = smps[i]->data[k].i * p->scale + p->offset; break; - case SIGNAL_FORMAT_FLOAT: + case SIGNAL_TYPE_FLOAT: smps[i]->data[k].f = smps[i]->data[k].f * p->scale + p->offset; break; - case SIGNAL_FORMAT_COMPLEX: + case SIGNAL_TYPE_COMPLEX: smps[i]->data[k].z = smps[i]->data[k].z * p->scale + p->offset; break; - case SIGNAL_FORMAT_BOOLEAN: + case SIGNAL_TYPE_BOOLEAN: smps[i]->data[k].b = smps[i]->data[k].b * p->scale + p->offset; break;