make -u flag per-device similarly to -a and -w

This commit is contained in:
Alexandre Ratchov 2011-06-29 09:36:03 +02:00
parent 736ea055d7
commit d187c66343
2 changed files with 29 additions and 20 deletions

View File

@ -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

View File

@ -252,6 +252,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 */
@ -289,6 +290,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);
@ -461,13 +463,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);
}
@ -480,7 +482,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;
@ -493,7 +495,6 @@ aucat_main(int argc, char **argv)
* global options defaults
*/
unit = -1;
u_flag = 0;
d_flag = 0;
l_flag = 0;
n_flag = 0;
@ -507,7 +508,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
@ -519,9 +520,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)
@ -592,6 +590,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;
@ -681,7 +682,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);
}
@ -689,7 +690,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) {
@ -698,14 +699,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);
}