Merge branch 'master' of ssh://caoua.org/~alex/git/sndio

This commit is contained in:
Alexandre Ratchov 2020-05-02 17:51:56 +02:00
commit 417e0d6bef
11 changed files with 89 additions and 38 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

@ -62,7 +62,7 @@ sio_open(const char *str, unsigned int mode, int nbio)
if (hdl != NULL)
return hdl;
#if defined(USE_SUN)
return _sio_sun_open("rsnd/default", mode, nbio);
return _sio_sun_open("rsnd/0", mode, nbio);
#elif defined(USE_OSS)
return _sio_oss_open("rsnd/default", mode, nbio);
#elif defined(USE_ALSA)

View File

@ -290,14 +290,10 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio)
DPRINTF("sio_sun_getfd: %s: '/' expected\n", str);
return -1;
}
if (strcmp(p, "default") == 0) {
devnum = 0;
} else {
p = _sndio_parsenum(p, &devnum, 255);
if (p == NULL || *p != '\0') {
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
return -1;
}
p = _sndio_parsenum(p, &devnum, 255);
if (p == NULL || *p != '\0') {
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
return -1;
}
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
if (mode == (SIO_PLAY | SIO_REC))

View File

@ -45,7 +45,7 @@ sioctl_open(const char *str, unsigned int mode, int nbio)
if (hdl != NULL)
return hdl;
#if defined(USE_SUN_MIXER)
return _sioctl_sun_open("rsnd/default", mode, nbio);
return _sioctl_sun_open("rsnd/0", mode, nbio);
#else
return NULL;
#endif

View File

@ -84,14 +84,24 @@ static int
initmute(struct sioctl_sun_hdl *hdl, struct mixer_devinfo *info)
{
struct mixer_devinfo mi;
char name[MAX_AUDIO_DEV_LEN];
mi.index = info->next;
for (mi.index = info->next; mi.index != -1; mi.index = mi.next) {
if (ioctl(hdl->fd, AUDIO_MIXER_DEVINFO, &mi) < 0)
break;
if (strcmp(mi.label.name, AudioNmute) == 0)
return mi.index;
}
/* try "_mute" suffix */
snprintf(name, sizeof(name), "%s_mute", info->label.name);
for (mi.index = 0; ; mi.index++) {
if (ioctl(hdl->fd, AUDIO_MIXER_DEVINFO, &mi) < 0)
break;
if (info->mixer_class == mi.mixer_class &&
strcmp(mi.label.name, name) == 0)
return mi.index;
}
return -1;
}

View File

@ -100,20 +100,22 @@ If
.Qq \&!
is used instead of a number, then the switch is toggled.
.Sh EXAMPLES
The following will set all
.Ar output
channels
.Ar level
control to zero:
Increase the
.Cm level
control affecting all
.Cm output
channels by 10% of the maximum:
.Pp
.Dl $ sndioctl output.level=0
.Dl $ sndioctl output.level=+0.1
.Pp
The following set all
.Ar output
channels
.Ar mute
Mute all output channels:
.Pp
.Dl $ sndioctl output.mute=1
.Pp
Toggle the above
.Cm mute
control:
.Pp
.Dl $ sndioctl output.mute=0
.Dl $ sndioctl output.mute=!
.Sh SEE ALSO
.Xr sioctl_open 3

View File

@ -374,7 +374,14 @@ print_val(struct info *p, int mono)
switch (p->desc.type) {
case SIOCTL_NUM:
case SIOCTL_SW:
printf("%.2g", p->curval / (float)p->desc.maxval);
if (p->desc.maxval == 1)
printf("%d", p->curval);
else
/*
* For now, maxval is always 127 or 255,
* so three decimals is always ideal.
*/
printf("%.3f", p->curval / (float)p->desc.maxval);
break;
case SIOCTL_VEC:
case SIOCTL_LIST:
@ -389,7 +396,11 @@ print_val(struct info *p, int mono)
if (more)
printf(",");
print_node(&e->desc.node1, mono);
printf(":%.2g", e->curval / (float)e->desc.maxval);
if (e->desc.maxval == 1)
printf(":%d", e->curval);
else
printf(":%.3f",
e->curval / (float)e->desc.maxval);
more = 1;
}
}

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;

View File

@ -151,7 +151,7 @@ sock_close(struct sock *f)
}
#endif
if (f->pstate > SOCK_AUTH)
sock_sesrefs--;
sock_sesrefs -= f->sesrefs;
if (f->slot) {
slot_del(f->slot);
f->slot = NULL;
@ -792,11 +792,12 @@ sock_auth(struct sock *f)
if (sock_sesrefs == 0) {
/* start a new session */
memcpy(sock_sescookie, p->cookie, AMSG_COOKIELEN);
f->sesrefs = 1;
} else if (memcmp(sock_sescookie, p->cookie, AMSG_COOKIELEN) != 0) {
/* another session is active, drop connection */
return 0;
}
sock_sesrefs++;
sock_sesrefs += f->sesrefs;
f->pstate = SOCK_HELLO;
return 1;
}

View File

@ -64,6 +64,7 @@ struct sock {
#define SOCK_CTLVAL 2 /* send value changes */
unsigned int ctlops; /* bitmap of above */
int ctlsyncpending; /* CTLSYNC waiting to be transmitted */
unsigned int sesrefs; /* 1 if socket belongs to a session */
};
struct sock *sock_new(int fd);