diff options
author | 2019-09-19 05:10:19 +0000 | |
---|---|---|
committer | 2019-09-19 05:10:19 +0000 | |
commit | 25479e21008cbf1172b78e843e88383ed105994c (patch) | |
tree | 2a6950e34d6d0d0570509c3c6235e4a12339d335 | |
parent | Move device slot convertions setup in its own routine. (diff) | |
download | wireguard-openbsd-25479e21008cbf1172b78e843e88383ed105994c.tar.xz wireguard-openbsd-25479e21008cbf1172b78e843e88383ed105994c.zip |
Don't attempt to join/expand nonexistent channels.
If the (hardware) device has fewer channels than the exposed
sub-device, then join/expand only to channels that exist on the
device.
-rw-r--r-- | usr.bin/sndiod/dev.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index e1745cfb7f4..7fe63983083 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.60 2019/09/19 05:04:34 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.61 2019/09/19 05:10:19 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -1432,19 +1432,9 @@ dev_mmcloc(struct dev *d, unsigned int origin) void slot_initconv(struct slot *s) { - unsigned int dev_nch; struct dev *d = s->dev; if (s->mode & MODE_PLAY) { - dev_nch = s->opt->pmax - s->opt->pmin + 1; - s->mix.join = 1; - s->mix.expand = 1; - if (s->opt->dup) { - if (dev_nch > s->mix.nch) - s->mix.expand = dev_nch / s->mix.nch; - else if (dev_nch < s->mix.nch) - s->mix.join = s->mix.nch / dev_nch; - } cmap_init(&s->mix.cmap, s->opt->pmin, s->opt->pmin + s->mix.nch - 1, s->opt->pmin, s->opt->pmin + s->mix.nch - 1, @@ -1457,18 +1447,17 @@ slot_initconv(struct slot *s) resamp_init(&s->mix.resamp, s->round, d->round, s->mix.nch); } + s->mix.join = 1; + s->mix.expand = 1; + if (s->opt->dup) { + if (s->mix.cmap.nch > s->mix.nch) + s->mix.expand = s->mix.cmap.nch / s->mix.nch; + else if (s->mix.cmap.nch > 0) + s->mix.join = s->mix.nch / s->mix.cmap.nch; + } } if (s->mode & MODE_RECMASK) { - dev_nch = s->opt->rmax - s->opt->rmin + 1; - s->sub.join = 1; - s->sub.expand = 1; - if (s->opt->dup) { - if (dev_nch > s->sub.nch) - s->sub.join = dev_nch / s->sub.nch; - else if (dev_nch < s->sub.nch) - s->sub.expand = s->sub.nch / dev_nch; - } cmap_init(&s->sub.cmap, 0, ((s->mode & MODE_MON) ? d->pchan : d->rchan) - 1, s->opt->rmin, s->opt->rmax, @@ -1481,6 +1470,14 @@ slot_initconv(struct slot *s) if (!aparams_native(&s->par)) { enc_init(&s->sub.enc, &s->par, s->sub.nch); } + s->sub.join = 1; + s->sub.expand = 1; + if (s->opt->dup) { + if (s->sub.cmap.nch > s->sub.nch) + s->sub.join = s->sub.cmap.nch / s->sub.nch; + else if (s->sub.cmap.nch > 0) + s->sub.expand = s->sub.nch / s->sub.cmap.nch; + } /* * cmap_copy() doesn't write samples in all channels, |