=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sndiod/dev.c,v retrieving revision 1.62 retrieving revision 1.63 diff -c -r1.62 -r1.63 *** src/usr.bin/sndiod/dev.c 2019/09/21 04:42:46 1.62 --- src/usr.bin/sndiod/dev.c 2020/01/10 19:01:55 1.63 *************** *** 1,4 **** ! /* $OpenBSD: dev.c,v 1.62 2019/09/21 04:42:46 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * --- 1,4 ---- ! /* $OpenBSD: dev.c,v 1.63 2020/01/10 19:01:55 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * *************** *** 1501,1506 **** --- 1501,1507 ---- void slot_initconv(struct slot *s) { + unsigned int dev_nch; struct dev *d = s->dev; if (s->mode & MODE_PLAY) { *************** *** 1518,1534 **** } 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) { cmap_init(&s->sub.cmap, ! 0, ((s->mode & MODE_MON) ? d->pchan : d->rchan) - 1, s->opt->rmin, s->opt->rmax, s->opt->rmin, s->opt->rmin + s->sub.nch - 1, s->opt->rmin, s->opt->rmin + s->sub.nch - 1); --- 1519,1541 ---- } s->mix.join = 1; s->mix.expand = 1; ! if (s->opt->dup && s->mix.cmap.nch > 0) { ! dev_nch = d->pchan < (s->opt->pmax + 1) ? ! d->pchan - s->opt->pmin : ! s->opt->pmax - s->opt->pmin + 1; ! if (dev_nch > s->mix.nch) ! s->mix.expand = dev_nch / s->mix.nch; ! else if (s->mix.nch > dev_nch) ! s->mix.join = s->mix.nch / dev_nch; } } if (s->mode & MODE_RECMASK) { + unsigned int outchan = (s->mode & MODE_MON) ? + d->pchan : d->rchan; + cmap_init(&s->sub.cmap, ! 0, outchan - 1, s->opt->rmin, s->opt->rmax, s->opt->rmin, s->opt->rmin + s->sub.nch - 1, s->opt->rmin, s->opt->rmin + s->sub.nch - 1); *************** *** 1541,1551 **** } 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; } /* --- 1548,1561 ---- } s->sub.join = 1; s->sub.expand = 1; ! if (s->opt->dup && s->sub.cmap.nch > 0) { ! dev_nch = outchan < (s->opt->rmax + 1) ? ! outchan - s->opt->rmin : ! s->opt->rmax - s->opt->rmin + 1; ! if (dev_nch > s->sub.nch) ! s->sub.join = dev_nch / s->sub.nch; ! else if (s->sub.nch > dev_nch) ! s->sub.expand = s->sub.nch / dev_nch; } /*