If no -f options are used, expose first 4 midi(4) devices to sndiod clients

A single default device could be set at ./configure time with
the --default-dev option
This commit is contained in:
Alexandre Ratchov 2020-04-30 19:04:30 +02:00
parent 7433055e88
commit f330fa3d4a
3 changed files with 42 additions and 12 deletions

11
configure vendored
View File

@ -24,6 +24,7 @@ Usage: configure [options]
--disable-umidi disable usb-midi backend
--with-libbsd use the libbsd rather than bsd-compat/*
--without-libbsd don't use libbsd
--default-dev=DEV set default device [$dev]
END
}
@ -49,6 +50,7 @@ unset includedir # path where to install header file
unset libdir # path where to install library
unset defs # no extra #defines
unset ldadd # no extra libraries (-l options)
unset dev
#
# guess OS-specific parameters
@ -170,6 +172,9 @@ for i; do
--without-libbsd)
libbsd=no
shift;;
--default-dev=*)
dev="${i#--default-dev=}"
shift;;
CC=*|CFLAGS=*|LDFLAGS=*)
vars="$vars$i$nl"
shift;;
@ -241,6 +246,11 @@ if [ $libbsd = yes ]; then
ldadd="$ldadd -lbsd"
fi
if [ -n "$dev" ]; then
defs="$defs -DDEFAULT_DEV=\\\"$dev\\\""
fi
for f in Makefile aucat/Makefile midicat/Makefile sndiod/Makefile \
libsndio/Makefile \
sndioctl/Makefile \
@ -262,6 +272,7 @@ do
-e "s:@vars@:${vars}:" \
-e "s:@precision@:$precision:" \
-e "s:@user@:$user:" \
-e "s:@devs@:$devs:" \
< $f.in > $f
done

View File

@ -208,6 +208,14 @@ Sub-devices
that are applied after will be attached to this device.
Device mode and parameters are determined from sub-devices
attached to it.
If no
.Fl f
option is used,
.Nm
will use
.Pa rsnd/0 , rsnd/1 ,
.No ... ,
.Pa rsnd/3 .
.It Fl j Ar flag
Control whether program channels are joined or expanded if
the number of channels requested by a program is not equal

View File

@ -78,13 +78,6 @@
#define DEFAULT_BUFSZ 7680
#endif
/*
* default device in server mode
*/
#ifndef DEFAULT_DEV
#define DEFAULT_DEV "rsnd/default"
#endif
void sigint(int);
void sighup(int);
void opt_ch(int *, int *);
@ -111,6 +104,18 @@ char usagestr[] = "usage: sndiod [-d] [-a flag] [-b nframes] "
"[-Q port] [-q port] [-r rate] [-s name] [-t mode] [-U unit]\n\t"
"[-v volume] [-w flag] [-z nframes]\n";
/*
* default audio devices
*/
static char *default_devs[] = {
#ifdef DEFAULT_DEV
DEFAULT_DEV,
#else
"rsnd/0", "rsnd/1", "rsnd/2", "rsnd/3",
#endif
NULL
};
/*
* default MIDI ports
*/
@ -361,7 +366,7 @@ mkopt(char *path, struct dev *d,
int
main(int argc, char **argv)
{
int c, i, background, unit;
int c, i, background, unit, devindex;
int pmin, pmax, rmin, rmax;
char base[SOCKPATH_MAX], path[SOCKPATH_MAX];
unsigned int mode, dup, mmc, vol;
@ -399,6 +404,7 @@ main(int argc, char **argv)
aparams_init(&par);
mode = MODE_PLAY | MODE_REC;
tcpaddr_list = NULL;
devindex = 0;
while ((c = getopt(argc, argv,
"a:b:c:C:de:F:f:j:L:m:Q:q:r:s:t:U:v:w:x:z:")) != -1) {
@ -448,8 +454,8 @@ main(int argc, char **argv)
break;
case 's':
if ((d = dev_list) == NULL) {
d = mkdev(DEFAULT_DEV, &par, 0, bufsz, round,
rate, hold, autovol);
d = mkdev(default_devs[devindex++], &par, 0,
bufsz, round, rate, hold, autovol);
}
if (mkopt(optarg, d, pmin, pmax, rmin, rmax,
mode, vol, mmc, dup) == NULL)
@ -482,6 +488,7 @@ main(int argc, char **argv)
case 'f':
mkdev(optarg, &par, 0, bufsz, round,
rate, hold, autovol);
devindex = -1;
break;
case 'F':
if (dev_list == NULL)
@ -503,8 +510,12 @@ main(int argc, char **argv)
for (i = 0; default_ports[i] != NULL; i++)
mkport(default_ports[i], 0);
}
if (dev_list == NULL)
mkdev(DEFAULT_DEV, &par, 0, bufsz, round, rate, hold, autovol);
if (devindex != -1) {
for (i = devindex; default_devs[i] != NULL; i++) {
mkdev(default_devs[i], &par, 0,
bufsz, round, rate, 0, autovol);
}
}
for (d = dev_list; d != NULL; d = d->next) {
if (opt_byname(d, "default"))
continue;