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 .Sh SYNOPSIS
.Nm aucat .Nm aucat
.Bk -words .Bk -words
.Op Fl dlnu .Op Fl dln
.Op Fl a Ar flag .Op Fl a Ar flag
.Op Fl b Ar nframes .Op Fl b Ar nframes
.Op Fl C Ar min : Ns Ar max .Op Fl C Ar min : Ns Ar max
@ -41,6 +41,7 @@
.Op Fl s Ar name .Op Fl s Ar name
.Op Fl t Ar mode .Op Fl t Ar mode
.Op Fl U Ar unit .Op Fl U Ar unit
.Op Fl u Ar flag
.Op Fl v Ar volume .Op Fl v Ar volume
.Op Fl w Ar flag .Op Fl w Ar flag
.Op Fl x Ar policy .Op Fl x Ar policy
@ -116,7 +117,7 @@ Preceding streams
control MIDI ports control MIDI ports
.Pq Fl q , .Pq Fl q ,
and per-device options and per-device options
.Pq Fl abwz .Pq Fl abuwz
apply to this device. apply to this device.
Device mode and parameters are determined from streams Device mode and parameters are determined from streams
attached to it. attached to it.
@ -238,14 +239,21 @@ used in
.Xr sndio 7 .Xr sndio 7
device names. device names.
The default is 0. The default is 0.
.It Fl u .It Fl u Ar flag
Normally Control how parameters of the audio device are chosen.
If the flag is
.Va on
then
.Nm .Nm
tries to automatically determine the optimal parameters for the audio device; tries to automatically determine the optimal parameters to
if this option is specified, match stream parameters and avoid conversions if possible.
If the flag is
.Va off
it will instead use the parameters specified by the it will instead use the parameters specified by the
.Fl Ccer .Fl Ccer
options. options.
The default is
.Va on .
.It Fl v Ar volume .It Fl v Ar volume
Software volume attenuation of the playback stream. Software volume attenuation of the playback stream.
The value must be between 1 and 127, The value must be between 1 and 127,
@ -318,7 +326,7 @@ to a 400 frame block size.
.Pp .Pp
On the command line, On the command line,
per-device parameters per-device parameters
.Pq Fl abwz .Pq Fl abuwz
must precede the device definition must precede the device definition
.Pq Fl f , .Pq Fl f ,
and per-stream parameters and per-stream parameters

View File

@ -252,6 +252,7 @@ struct cfdev {
struct aparams opar; /* output (write) parameters */ struct aparams opar; /* output (write) parameters */
unsigned hold; /* open immediately */ unsigned hold; /* open immediately */
unsigned autovol; /* adjust volumes */ unsigned autovol; /* adjust volumes */
unsigned autopar; /* adjust parameters to streams */
unsigned bufsz; /* par.bufsz for sio device */ unsigned bufsz; /* par.bufsz for sio device */
unsigned round; /* par.round for sio device */ unsigned round; /* par.round for sio device */
unsigned mode; /* bitmap of MODE_XXX */ unsigned mode; /* bitmap of MODE_XXX */
@ -289,6 +290,7 @@ cfdev_new(struct cfdev *templ)
cd->round = 0; cd->round = 0;
cd->hold = 1; cd->hold = 1;
cd->autovol = 1; cd->autovol = 1;
cd->autopar = 1;
} }
SLIST_INIT(&cd->ins); SLIST_INIT(&cd->ins);
SLIST_INIT(&cd->outs); SLIST_INIT(&cd->outs);
@ -461,13 +463,13 @@ privdrop(void)
void void
aucat_usage(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" "[-C min:max] [-c min:max] [-e enc]\n\t"
"[-f device] [-h fmt] [-i file] [-j flag] [-L addr] [-m mode] " "[-f device] [-h fmt] [-i file] [-j flag] [-L addr] [-m mode] "
"[-o file]\n\t" "[-o file]\n\t"
"[-q device] [-r rate] [-s name] [-t mode] [-U unit] " "[-q device] [-r rate] [-s name] [-t mode] [-U unit] "
"[-v volume]\n\t" "[-u flag]\nt"
"[-w flag] [-x policy] [-z nframes]\n", "[-v volume] [-w flag] [-x policy] [-z nframes]\n",
stderr); stderr);
} }
@ -480,7 +482,7 @@ aucat_main(int argc, char **argv)
struct cfstr *cs; struct cfstr *cs;
struct cfdev *cd; struct cfdev *cd;
struct cfnet *cn; 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]; char base[PATH_MAX], path[PATH_MAX];
unsigned mode, rate; unsigned mode, rate;
const char *str; const char *str;
@ -493,7 +495,6 @@ aucat_main(int argc, char **argv)
* global options defaults * global options defaults
*/ */
unit = -1; unit = -1;
u_flag = 0;
d_flag = 0; d_flag = 0;
l_flag = 0; l_flag = 0;
n_flag = 0; n_flag = 0;
@ -507,7 +508,7 @@ aucat_main(int argc, char **argv)
cd = cfdev_new(NULL); cd = cfdev_new(NULL);
cs = cfstr_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) { switch (c) {
case 'd': case 'd':
#ifdef DEBUG #ifdef DEBUG
@ -519,9 +520,6 @@ aucat_main(int argc, char **argv)
case 'n': case 'n':
n_flag = 1; n_flag = 1;
break; break;
case 'u':
u_flag = 1;
break;
case 'U': case 'U':
unit = strtonum(optarg, 0, MIDI_MAXCTL, &str); unit = strtonum(optarg, 0, MIDI_MAXCTL, &str);
if (str) if (str)
@ -592,6 +590,9 @@ aucat_main(int argc, char **argv)
case 'w': case 'w':
cd->autovol = opt_onoff(); cd->autovol = opt_onoff();
break; break;
case 'u':
cd->autopar = opt_onoff();
break;
case 'q': case 'q':
cfmid_add(&cd->mids, optarg); cfmid_add(&cd->mids, optarg);
break; break;
@ -681,7 +682,7 @@ aucat_main(int argc, char **argv)
*/ */
SLIST_FOREACH(cd, &cfdevs, entry) { SLIST_FOREACH(cd, &cfdevs, entry) {
mode = 0; 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);
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) if (cs->mode == 0)
errx(1, "%s: not in play mode", cs->path); errx(1, "%s: not in play mode", cs->path);
mode |= (cs->mode & MODE_PLAY); mode |= (cs->mode & MODE_PLAY);
if (!u_flag) if (cd->autopar)
aparams_grow(&cd->opar, &cs->ipar); aparams_grow(&cd->opar, &cs->ipar);
} }
SLIST_FOREACH(cs, &cd->outs, entry) { 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)) if ((cs->mode & MODE_REC) && (cs->mode & MODE_MON))
errx(1, "%s: can't rec and mon", cs->path); errx(1, "%s: can't rec and mon", cs->path);
mode |= (cs->mode & MODE_RECMASK); mode |= (cs->mode & MODE_RECMASK);
if (!u_flag) if (cd->autopar)
aparams_grow(&cd->ipar, &cs->opar); aparams_grow(&cd->ipar, &cs->opar);
} }
SLIST_FOREACH(cs, &cd->opts, entry) { SLIST_FOREACH(cs, &cd->opts, entry) {
if ((cs->mode & MODE_REC) && (cs->mode & MODE_MON)) if ((cs->mode & MODE_REC) && (cs->mode & MODE_MON))
errx(1, "%s: can't rec and mon", cs->path); errx(1, "%s: can't rec and mon", cs->path);
mode |= (cs->mode & (MODE_RECMASK | MODE_PLAY)); mode |= (cs->mode & (MODE_RECMASK | MODE_PLAY));
if (!u_flag) { if (cd->autopar) {
aparams_grow(&cd->opar, &cs->ipar); aparams_grow(&cd->opar, &cs->ipar);
aparams_grow(&cd->ipar, &cs->opar); aparams_grow(&cd->ipar, &cs->opar);
} }