From 1949c506b8afcdb7f60d9be0fb62c640bd7c0251 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Tue, 10 Jan 2012 09:12:00 +0100 Subject: [PATCH] Fix the way the mixer figures out which groups of streams have common channels and thus need to share their dynamic range. Fixes, unnecessarily decreased volume in some theoretical cases. --- aucat/aproc.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/aucat/aproc.c b/aucat/aproc.c index 9014032..ef8c7f5 100644 --- a/aucat/aproc.c +++ b/aucat/aproc.c @@ -1045,34 +1045,20 @@ mix_setmaster(struct aproc *p) struct abuf *i, *j; int weight; - if (!p->u.mix.autovol) - return; - - /* - * count the number of inputs. If a set of inputs - * uses channels that have no intersection, they are - * counted only once because they don't need to - * share their volume - * - * XXX: this is wrong, this is not optimal if we have two - * buckets of N and N' clients, in which case we should - * get 1/N and 1/N' respectively - */ - n = 0; LIST_FOREACH(i, &p->ins, ient) { - j = LIST_NEXT(i, ient); - for (;;) { - if (j == NULL) { - n++; - break; + weight = ADATA_UNIT; + if (p->u.mix.autovol) { + /* + * count the number of inputs that have + * overlapping channel sets + */ + n = 0; + LIST_FOREACH(j, &p->ins, ient) { + if (i->cmin <= j->cmax && i->cmax >= j->cmin) + n++; } - if (i->cmin > j->cmax || i->cmax < j->cmin) - break; - j = LIST_NEXT(j, ient); + weight /= n; } - } - LIST_FOREACH(i, &p->ins, ient) { - weight = ADATA_UNIT / n; if (weight > i->r.mix.maxweight) weight = i->r.mix.maxweight; i->r.mix.weight = weight;