mirror of https://github.com/ericonr/sndio.git
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.
This commit is contained in:
parent
de7dc61de4
commit
1949c506b8
|
@ -1045,34 +1045,20 @@ mix_setmaster(struct aproc *p)
|
|||
struct abuf *i, *j;
|
||||
int weight;
|
||||
|
||||
if (!p->u.mix.autovol)
|
||||
return;
|
||||
|
||||
LIST_FOREACH(i, &p->ins, ient) {
|
||||
weight = ADATA_UNIT;
|
||||
if (p->u.mix.autovol) {
|
||||
/*
|
||||
* 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
|
||||
* count the number of inputs that have
|
||||
* overlapping channel sets
|
||||
*/
|
||||
n = 0;
|
||||
LIST_FOREACH(i, &p->ins, ient) {
|
||||
j = LIST_NEXT(i, ient);
|
||||
for (;;) {
|
||||
if (j == NULL) {
|
||||
LIST_FOREACH(j, &p->ins, ient) {
|
||||
if (i->cmin <= j->cmax && i->cmax >= j->cmin)
|
||||
n++;
|
||||
break;
|
||||
}
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue