diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-04-17 09:16:58 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2010-04-17 09:16:58 +0000 |
commit | 5124941d566ebff0597ff6e5eaaa24cd2827f299 (patch) | |
tree | c2a4534ca7b01335b8360f42bd0a11c61a33141f /usr.bin | |
parent | d510d42043583658ed1ba220fb77b18a92137a06 (diff) |
Allow the mixer to handle inputs with channel ranges outside
the device channel range. This makes the channel mapping code
no longer usefuli, so remove it. No behaviour change.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/aucat/aproc.c | 183 | ||||
-rw-r--r-- | usr.bin/aucat/aproc.h | 6 | ||||
-rw-r--r-- | usr.bin/aucat/dev.c | 26 |
3 files changed, 30 insertions, 185 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index b1001f2ab65..2af5ed50c3c 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.51 2010/04/06 20:07:01 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.52 2010/04/17 09:16:57 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -608,7 +608,8 @@ unsigned mix_badd(struct abuf *ibuf, struct abuf *obuf) { short *idata, *odata; - unsigned i, j, icnt, onext, ostart; + unsigned cmin, cmax; + unsigned i, j, cc, istart, inext, onext, ostart; unsigned scount, icount, ocount; int vol; @@ -652,18 +653,24 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf) return 0; vol = (ibuf->r.mix.weight * ibuf->r.mix.vol) >> ADATA_SHIFT; - ostart = ibuf->cmin - obuf->cmin; - onext = obuf->cmax - ibuf->cmax + ostart; - icnt = ibuf->cmax - ibuf->cmin + 1; + cmin = obuf->cmin > ibuf->cmin ? obuf->cmin : ibuf->cmin; + cmax = obuf->cmax < ibuf->cmax ? obuf->cmax : ibuf->cmax; + ostart = cmin - obuf->cmin; + istart = cmin - ibuf->cmin; + onext = obuf->cmax - cmax + ostart; + inext = ibuf->cmax - cmax + istart; + cc = cmax - cmin + 1; odata += ostart; + idata += istart; scount = (icount < ocount) ? icount : ocount; for (i = scount; i > 0; i--) { - for (j = icnt; j > 0; j--) { + for (j = cc; j > 0; j--) { *odata += (*idata * vol) >> ADATA_SHIFT; idata++; odata++; } odata += onext; + idata += inext; } abuf_rdiscard(ibuf, scount); ibuf->r.mix.done += scount; @@ -938,14 +945,6 @@ mix_hup(struct aproc *p, struct abuf *obuf) void mix_newin(struct aproc *p, struct abuf *ibuf) { -#ifdef DEBUG - struct abuf *obuf = LIST_FIRST(&p->obuflist); - - if (!obuf || ibuf->cmin < obuf->cmin || ibuf->cmax > obuf->cmax) { - dbg_puts("newin: channel ranges mismatch\n"); - dbg_panic(); - } -#endif p->u.mix.idle = 0; ibuf->r.mix.done = 0; ibuf->r.mix.vol = ADATA_UNIT; @@ -1157,7 +1156,8 @@ void sub_bcopy(struct abuf *ibuf, struct abuf *obuf) { short *idata, *odata; - unsigned i, j, ocnt, inext, istart; + unsigned cmin, cmax; + unsigned i, j, cc, istart, inext, onext, ostart; unsigned icount, ocount, scount; /* @@ -1177,17 +1177,25 @@ sub_bcopy(struct abuf *ibuf, struct abuf *obuf) odata = (short *)abuf_wgetblk(obuf, &ocount, 0); if (ocount == 0) return; - istart = obuf->cmin - ibuf->cmin; - inext = ibuf->cmax - obuf->cmax + istart; - ocnt = obuf->cmax - obuf->cmin + 1; - scount = (icount < ocount) ? icount : ocount; + cmin = obuf->cmin > ibuf->cmin ? obuf->cmin : ibuf->cmin; + cmax = obuf->cmax < ibuf->cmax ? obuf->cmax : ibuf->cmax; + ostart = cmin - obuf->cmin; + istart = cmin - ibuf->cmin; + onext = obuf->cmax - cmax; + inext = ibuf->cmax - cmax + istart; + cc = cmax - cmin + 1; idata += istart; + scount = (icount < ocount) ? icount : ocount; for (i = scount; i > 0; i--) { - for (j = ocnt; j > 0; j--) { + for (j = ostart; j > 0; j--) + *odata++ = 0x1111; + for (j = cc; j > 0; j--) { *odata = *idata; odata++; idata++; } + for (j = onext; j > 0; j--) + *odata++ = 0x2222; idata += inext; } abuf_wcommit(obuf, scount); @@ -1385,14 +1393,6 @@ sub_hup(struct aproc *p, struct abuf *obuf) void sub_newout(struct aproc *p, struct abuf *obuf) { -#ifdef DEBUG - struct abuf *ibuf = LIST_FIRST(&p->ibuflist); - - if (!ibuf || obuf->cmin < ibuf->cmin || obuf->cmax > ibuf->cmax) { - dbg_puts("newout: channel ranges mismatch\n"); - dbg_panic(); - } -#endif p->u.sub.idle = 0; obuf->w.sub.done = 0; obuf->w.sub.xrun = XRUN_IGNORE; @@ -1664,133 +1664,6 @@ resamp_new(char *name, unsigned iblksz, unsigned oblksz) * Convert one block. */ void -cmap_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) -{ - unsigned inch; - short *idata; - unsigned onch; - short *odata; - short *ctx, *ictx, *octx; - unsigned c, f, scount, icount, ocount; - - /* - * Calculate max frames readable at once from the input buffer. - */ - idata = (short *)abuf_rgetblk(ibuf, &icount, 0); - if (icount == 0) - return; - odata = (short *)abuf_wgetblk(obuf, &ocount, 0); - if (ocount == 0) - return; - scount = icount < ocount ? icount : ocount; - inch = ibuf->cmax - ibuf->cmin + 1; - onch = obuf->cmax - obuf->cmin + 1; - ictx = p->u.cmap.ctx + ibuf->cmin; - octx = p->u.cmap.ctx + obuf->cmin; - - for (f = scount; f > 0; f--) { - ctx = ictx; - for (c = inch; c > 0; c--) { - *ctx = *idata; - idata++; - ctx++; - } - ctx = octx; - for (c = onch; c > 0; c--) { - *odata = *ctx; - odata++; - ctx++; - } - } -#ifdef DEBUG - if (debug_level >= 4) { - aproc_dbg(p); - dbg_puts(": bcopy "); - dbg_putu(scount); - dbg_puts(" fr\n"); - } -#endif - abuf_rdiscard(ibuf, scount); - abuf_wcommit(obuf, scount); -} - -int -cmap_in(struct aproc *p, struct abuf *ibuf) -{ - struct abuf *obuf = LIST_FIRST(&p->obuflist); - - if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf)) - return 0; - cmap_bcopy(p, ibuf, obuf); - if (!abuf_flush(obuf)) - return 0; - return 1; -} - -int -cmap_out(struct aproc *p, struct abuf *obuf) -{ - struct abuf *ibuf = LIST_FIRST(&p->ibuflist); - - if (!abuf_fill(ibuf)) - return 0; - if (!ABUF_WOK(obuf) || !ABUF_ROK(ibuf)) - return 0; - cmap_bcopy(p, ibuf, obuf); - return 1; -} - -void -cmap_eof(struct aproc *p, struct abuf *ibuf) -{ - aproc_del(p); -} - -void -cmap_hup(struct aproc *p, struct abuf *obuf) -{ - aproc_del(p); -} - -struct aproc_ops cmap_ops = { - "cmap", - cmap_in, - cmap_out, - cmap_eof, - cmap_hup, - NULL, - NULL, - aproc_ipos, - aproc_opos, - NULL -}; - -struct aproc * -cmap_new(char *name, struct aparams *ipar, struct aparams *opar) -{ - struct aproc *p; - unsigned i; - - p = aproc_new(&cmap_ops, name); - for (i = 0; i < NCHAN_MAX; i++) - p->u.cmap.ctx[i] = 0; -#ifdef DEBUG - if (debug_level >= 3) { - aproc_dbg(p); - dbg_puts(": new "); - aparams_dbg(ipar); - dbg_puts(" -> "); - aparams_dbg(opar); - dbg_puts("\n"); - } -#endif - return p; -} - -/* - * Convert one block. - */ -void enc_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) { unsigned nch, scount, icount, ocount; diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h index 40eb26f7433..bbd157dd520 100644 --- a/usr.bin/aucat/aproc.h +++ b/usr.bin/aucat/aproc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.h,v 1.32 2010/04/06 20:07:01 ratchov Exp $ */ +/* $OpenBSD: aproc.h,v 1.33 2010/04/17 09:16:57 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -163,9 +163,6 @@ struct aproc { int idelta, odelta; /* remainder of resamp_xpos */ } resamp; struct { - short ctx[NCHAN_MAX]; - } cmap; - struct { int bfirst; /* bytes to skip at startup */ unsigned bps; /* bytes per sample */ unsigned shift; /* shift to get 32bit MSB */ @@ -243,7 +240,6 @@ struct aproc *wfile_new(struct file *); struct aproc *mix_new(char *, int, unsigned, struct aproc *); struct aproc *sub_new(char *, int, unsigned, struct aproc *); struct aproc *resamp_new(char *, unsigned, unsigned); -struct aproc *cmap_new(char *, struct aparams *, struct aparams *); struct aproc *enc_new(char *, struct aparams *); struct aproc *dec_new(char *, struct aparams *); struct aproc *mon_new(char *, unsigned); diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c index 1813b75bede..b30d3177874 100644 --- a/usr.bin/aucat/dev.c +++ b/usr.bin/aucat/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.46 2010/04/06 20:07:01 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.47 2010/04/17 09:16:57 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -683,14 +683,6 @@ dev_attach(char *name, unsigned mode, ibuf = abuf_new(nblk * round, &ipar); aproc_setout(conv, ibuf); } - if (!aparams_subset(&ipar, &dev_opar)) { - conv = cmap_new(name, &ipar, &dev_opar); - ipar.cmin = dev_opar.cmin; - ipar.cmax = dev_opar.cmax; - aproc_setin(conv, ibuf); - ibuf = abuf_new(nblk * round, &ipar); - aproc_setout(conv, ibuf); - } if (!aparams_eqrate(&ipar, &dev_opar)) { conv = resamp_new(name, round, dev_round); ipar.rate = dev_opar.rate; @@ -720,14 +712,6 @@ dev_attach(char *name, unsigned mode, obuf = abuf_new(nblk * round, &opar); aproc_setin(conv, obuf); } - if (!aparams_subset(&opar, &dev_ipar)) { - conv = cmap_new(name, &dev_ipar, &opar); - opar.cmin = dev_ipar.cmin; - opar.cmax = dev_ipar.cmax; - aproc_setout(conv, obuf); - obuf = abuf_new(nblk * round, &opar); - aproc_setin(conv, obuf); - } if (!aparams_eqrate(&opar, &dev_ipar)) { conv = resamp_new(name, dev_round, round); opar.rate = dev_ipar.rate; @@ -755,14 +739,6 @@ dev_attach(char *name, unsigned mode, obuf = abuf_new(nblk * round, &opar); aproc_setin(conv, obuf); } - if (!aparams_subset(&opar, &dev_opar)) { - conv = cmap_new(name, &dev_opar, &opar); - opar.cmin = dev_opar.cmin; - opar.cmax = dev_opar.cmax; - aproc_setout(conv, obuf); - obuf = abuf_new(nblk * round, &opar); - aproc_setin(conv, obuf); - } if (!aparams_eqrate(&opar, &dev_opar)) { conv = resamp_new(name, dev_round, round); opar.rate = dev_opar.rate; |