summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2009-11-15 21:44:09 +0000
committerratchov <ratchov@openbsd.org>2009-11-15 21:44:09 +0000
commit7ffbca6712c39d62dffcb870c3160e93a72698ea (patch)
tree4dddcc17700c1cbf7d36081bb89167aee9ba1313
parentvether(4) interfaces can be created too; ok deraadt (diff)
downloadwireguard-openbsd-7ffbca6712c39d62dffcb870c3160e93a72698ea.tar.xz
wireguard-openbsd-7ffbca6712c39d62dffcb870c3160e93a72698ea.zip
If two (or more) inputs use channel ranges having no intersection,
then don't reduce their dynamic range to ``share the volume''.
-rw-r--r--usr.bin/aucat/aproc.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c
index f5d7375ff07..0f1e6f5b7e9 100644
--- a/usr.bin/aucat/aproc.c
+++ b/usr.bin/aucat/aproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aproc.c,v 1.39 2009/11/05 08:36:48 ratchov Exp $ */
+/* $OpenBSD: aproc.c,v 1.40 2009/11/15 21:44:09 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -625,18 +625,33 @@ void
mix_setmaster(struct aproc *p)
{
unsigned n;
- struct abuf *buf;
+ struct abuf *i, *j;
int weight;
+ /*
+ * 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
+ */
n = 0;
- LIST_FOREACH(buf, &p->ibuflist, ient) {
- n++;
+ LIST_FOREACH(i, &p->ibuflist, ient) {
+ j = LIST_NEXT(i, ient);
+ for (;;) {
+ if (j == NULL) {
+ n++;
+ break;
+ }
+ if (i->cmin > j->cmax || i->cmax < j->cmin)
+ break;
+ j = LIST_NEXT(j, ient);
+ }
}
- LIST_FOREACH(buf, &p->ibuflist, ient) {
+ LIST_FOREACH(i, &p->ibuflist, ient) {
weight = ADATA_UNIT / n;
- if (weight > buf->r.mix.maxweight)
- weight = buf->r.mix.maxweight;
- buf->r.mix.weight = weight;
+ if (weight > i->r.mix.maxweight)
+ weight = i->r.mix.maxweight;
+ i->r.mix.weight = weight;
}
}