diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2011-05-26 07:18:41 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2011-05-26 07:18:41 +0000 |
commit | a76b2bb9ddd43569d8335eebb3456d6c60b492b1 (patch) | |
tree | bd505c211598839a0f6c7176ad7b9010ab13c4bb /usr.bin/aucat | |
parent | 28c2975d6c806b1333060e08ee056c3c477bd214 (diff) |
add a new -w flag to control whether master volume is automatically
adjusted when new streams are connected and disconnected. Disabling
automatic volume adjustment makes sense if all streams are recorded
with properly lowered volumes.
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r-- | usr.bin/aucat/aproc.c | 8 | ||||
-rw-r--r-- | usr.bin/aucat/aproc.h | 5 | ||||
-rw-r--r-- | usr.bin/aucat/aucat.1 | 28 | ||||
-rw-r--r-- | usr.bin/aucat/aucat.c | 13 | ||||
-rw-r--r-- | usr.bin/aucat/dev.c | 7 | ||||
-rw-r--r-- | usr.bin/aucat/dev.h | 6 |
6 files changed, 50 insertions, 17 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index 345f9300769..d4e13bf1bc1 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.64 2011/04/28 07:20:03 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.65 2011/05/26 07:18:40 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -1016,7 +1016,7 @@ struct aproc_ops mix_ops = { }; struct aproc * -mix_new(char *name, int maxlat, unsigned round) +mix_new(char *name, int maxlat, unsigned round, unsigned autovol) { struct aproc *p; @@ -1027,6 +1027,7 @@ mix_new(char *name, int maxlat, unsigned round) p->u.mix.maxlat = maxlat; p->u.mix.ctl = NULL; p->u.mix.mon = NULL; + p->u.mix.autovol = autovol; return p; } @@ -1040,6 +1041,9 @@ mix_setmaster(struct aproc *p) struct abuf *i, *j; int weight; + if (!p->u.mix.autovol) + return; + /* * count the number of inputs. If a set of inputs * uses channels that have no intersection, they are diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h index ee6233cd463..582a009befd 100644 --- a/usr.bin/aucat/aproc.h +++ b/usr.bin/aucat/aproc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.h,v 1.38 2010/11/04 17:55:28 ratchov Exp $ */ +/* $OpenBSD: aproc.h,v 1.39 2011/05/26 07:18:40 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -140,6 +140,7 @@ struct aproc { unsigned abspos; /* frames produced */ struct aproc *ctl; /* MIDI control/sync */ struct aproc *mon; /* snoop output */ + unsigned autovol; /* adjust volume dynamically */ } mix; struct { unsigned idle; /* frames since idleing */ @@ -239,7 +240,7 @@ void aproc_opos(struct aproc *, struct abuf *, int); struct aproc *rfile_new(struct file *); struct aproc *wfile_new(struct file *); -struct aproc *mix_new(char *, int, unsigned); +struct aproc *mix_new(char *, int, unsigned, unsigned); struct aproc *sub_new(char *, int, unsigned); struct aproc *resamp_new(char *, unsigned, unsigned); struct aproc *enc_new(char *, struct aparams *); diff --git a/usr.bin/aucat/aucat.1 b/usr.bin/aucat/aucat.1 index abe62fe1110..bdbd6be5d4f 100644 --- a/usr.bin/aucat/aucat.1 +++ b/usr.bin/aucat/aucat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: aucat.1,v 1.79 2011/05/23 07:06:53 jmc Exp $ +.\" $OpenBSD: aucat.1,v 1.80 2011/05/26 07:18:40 ratchov Exp $ .\" .\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 23 2011 $ +.Dd $Mdocdate: May 26 2011 $ .Dt AUCAT 1 .Os .Sh NAME @@ -42,6 +42,7 @@ .Op Fl t Ar mode .Op Fl U Ar unit .Op Fl v Ar volume +.Op Fl w Ar flag .Op Fl x Ar policy .Op Fl z Ar nframes .Ek @@ -114,7 +115,7 @@ Preceding streams control MIDI ports .Pq Fl q , and per-device options -.Pq Fl abz +.Pq Fl abwz apply to this device. Device mode and parameters are determined from streams attached to it. @@ -255,6 +256,25 @@ of clients as long as their number is small enough. A good compromise is to use \-4dB attenuation (12 volume units) for each additional client expected (115 if 2 clients are expected, 103 for 3 clients, and so on). +.It Fl w Ar flag +Control +.Nm +behaviour when the maximum volume of the hardware is reached +and a new stream is connected. +This happens only when stream volumes +are not properly set using the +.Fl v +option. +If the flag is +.Va on , +then the master volume (corresponding to the mix of all playback streams) +is automatically adjusted to avoid clipping. +Using +.Fl w Va off +makes sense when all streams are recorded or produced with properly lowered +volumes. +The default is +.Va on . .It Fl x Ar policy Action when the output stream cannot accept recorded data fast enough or the input stream @@ -298,7 +318,7 @@ to a 400 frame block size. .Pp On the command line, per-device parameters -.Pq Fl abz +.Pq Fl abwz must precede the device definition .Pq Fl f , and per-stream parameters diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index 87618c9cbba..ae3d916237f 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.114 2011/05/10 06:26:34 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.115 2011/05/26 07:18:40 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -250,6 +250,7 @@ struct cfdev { struct aparams ipar; /* input (read) parameters */ struct aparams opar; /* output (write) parameters */ unsigned hold; /* open immediately */ + unsigned autovol; /* adjust volumes */ unsigned bufsz; /* par.bufsz for sio device */ unsigned round; /* par.round for sio device */ unsigned mode; /* bitmap of MODE_XXX */ @@ -442,7 +443,7 @@ aucat_usage(void) "[-o file]\n\t" "[-q device] [-r rate] [-s name] [-t mode] [-U unit] " "[-v volume]\n\t" - "[-x policy] [-z nframes]\n", + "[-w flag] [-x policy] [-z nframes]\n", stderr); } @@ -511,8 +512,9 @@ aucat_main(int argc, char **argv) cd->bufsz = 0; cd->round = 0; cd->hold = 1; + cd->autovol = 1; - while ((c = getopt(argc, argv, "a:dnb:c:C:e:r:h:x:v:i:o:f:m:luq:s:U:L:t:j:z:")) != -1) { + while ((c = getopt(argc, argv, "a:w:dnb:c:C:e:r:h:x:v:i:o:f:m:luq:s:U:L:t:j:z:")) != -1) { switch (c) { case 'd': #ifdef DEBUG @@ -592,6 +594,9 @@ aucat_main(int argc, char **argv) case 'a': cd->hold = opt_onoff(); break; + case 'w': + cd->autovol = opt_onoff(); + break; case 'q': cfmid_add(&cd->mids, optarg); break; @@ -730,7 +735,7 @@ aucat_main(int argc, char **argv) } else { d = dev_new_sio(cd->path, cd->mode | MODE_MIDIMASK, &cd->ipar, &cd->opar, cd->bufsz, cd->round, - cd->hold); + cd->hold, cd->autovol); } if (d == NULL) errx(1, "%s: can't open device", cd->path); diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c index b09808ce12b..86ae039516f 100644 --- a/usr.bin/aucat/dev.c +++ b/usr.bin/aucat/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.64 2010/10/21 18:57:42 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.65 2011/05/26 07:18:40 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -114,7 +114,7 @@ struct dev *dev_list = NULL; struct dev * dev_new_sio(char *path, unsigned mode, struct aparams *dipar, struct aparams *dopar, - unsigned bufsz, unsigned round, unsigned hold) + unsigned bufsz, unsigned round, unsigned hold, unsigned autovol) { struct dev *d; @@ -132,6 +132,7 @@ dev_new_sio(char *path, d->reqbufsz = bufsz; d->reqround = round; d->hold = hold; + d->autovol = autovol; d->pstate = DEV_CLOSED; d->next = dev_list; dev_list = d; @@ -299,7 +300,7 @@ dev_open(struct dev *d) * Create mixer, demuxer and monitor */ if (d->mode & MODE_PLAY) { - d->mix = mix_new("play", d->bufsz, d->round); + d->mix = mix_new("play", d->bufsz, d->round, d->autovol); d->mix->refs++; d->mix->u.mix.ctl = d->midi; } diff --git a/usr.bin/aucat/dev.h b/usr.bin/aucat/dev.h index 58ad1bd0553..4f6bc88397f 100644 --- a/usr.bin/aucat/dev.h +++ b/usr.bin/aucat/dev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.h,v 1.27 2010/07/06 01:12:45 ratchov Exp $ */ +/* $OpenBSD: dev.h,v 1.28 2011/05/26 07:18:40 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -34,6 +34,7 @@ struct dev { unsigned reqround; /* block size */ unsigned reqrate; /* sample rate */ unsigned hold; /* hold the device open ? */ + unsigned autovol; /* auto adjust playvol ? */ unsigned refcnt; /* number of openers */ #define DEV_CLOSED 0 /* closed */ #define DEV_INIT 1 /* stopped */ @@ -64,7 +65,8 @@ void dev_drain(struct dev *); struct dev *dev_new_thru(void); struct dev *dev_new_loop(struct aparams *, struct aparams *, unsigned); struct dev *dev_new_sio(char *, unsigned, - struct aparams *, struct aparams *, unsigned, unsigned, unsigned); + struct aparams *, struct aparams *, + unsigned, unsigned, unsigned, unsigned); int dev_thruadd(struct dev *, char *, int, int); void dev_midiattach(struct dev *, struct abuf *, struct abuf *); unsigned dev_roundof(struct dev *, unsigned); |