diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-10-09 16:49:49 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2009-10-09 16:49:49 +0000 |
commit | e63b410bd2d2ea83a174720f32baf4ebe8201f7f (patch) | |
tree | 688a3b4835f995a31258be9828a7305070ced87a | |
parent | 18e5527c20aa9fec68e81896548209b8fb82b032 (diff) |
Make abuf structure smaller:
- put aproc-specific parameters into unions since they are never
used together
- remove constant ``data'' pointer always pointing the end of the
abuf structure
-rw-r--r-- | usr.bin/aucat/abuf.c | 7 | ||||
-rw-r--r-- | usr.bin/aucat/abuf.h | 71 | ||||
-rw-r--r-- | usr.bin/aucat/aproc.c | 108 | ||||
-rw-r--r-- | usr.bin/aucat/dev.c | 10 | ||||
-rw-r--r-- | usr.bin/aucat/dev.h | 5 | ||||
-rw-r--r-- | usr.bin/aucat/midi.c | 132 |
6 files changed, 171 insertions, 162 deletions
diff --git a/usr.bin/aucat/abuf.c b/usr.bin/aucat/abuf.c index 5485f0147b7..54f2436c21b 100644 --- a/usr.bin/aucat/abuf.c +++ b/usr.bin/aucat/abuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abuf.c,v 1.15 2009/09/27 11:51:20 ratchov Exp $ */ +/* $OpenBSD: abuf.c,v 1.16 2009/10/09 16:49:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -72,7 +72,6 @@ abuf_new(unsigned nfr, struct aparams *par) buf->rproc = NULL; buf->wproc = NULL; buf->duplex = NULL; - buf->data = (unsigned char *)buf + sizeof(*buf); return buf; } @@ -113,7 +112,7 @@ abuf_rgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) if (count > used) count = used; *rsize = count; - return buf->data + start; + return (unsigned char *)buf + sizeof(struct abuf) + start; } /* @@ -155,7 +154,7 @@ abuf_wgetblk(struct abuf *buf, unsigned *rsize, unsigned ofs) if (count > avail) count = avail; *rsize = count; - return buf->data + end; + return (unsigned char *)buf + sizeof(struct abuf) + end; } /* diff --git a/usr.bin/aucat/abuf.h b/usr.bin/aucat/abuf.h index 659e658897e..23c2e8ffde4 100644 --- a/usr.bin/aucat/abuf.h +++ b/usr.bin/aucat/abuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: abuf.h,v 1.18 2009/09/27 11:51:20 ratchov Exp $ */ +/* $OpenBSD: abuf.h,v 1.19 2009/10/09 16:49:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -19,37 +19,17 @@ #include <sys/queue.h> +#define XRUN_IGNORE 0 /* on xrun silently insert/discard samples */ +#define XRUN_SYNC 1 /* catchup to sync to the mix/sub */ +#define XRUN_ERROR 2 /* xruns are errors, eof/hup buffer */ +#define MIDI_MSGMAX 16 /* max size of MIDI messaage */ + struct aproc; struct aparams; struct abuf { - /* - * Misc aproc-specific per-buffer parameters. - * since the buffer can connect any pair of aproc structure, - * each aproc must have it's own specific data. Thus we cannot - * use a union. The only exception is the xrun field, because - * there can be only one aproc that absorbs xruns in any - * intput->output path. - */ - int mixweight; /* dynamic range for the source stream */ - int mixmaxweight; /* max dynamic range allowed */ - unsigned mixvol; /* volume within the dynamic range */ - unsigned mixodone; /* bytes done on the dest stream */ - unsigned mixitodo; /* bytes to do on the source stream */ - unsigned subidone; /* bytes copied from the source stream */ -#define XRUN_IGNORE 0 /* on xrun silently insert/discard samples */ -#define XRUN_SYNC 1 /* catchup to sync to the mix/sub */ -#define XRUN_ERROR 2 /* xruns are errors, eof/hup buffer */ - unsigned xrun; /* common to mix and sub */ - LIST_ENTRY(abuf) ient; /* for mix inputs list */ - LIST_ENTRY(abuf) oent; /* for sub outputs list */ - unsigned mstatus; /* MIDI running status */ - unsigned mindex; /* current MIDI message size */ - unsigned mused; /* bytes used from mdata */ - unsigned mlen; /* MIDI message length */ -#define MDATA_NMAX 16 - unsigned char mdata[MDATA_NMAX]; /* MIDI message data */ - unsigned mtickets; /* max data to transmit (throttling) */ + LIST_ENTRY(abuf) ient; /* reader's list of inputs entry */ + LIST_ENTRY(abuf) oent; /* writer's list of outputs entry */ /* * fifo parameters @@ -66,7 +46,40 @@ struct abuf { struct aproc *wproc; /* writer */ struct abuf *duplex; /* link to buffer of the other direction */ unsigned inuse; /* in abuf_{flush,fill,run}() */ - unsigned char *data; /* actual data (immediately following) */ + unsigned tickets; /* max data to (if throttling) */ + + /* + * Misc reader aproc-specific per-buffer parameters. + */ + union { + struct { + int weight; /* dynamic range */ + int maxweight; /* max dynamic range allowed */ + unsigned vol; /* volume within the dynamic range */ + unsigned done; /* bytes ready */ + unsigned xrun; /* underrun policy */ + } mix; + struct { + unsigned st; /* MIDI running status */ + unsigned used; /* bytes used from ``msg'' */ + unsigned idx; /* actual MIDI message size */ + unsigned len; /* MIDI message length */ + unsigned char msg[MIDI_MSGMAX]; + } midi; + } r; + + /* + * Misc reader aproc-specific per-buffer parameters. + */ + union { + struct { + unsigned todo; /* bytes to process */ + } mix; + struct { + unsigned done; /* bytes copied */ + unsigned xrun; /* overrun policy */ + } sub; + } w; }; /* diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index fd5bf6c46f5..f9274299f6c 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.35 2009/10/06 18:06:55 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.36 2009/10/09 16:49:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -345,12 +345,12 @@ mix_bzero(struct abuf *obuf, unsigned zcount) short *odata; unsigned ocount; - odata = (short *)abuf_wgetblk(obuf, &ocount, obuf->mixitodo); + odata = (short *)abuf_wgetblk(obuf, &ocount, obuf->w.mix.todo); ocount -= ocount % obuf->bpf; if (ocount > zcount) ocount = zcount; memset(odata, 0, ocount); - obuf->mixitodo += ocount; + obuf->w.mix.todo += ocount; } /* @@ -375,19 +375,19 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf) /* * Zero-fill if necessary. */ - zcount = ibuf->mixodone + icount * obuf->bpf; - if (zcount > obuf->mixitodo) - mix_bzero(obuf, zcount - obuf->mixitodo); + zcount = ibuf->r.mix.done + icount * obuf->bpf; + if (zcount > obuf->w.mix.todo) + mix_bzero(obuf, zcount - obuf->w.mix.todo); /* * Calculate the maximum we can write. */ - odata = (short *)abuf_wgetblk(obuf, &ocount, ibuf->mixodone); + odata = (short *)abuf_wgetblk(obuf, &ocount, ibuf->r.mix.done); ocount /= obuf->bpf; if (ocount == 0) return; - vol = (ibuf->mixweight * ibuf->mixvol) >> ADATA_SHIFT; + 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; @@ -402,7 +402,7 @@ mix_badd(struct abuf *ibuf, struct abuf *obuf) odata += onext; } abuf_rdiscard(ibuf, scount * ibuf->bpf); - ibuf->mixodone += scount * obuf->bpf; + ibuf->r.mix.done += scount * obuf->bpf; } @@ -414,16 +414,16 @@ mix_xrun(struct abuf *i, struct abuf *obuf) { unsigned fdrop; - if (i->mixodone > 0) + if (i->r.mix.done > 0) return 1; - if (i->xrun == XRUN_ERROR) { + if (i->r.mix.xrun == XRUN_ERROR) { abuf_hup(i); return 0; } mix_bzero(obuf, obuf->len); - fdrop = obuf->mixitodo / obuf->bpf; - i->mixodone += fdrop * obuf->bpf; - if (i->xrun == XRUN_SYNC) + fdrop = obuf->w.mix.todo / obuf->bpf; + i->r.mix.done += fdrop * obuf->bpf; + if (i->r.mix.xrun == XRUN_SYNC) i->drop += fdrop * i->bpf; else { abuf_opos(i, -(int)fdrop); @@ -449,17 +449,17 @@ mix_in(struct aproc *p, struct abuf *ibuf) if (!abuf_fill(i)) continue; /* eof */ mix_badd(i, obuf); - if (odone > i->mixodone) - odone = i->mixodone; + if (odone > i->r.mix.done) + odone = i->r.mix.done; } if (LIST_EMPTY(&p->ibuflist) || odone == 0) return 0; p->u.mix.lat += odone / obuf->bpf; LIST_FOREACH(i, &p->ibuflist, ient) { - i->mixodone -= odone; + i->r.mix.done -= odone; } abuf_wcommit(obuf, odone); - obuf->mixitodo -= odone; + obuf->w.mix.todo -= odone; if (!abuf_flush(obuf)) return 0; /* hup */ return 1; @@ -485,8 +485,8 @@ mix_out(struct aproc *p, struct abuf *obuf) } } else mix_badd(i, obuf); - if (odone > i->mixodone) - odone = i->mixodone; + if (odone > i->r.mix.done) + odone = i->r.mix.done; } if (LIST_EMPTY(&p->ibuflist)) { if (p->u.mix.flags & MIX_AUTOQUIT) { @@ -496,17 +496,17 @@ mix_out(struct aproc *p, struct abuf *obuf) if (!(p->u.mix.flags & MIX_DROP)) return 0; mix_bzero(obuf, obuf->len); - odone = obuf->mixitodo; + odone = obuf->w.mix.todo; p->u.mix.idle += odone / obuf->bpf; } if (odone == 0) return 0; p->u.mix.lat += odone / obuf->bpf; LIST_FOREACH(i, &p->ibuflist, ient) { - i->mixodone -= odone; + i->r.mix.done -= odone; } abuf_wcommit(obuf, odone); - obuf->mixitodo -= odone; + obuf->w.mix.todo -= odone; return 1; } @@ -524,17 +524,17 @@ mix_eof(struct aproc *p, struct abuf *ibuf) */ odone = obuf->len; LIST_FOREACH(i, &p->ibuflist, ient) { - if (ABUF_ROK(i) && i->mixodone < obuf->mixitodo) { + if (ABUF_ROK(i) && i->r.mix.done < obuf->w.mix.todo) { abuf_run(i); return; } - if (odone > i->mixodone) - odone = i->mixodone; + if (odone > i->r.mix.done) + odone = i->r.mix.done; } /* * No blocked inputs. Check if output is blocked. */ - if (LIST_EMPTY(&p->ibuflist) || odone == obuf->mixitodo) + if (LIST_EMPTY(&p->ibuflist) || odone == obuf->w.mix.todo) abuf_run(obuf); } } @@ -549,17 +549,17 @@ void mix_newin(struct aproc *p, struct abuf *ibuf) { p->u.mix.idle = 0; - ibuf->mixodone = 0; - ibuf->mixvol = ADATA_UNIT; - ibuf->mixweight = ADATA_UNIT; - ibuf->mixmaxweight = ADATA_UNIT; - ibuf->xrun = XRUN_IGNORE; + ibuf->r.mix.done = 0; + ibuf->r.mix.vol = ADATA_UNIT; + ibuf->r.mix.weight = ADATA_UNIT; + ibuf->r.mix.maxweight = ADATA_UNIT; + ibuf->r.mix.xrun = XRUN_IGNORE; } void mix_newout(struct aproc *p, struct abuf *obuf) { - obuf->mixitodo = 0; + obuf->w.mix.todo = 0; } void @@ -611,9 +611,9 @@ mix_setmaster(struct aproc *p) } LIST_FOREACH(buf, &p->ibuflist, ient) { weight = ADATA_UNIT / n; - if (weight > buf->mixmaxweight) - weight = buf->mixmaxweight; - buf->mixweight = weight; + if (weight > buf->r.mix.maxweight) + weight = buf->r.mix.maxweight; + buf->r.mix.weight = weight; } } @@ -623,7 +623,7 @@ mix_clear(struct aproc *p) struct abuf *obuf = LIST_FIRST(&p->obuflist); p->u.mix.lat = 0; - obuf->mixitodo = 0; + obuf->w.mix.todo = 0; } /* @@ -636,7 +636,7 @@ sub_bcopy(struct abuf *ibuf, struct abuf *obuf) unsigned i, j, ocnt, inext, istart; unsigned icount, ocount, scount; - idata = (short *)abuf_rgetblk(ibuf, &icount, obuf->subidone); + idata = (short *)abuf_rgetblk(ibuf, &icount, obuf->w.sub.done); icount /= ibuf->bpf; if (icount == 0) return; @@ -658,7 +658,7 @@ sub_bcopy(struct abuf *ibuf, struct abuf *obuf) idata += inext; } abuf_wcommit(obuf, scount * obuf->bpf); - obuf->subidone += scount * ibuf->bpf; + obuf->w.sub.done += scount * ibuf->bpf; } /* @@ -669,14 +669,14 @@ sub_xrun(struct abuf *ibuf, struct abuf *i) { unsigned fdrop; - if (i->subidone > 0) + if (i->w.sub.done > 0) return 1; - if (i->xrun == XRUN_ERROR) { + if (i->w.sub.xrun == XRUN_ERROR) { abuf_eof(i); return 0; } fdrop = ibuf->used / ibuf->bpf; - if (i->xrun == XRUN_SYNC) + if (i->w.sub.xrun == XRUN_SYNC) i->silence += fdrop * i->bpf; else { abuf_ipos(i, -(int)fdrop); @@ -685,7 +685,7 @@ sub_xrun(struct abuf *ibuf, struct abuf *i) abuf_opos(i->duplex, -(int)fdrop); } } - i->subidone += fdrop * ibuf->bpf; + i->w.sub.done += fdrop * ibuf->bpf; return 1; } @@ -707,8 +707,8 @@ sub_in(struct aproc *p, struct abuf *ibuf) } } else sub_bcopy(ibuf, i); - if (idone > i->subidone) - idone = i->subidone; + if (idone > i->w.sub.done) + idone = i->w.sub.done; if (!abuf_flush(i)) continue; } @@ -725,7 +725,7 @@ sub_in(struct aproc *p, struct abuf *ibuf) if (idone == 0) return 0; LIST_FOREACH(i, &p->obuflist, oent) { - i->subidone -= idone; + i->w.sub.done -= idone; } abuf_rdiscard(ibuf, idone); p->u.sub.lat -= idone / ibuf->bpf; @@ -747,15 +747,15 @@ sub_out(struct aproc *p, struct abuf *obuf) for (i = LIST_FIRST(&p->obuflist); i != NULL; i = inext) { inext = LIST_NEXT(i, oent); sub_bcopy(ibuf, i); - if (idone > i->subidone) - idone = i->subidone; + if (idone > i->w.sub.done) + idone = i->w.sub.done; if (!abuf_flush(i)) continue; } if (LIST_EMPTY(&p->obuflist) || idone == 0) return 0; LIST_FOREACH(i, &p->obuflist, oent) { - i->subidone -= idone; + i->w.sub.done -= idone; } abuf_rdiscard(ibuf, idone); p->u.sub.lat -= idone / ibuf->bpf; @@ -780,12 +780,12 @@ sub_hup(struct aproc *p, struct abuf *obuf) */ idone = ibuf->len; LIST_FOREACH(i, &p->obuflist, oent) { - if (ABUF_WOK(i) && i->subidone < ibuf->used) { + if (ABUF_WOK(i) && i->w.sub.done < ibuf->used) { abuf_run(i); return; } - if (idone > i->subidone) - idone = i->subidone; + if (idone > i->w.sub.done) + idone = i->w.sub.done; } /* * No blocked outputs. Check if input is blocked. @@ -799,8 +799,8 @@ void sub_newout(struct aproc *p, struct abuf *obuf) { p->u.sub.idle = 0; - obuf->subidone = 0; - obuf->xrun = XRUN_IGNORE; + obuf->w.sub.done = 0; + obuf->w.sub.xrun = XRUN_IGNORE; } void diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c index 03ebec61b2f..133014e7b47 100644 --- a/usr.bin/aucat/dev.c +++ b/usr.bin/aucat/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.30 2009/09/27 11:51:20 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.31 2009/10/09 16:49:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -528,8 +528,8 @@ dev_attach(char *name, } aproc_setin(dev_mix, ibuf); abuf_opos(ibuf, -dev_mix->u.mix.lat); - ibuf->xrun = underrun; - ibuf->mixmaxweight = vol; + ibuf->r.mix.xrun = underrun; + ibuf->r.mix.maxweight = vol; mix_setmaster(dev_mix); } if (obuf) { @@ -566,7 +566,7 @@ dev_attach(char *name, } aproc_setout(dev_sub, obuf); abuf_ipos(obuf, -dev_sub->u.sub.lat); - obuf->xrun = overrun; + obuf->w.sub.xrun = overrun; } /* @@ -588,7 +588,7 @@ dev_setvol(struct abuf *ibuf, int vol) if (!dev_getep(&ibuf, NULL)) { return; } - ibuf->mixvol = vol; + ibuf->r.mix.vol = vol; } /* diff --git a/usr.bin/aucat/dev.h b/usr.bin/aucat/dev.h index e62553c0b8f..95b119896cd 100644 --- a/usr.bin/aucat/dev.h +++ b/usr.bin/aucat/dev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.h,v 1.12 2009/08/19 05:54:15 ratchov Exp $ */ +/* $OpenBSD: dev.h,v 1.13 2009/10/09 16:49:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -22,7 +22,6 @@ struct aparams; struct abuf; extern unsigned dev_bufsz, dev_round, dev_rate; -extern unsigned dev_rate_div, dev_round_div; extern struct aparams dev_ipar, dev_opar; extern struct aproc *dev_mix, *dev_sub, *dev_rec, *dev_play, *dev_midi; @@ -45,6 +44,4 @@ void dev_attach(char *, void dev_setvol(struct abuf *, int); void dev_clear(void); -extern struct devops *devops, devops_sun, devops_aucat; - #endif /* !define(DEV_H) */ diff --git a/usr.bin/aucat/midi.c b/usr.bin/aucat/midi.c index 54ccf219d80..0e794305a36 100644 --- a/usr.bin/aucat/midi.c +++ b/usr.bin/aucat/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.9 2009/09/27 11:51:20 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.10 2009/10/09 16:49:48 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -70,7 +70,7 @@ unsigned voice_len[] = { 3, 3, 3, 3, 2, 2, 3 }; unsigned common_len[] = { 0, 2, 3, 2, 0, 0, 1, 1 }; /* - * send the message stored in of ibuf->mdata to obuf + * send the message stored in of ibuf->r.midi.msg to obuf */ void thru_flush(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) @@ -78,8 +78,8 @@ thru_flush(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) unsigned ocount, itodo; unsigned char *odata, *idata; - itodo = ibuf->mused; - idata = ibuf->mdata; + itodo = ibuf->r.midi.used; + idata = ibuf->r.midi.msg; while (itodo > 0) { if (!ABUF_WOK(obuf)) { abuf_rdiscard(obuf, obuf->used); @@ -95,7 +95,7 @@ thru_flush(struct aproc *p, struct abuf *ibuf, struct abuf *obuf) itodo -= ocount; idata += ocount; } - ibuf->mused = 0; + ibuf->r.midi.used = 0; p->u.thru.owner = ibuf; } @@ -145,44 +145,44 @@ thru_bcopy(struct aproc *p, struct abuf *ibuf, struct abuf *obuf, unsigned todo) c = *idata++; icount--; if (c < 0x80) { - if (ibuf->mindex == 0 && ibuf->mstatus) { - ibuf->mdata[ibuf->mused++] = ibuf->mstatus; - ibuf->mindex++; + if (ibuf->r.midi.idx == 0 && ibuf->r.midi.st) { + ibuf->r.midi.msg[ibuf->r.midi.used++] = ibuf->r.midi.st; + ibuf->r.midi.idx++; } - ibuf->mdata[ibuf->mused++] = c; - ibuf->mindex++; - if (ibuf->mindex == ibuf->mlen) { + ibuf->r.midi.msg[ibuf->r.midi.used++] = c; + ibuf->r.midi.idx++; + if (ibuf->r.midi.idx == ibuf->r.midi.len) { thru_flush(p, ibuf, obuf); - if (ibuf->mstatus >= 0xf0) - ibuf->mstatus = 0; - ibuf->mindex = 0; + if (ibuf->r.midi.st >= 0xf0) + ibuf->r.midi.st = 0; + ibuf->r.midi.idx = 0; } - if (ibuf->mused == MDATA_NMAX) { - if (ibuf->mused == ibuf->mindex || + if (ibuf->r.midi.used == MIDI_MSGMAX) { + if (ibuf->r.midi.used == ibuf->r.midi.idx || p->u.thru.owner == ibuf) thru_flush(p, ibuf, obuf); else - ibuf->mused = 0; + ibuf->r.midi.used = 0; } } else if (c < 0xf8) { - if (ibuf->mused == ibuf->mindex || + if (ibuf->r.midi.used == ibuf->r.midi.idx || p->u.thru.owner == ibuf) { thru_flush(p, ibuf, obuf); } else - ibuf->mused = 0; - ibuf->mdata[0] = c; - ibuf->mused = 1; - ibuf->mlen = (c >= 0xf0) ? + ibuf->r.midi.used = 0; + ibuf->r.midi.msg[0] = c; + ibuf->r.midi.used = 1; + ibuf->r.midi.len = (c >= 0xf0) ? common_len[c & 7] : voice_len[(c >> 4) & 7]; - if (ibuf->mlen == 1) { + if (ibuf->r.midi.len == 1) { thru_flush(p, ibuf, obuf); - ibuf->mindex = 0; - ibuf->mstatus = 0; - ibuf->mlen = 0; + ibuf->r.midi.idx = 0; + ibuf->r.midi.st = 0; + ibuf->r.midi.len = 0; } else { - ibuf->mstatus = c; - ibuf->mindex = 1; + ibuf->r.midi.st = c; + ibuf->r.midi.idx = 1; } } else { thru_rt(p, ibuf, obuf, c); @@ -198,13 +198,13 @@ thru_in(struct aproc *p, struct abuf *ibuf) if (!ABUF_ROK(ibuf)) return 0; - if (ibuf->mtickets == 0) { + if (ibuf->tickets == 0) { return 0; } todo = ibuf->used; - if (todo > ibuf->mtickets) - todo = ibuf->mtickets; - ibuf->mtickets -= todo; + if (todo > ibuf->tickets) + todo = ibuf->tickets; + ibuf->tickets -= todo; for (i = LIST_FIRST(&p->obuflist); i != NULL; i = inext) { inext = LIST_NEXT(i, oent); if (ibuf->duplex == i) @@ -235,11 +235,11 @@ thru_hup(struct aproc *p, struct abuf *obuf) void thru_newin(struct aproc *p, struct abuf *ibuf) { - ibuf->mused = 0; - ibuf->mlen = 0; - ibuf->mindex = 0; - ibuf->mstatus = 0; - ibuf->mtickets = MIDITHRU_XFER; + ibuf->r.midi.used = 0; + ibuf->r.midi.len = 0; + ibuf->r.midi.idx = 0; + ibuf->r.midi.st = 0; + ibuf->tickets = MIDITHRU_XFER; } void @@ -277,8 +277,8 @@ thru_cb(void *addr) for (i = LIST_FIRST(&p->ibuflist); i != NULL; i = inext) { inext = LIST_NEXT(i, ient); - tickets = i->mtickets; - i->mtickets = MIDITHRU_XFER; + tickets = i->tickets; + i->tickets = MIDITHRU_XFER; if (tickets == 0) abuf_run(i); } @@ -450,17 +450,17 @@ ctl_ev(struct aproc *p, struct abuf *ibuf) { unsigned chan; struct ctl_slot *slot; - if ((ibuf->mdata[0] & MIDI_CMDMASK) == MIDI_CTL && - ibuf->mdata[1] == MIDI_CTLVOL) { - chan = ibuf->mdata[0] & MIDI_CHANMASK; + if ((ibuf->r.midi.msg[0] & MIDI_CMDMASK) == MIDI_CTL && + ibuf->r.midi.msg[1] == MIDI_CTLVOL) { + chan = ibuf->r.midi.msg[0] & MIDI_CHANMASK; if (chan >= CTL_NSLOT) return; slot = p->u.ctl.slot + chan; if (slot->cb == NULL) return; - slot->vol = ibuf->mdata[2]; + slot->vol = ibuf->r.midi.msg[2]; slot->cb(slot->arg, slot->vol); - ctl_sendmsg(p, ibuf, ibuf->mdata, ibuf->mlen); + ctl_sendmsg(p, ibuf, ibuf->r.midi.msg, ibuf->r.midi.len); } } @@ -478,30 +478,30 @@ ctl_in(struct aproc *p, struct abuf *ibuf) if (c >= 0xf8) { /* clock events not used yet */ } else if (c >= 0xf0) { - if (ibuf->mstatus == 0xf0 && c == 0xf7 && - ibuf->mindex < MDATA_NMAX) { - ibuf->mdata[ibuf->mindex++] = c; + if (ibuf->r.midi.st == 0xf0 && c == 0xf7 && + ibuf->r.midi.idx < MIDI_MSGMAX) { + ibuf->r.midi.msg[ibuf->r.midi.idx++] = c; ctl_ev(p, ibuf); continue; } - ibuf->mdata[0] = c; - ibuf->mlen = common_len[c & 7]; - ibuf->mstatus = c; - ibuf->mindex = 1; + ibuf->r.midi.msg[0] = c; + ibuf->r.midi.len = common_len[c & 7]; + ibuf->r.midi.st = c; + ibuf->r.midi.idx = 1; } else if (c >= 0x80) { - ibuf->mdata[0] = c; - ibuf->mlen = voice_len[(c >> 4) & 7]; - ibuf->mstatus = c; - ibuf->mindex = 1; - } else if (ibuf->mstatus) { - if (ibuf->mindex == MDATA_NMAX) + ibuf->r.midi.msg[0] = c; + ibuf->r.midi.len = voice_len[(c >> 4) & 7]; + ibuf->r.midi.st = c; + ibuf->r.midi.idx = 1; + } else if (ibuf->r.midi.st) { + if (ibuf->r.midi.idx == MIDI_MSGMAX) continue; - if (ibuf->mindex == 0) - ibuf->mdata[ibuf->mindex++] = ibuf->mstatus; - ibuf->mdata[ibuf->mindex++] = c; - if (ibuf->mindex == ibuf->mlen) { + if (ibuf->r.midi.idx == 0) + ibuf->r.midi.msg[ibuf->r.midi.idx++] = ibuf->r.midi.st; + ibuf->r.midi.msg[ibuf->r.midi.idx++] = c; + if (ibuf->r.midi.idx == ibuf->r.midi.len) { ctl_ev(p, ibuf); - ibuf->mindex = 0; + ibuf->r.midi.idx = 0; } } } @@ -528,10 +528,10 @@ ctl_hup(struct aproc *p, struct abuf *obuf) void ctl_newin(struct aproc *p, struct abuf *ibuf) { - ibuf->mused = 0; - ibuf->mlen = 0; - ibuf->mindex = 0; - ibuf->mstatus = 0; + ibuf->r.midi.used = 0; + ibuf->r.midi.len = 0; + ibuf->r.midi.idx = 0; + ibuf->r.midi.st = 0; } void |