summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2011-06-29 07:39:03 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2011-06-29 07:39:03 +0000
commit9cbe2e2b396aef602119e3afe296787251ce9cf8 (patch)
treee6e579d660abd0ad6cf80759d63d152ffdbc9ccf /usr.bin
parent3e3e7e6ae11012bed7eb0eb8df957ab3a4fb9197 (diff)
make -u flag per-device similarly to -a and -w
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/aucat/aucat.126
-rw-r--r--usr.bin/aucat/aucat.c29
2 files changed, 32 insertions, 23 deletions
diff --git a/usr.bin/aucat/aucat.1 b/usr.bin/aucat/aucat.1
index e7a63fea5b4..307733094df 100644
--- a/usr.bin/aucat/aucat.1
+++ b/usr.bin/aucat/aucat.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: aucat.1,v 1.85 2011/06/20 20:18:44 ratchov Exp $
+.\" $OpenBSD: aucat.1,v 1.86 2011/06/29 07:39:02 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: June 20 2011 $
+.Dd $Mdocdate: June 29 2011 $
.Dt AUCAT 1
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Sh SYNOPSIS
.Nm aucat
.Bk -words
-.Op Fl dlnu
+.Op Fl dln
.Op Fl a Ar flag
.Op Fl b Ar nframes
.Op Fl C Ar min : Ns Ar max
@@ -41,6 +41,7 @@
.Op Fl s Ar name
.Op Fl t Ar mode
.Op Fl U Ar unit
+.Op Fl u Ar flag
.Op Fl v Ar volume
.Op Fl w Ar flag
.Op Fl x Ar policy
@@ -116,7 +117,7 @@ Preceding streams
control MIDI ports
.Pq Fl q ,
and per-device options
-.Pq Fl abwz
+.Pq Fl abuwz
apply to this device.
Device mode and parameters are determined from streams
attached to it.
@@ -238,14 +239,21 @@ used in
.Xr sndio 7
device names.
The default is 0.
-.It Fl u
-Normally
+.It Fl u Ar flag
+Control how parameters of the audio device are chosen.
+If the flag is
+.Va on
+then
.Nm
-tries to automatically determine the optimal parameters for the audio device;
-if this option is specified,
+tries to automatically determine the optimal parameters to
+match stream parameters and avoid conversions if possible.
+If the flag is
+.Va off
it will instead use the parameters specified by the
.Fl Ccer
options.
+The default is
+.Va on .
.It Fl v Ar volume
Software volume attenuation of the playback stream.
The value must be between 1 and 127,
@@ -318,7 +326,7 @@ to a 400 frame block size.
.Pp
On the command line,
per-device parameters
-.Pq Fl abwz
+.Pq Fl abuwz
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 83595262ac9..ead5162e571 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.118 2011/06/20 20:18:44 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.119 2011/06/29 07:39:02 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -251,6 +251,7 @@ struct cfdev {
struct aparams opar; /* output (write) parameters */
unsigned hold; /* open immediately */
unsigned autovol; /* adjust volumes */
+ unsigned autopar; /* adjust parameters to streams */
unsigned bufsz; /* par.bufsz for sio device */
unsigned round; /* par.round for sio device */
unsigned mode; /* bitmap of MODE_XXX */
@@ -288,6 +289,7 @@ cfdev_new(struct cfdev *templ)
cd->round = 0;
cd->hold = 1;
cd->autovol = 1;
+ cd->autopar = 1;
}
SLIST_INIT(&cd->ins);
SLIST_INIT(&cd->outs);
@@ -460,13 +462,13 @@ privdrop(void)
void
aucat_usage(void)
{
- (void)fputs("usage: " PROG_AUCAT " [-dlnu] [-a flag] [-b nframes] "
+ (void)fputs("usage: " PROG_AUCAT " [-dln] [-a flag] [-b nframes] "
"[-C min:max] [-c min:max] [-e enc]\n\t"
"[-f device] [-h fmt] [-i file] [-j flag] [-L addr] [-m mode] "
"[-o file]\n\t"
"[-q device] [-r rate] [-s name] [-t mode] [-U unit] "
- "[-v volume]\n\t"
- "[-w flag] [-x policy] [-z nframes]\n",
+ "[-u flag]\nt"
+ "[-v volume] [-w flag] [-x policy] [-z nframes]\n",
stderr);
}
@@ -479,7 +481,7 @@ aucat_main(int argc, char **argv)
struct cfstr *cs;
struct cfdev *cd;
struct cfnet *cn;
- int c, u_flag, d_flag, l_flag, n_flag, unit;
+ int c, d_flag, l_flag, n_flag, unit;
char base[PATH_MAX], path[PATH_MAX];
unsigned mode, rate;
const char *str;
@@ -492,7 +494,6 @@ aucat_main(int argc, char **argv)
* global options defaults
*/
unit = -1;
- u_flag = 0;
d_flag = 0;
l_flag = 0;
n_flag = 0;
@@ -506,7 +507,7 @@ aucat_main(int argc, char **argv)
cd = cfdev_new(NULL);
cs = cfstr_new(NULL);
- 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) {
+ while ((c = getopt(argc, argv, "a:w:dnb:c:C:e:r:h:x:v:i:o:f:m:lu:q:s:U:L:t:j:z:")) != -1) {
switch (c) {
case 'd':
#ifdef DEBUG
@@ -518,9 +519,6 @@ aucat_main(int argc, char **argv)
case 'n':
n_flag = 1;
break;
- case 'u':
- u_flag = 1;
- break;
case 'U':
unit = strtonum(optarg, 0, MIDI_MAXCTL, &str);
if (str)
@@ -591,6 +589,9 @@ aucat_main(int argc, char **argv)
case 'w':
cd->autovol = opt_onoff();
break;
+ case 'u':
+ cd->autopar = opt_onoff();
+ break;
case 'q':
cfmid_add(&cd->mids, optarg);
break;
@@ -680,7 +681,7 @@ aucat_main(int argc, char **argv)
*/
SLIST_FOREACH(cd, &cfdevs, entry) {
mode = 0;
- if (!u_flag) {
+ if (cd->autopar) {
aparams_init(&cd->opar, NCHAN_MAX - 1, 0, RATE_MIN);
aparams_init(&cd->opar, NCHAN_MAX - 1, 0, RATE_MIN);
}
@@ -688,7 +689,7 @@ aucat_main(int argc, char **argv)
if (cs->mode == 0)
errx(1, "%s: not in play mode", cs->path);
mode |= (cs->mode & MODE_PLAY);
- if (!u_flag)
+ if (cd->autopar)
aparams_grow(&cd->opar, &cs->ipar);
}
SLIST_FOREACH(cs, &cd->outs, entry) {
@@ -697,14 +698,14 @@ aucat_main(int argc, char **argv)
if ((cs->mode & MODE_REC) && (cs->mode & MODE_MON))
errx(1, "%s: can't rec and mon", cs->path);
mode |= (cs->mode & MODE_RECMASK);
- if (!u_flag)
+ if (cd->autopar)
aparams_grow(&cd->ipar, &cs->opar);
}
SLIST_FOREACH(cs, &cd->opts, entry) {
if ((cs->mode & MODE_REC) && (cs->mode & MODE_MON))
errx(1, "%s: can't rec and mon", cs->path);
mode |= (cs->mode & (MODE_RECMASK | MODE_PLAY));
- if (!u_flag) {
+ if (cd->autopar) {
aparams_grow(&cd->opar, &cs->ipar);
aparams_grow(&cd->ipar, &cs->opar);
}