commit a8ad970059e9cb2258ba29f94e5abef6672fe118
parent cba7f04d0728f2f117b2d8cdde159a5540b15532
Author: Christos Margiolis <christos@margiolis.net>
Date: Mon, 16 Jan 2023 00:45:34 +0200
minor fixes
Diffstat:
8 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/README b/README
@@ -8,6 +8,6 @@ system in FreeBSD 14.0.
Usage
-----
$ make
- # make install clean
+ # make install clean cleandepend
Report any bugs to <christos@FreeBSD.org>.
diff --git a/lib/libmixer/mixer.3 b/lib/libmixer/mixer.3
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2021 Christos Margiolis <christos@FreeBSD.org>
+.\" Copyright (c) 2021-2022 Christos Margiolis <christos@FreeBSD.org>
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a copy
.\" of this software and associated documentation files (the "Software"), to deal
@@ -21,7 +21,8 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 18, 2022
+
+.Dd March 19, 2022
.Dt MIXER 3
.Os
.Sh NAME
@@ -311,7 +312,7 @@ is
or
.Ar /dev/mixer ,
.Fn mixer_open
-opens the default mixer (hw.snd.defaul_unit).
+opens the default mixer (hw.snd.default_unit).
.Pp
The
.Fn mixer_close
diff --git a/lib/libmixer/mixer.h b/lib/libmixer/mixer.h
@@ -67,12 +67,12 @@ struct mix_dev {
float right; /* right volume */
} vol;
int nctl; /* number of controls */
- TAILQ_HEAD(, mix_ctl) ctls; /* control list */
+ TAILQ_HEAD(mix_ctlhead, mix_ctl) ctls; /* control list */
TAILQ_ENTRY(mix_dev) devs;
};
struct mixer {
- TAILQ_HEAD(, mix_dev) devs; /* device list */
+ TAILQ_HEAD(mix_devhead, mix_dev) devs; /* device list */
struct mix_dev *dev; /* selected device */
oss_mixerinfo mi; /* mixer info */
oss_card_info ci; /* audio card info */
diff --git a/diff/mixer_kern.diff b/patches/mixer_kern.diff
diff --git a/diff/mixer_rc.diff b/patches/mixer_rc.diff
diff --git a/usr.sbin/mixer/Makefile b/usr.sbin/mixer/Makefile
@@ -1,9 +1,8 @@
# $FreeBSD$
-#.include <src.opts.mk>
+.include <src.opts.mk>
PROG= mixer
-BINDIR= /usr/sbin
SRCS= ${PROG}.c
MAN= ${PROG}.8
LDFLAGS+= -lmixer
diff --git a/usr.sbin/mixer/mixer.8 b/usr.sbin/mixer/mixer.8
@@ -21,7 +21,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 18, 2022
+.Dd April 29, 2022
.Dt MIXER 8
.Os
.Sh NAME
@@ -112,8 +112,8 @@ with one of the available devices):
.It Sy Name Ta Sy Value
.It Ar dev Cm .volume Ta Xo
.Ar vol |
-.Oo Cm \&+ | Cm \&- Oc Ar lvol
-.Oo Cm \&: Oo Cm \&+ | Cm \&- Oc Ar rvol Oc
+.Oo Cm \&+ | Cm \&- Oc Ar lvol Oo % Oc
+.Oo Cm \&: Oo Cm \&+ | Cm \&- Oc Ar rvol Oo % Oc Oc
.Xc
.It Ar dev Cm .mute Ta Cm 0 | 1 | ^
.It Ar dev Cm .recsrc Ta Cm ^ | + | - | =
@@ -128,16 +128,21 @@ The optional
and/or
.Ar rvol
values have to be specified.
-The values have to be normalized 32-bit floats, from 0.0 to 1.0 inclusively.
-If no
-.Ql \&.
-character is present, the value is treated like a percentage, for backwards compatibility.
+The values should typically be decimal numbers between 0 and 1 with at most 2
+digits after the decimal point.
+A trailing percent sign indicates that the value should be treated as a
+percentage of 1.0, rather than an absolute value.
+Thus, 70% means the same as 0.7.
If the left or right volume values are prefixed with
.Cm +
or
.Cm - ,
the value following will be used as a relative adjustment, modifying the
current settings by the amount specified.
+Note that relative percentages are still relative to 1.0, not to the current
+value.
+If the volume is currently 0.40 and an adjustment of +20% is specified, then
+thet final volume will be set to 0.60.
.Pp
Volume can also be set using the shorthand
.Ar dev Ns Cm =value .
diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c
@@ -341,7 +341,7 @@ mod_volume(struct mix_dev *d, void *p)
mix_ctl_t *cp;
mix_volume_t v;
const char *val;
- char lstr[8], rstr[8];
+ char *endp, lstr[8], rstr[8];
float lprev, rprev, lrel, rrel;
int n;
@@ -356,25 +356,32 @@ mod_volume(struct mix_dev *d, void *p)
lrel = rrel = 0;
if (n > 0) {
if (*lstr == '+' || *lstr == '-')
- lrel = rrel = 1;
- v.left = strtof(lstr, NULL);
+ lrel = 1;
+ v.left = strtof(lstr, &endp);
+ if (*endp != '\0' && (*endp != '%' || *(endp + 1) != '\0')) {
+ warnx("invalid volume value: %s", lstr);
+ return (-1);
+ }
- /* be backwards compatible */
- if (strstr(lstr, ".") == NULL)
+ if (*endp == '%')
v.left /= 100.0f;
}
if (n > 1) {
if (*rstr == '+' || *rstr == '-')
rrel = 1;
- v.right = strtof(rstr, NULL);
+ v.right = strtof(rstr, &endp);
+ if (*endp != '\0' && (*endp != '%' || *(endp + 1) != '\0')) {
+ warnx("invalid volume value: %s", rstr);
+ return (-1);
+ }
- /* be backwards compatible */
- if (strstr(rstr, ".") == NULL)
+ if (*endp == '%')
v.right /= 100.0f;
}
switch (n) {
case 1:
v.right = v.left; /* FALLTHROUGH */
+ rrel = lrel;
case 2:
if (lrel)
v.left += m->dev->vol.left;