From 003650eb217c7eddd32a93bd5739659f1e110cfc Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 23 Sep 2017 23:57:19 -0600 Subject: [PATCH] change behaviour of mux feautre: send sample containing all values by default --- lib/path.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/path.c b/lib/path.c index 0d13cee0a..59ff8fce6 100644 --- a/lib/path.c +++ b/lib/path.c @@ -296,8 +296,11 @@ int path_init2(struct path *p) for (size_t i = 0; i < list_length(&ps->mappings); i++) { struct mapping_entry *me = list_at(&ps->mappings, i); - if (me->offset + me->length > p->samplelen) - p->samplelen = me->offset + me->length; + int len = me->length; + int off = me->offset; + + if (off + len > p->samplelen) + p->samplelen = off + len; } } @@ -308,7 +311,9 @@ int path_init2(struct path *p) if (ret) return ret; - sample_alloc(&p->pool, &p->last_sample, 1); + ret = sample_alloc(&p->pool, &p->last_sample, 1); + if (ret != 1) + return -1; /* Prepare poll() */ p->reader.nfds = list_length(&p->sources); @@ -473,6 +478,27 @@ int path_start(struct path *p) p->sequence = 0; + /* We initialize the intial sample with zeros */ + for (size_t i = 0; i < list_length(&p->sources); i++) { + struct path_source *ps = list_at(&p->sources, i); + + for (size_t j = 0; j < list_length(&ps->mappings); j++) { + struct mapping_entry *me = list_at(&ps->mappings, j); + + int len = me->length; + int off = me->offset; + + if (len + off > p->last_sample->length) + p->last_sample->length = len + off; + + for (int k = off; k < off + len; k++) { + p->last_sample->data[k].f = 0; + + sample_set_data_format(p->last_sample, k, SAMPLE_DATA_FORMAT_FLOAT); + } + } + } + /* Start one thread per path for sending to destinations */ ret = pthread_create(&p->tid, NULL, &path_run, p); if (ret)