diff options
author | mdodd <mdodd@FreeBSD.org> | 2003-04-09 15:25:52 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2003-04-09 15:25:52 +0000 |
commit | 44c5b8459b18fe23017b645ce085890525e711a2 (patch) | |
tree | d8ffcf5a71a53af4f6562b589196dceb07711e4d /usr.sbin/mixer | |
parent | ff8a6b8bb5ec82a89ad7d0a9d782d6e4363721d5 (diff) | |
download | FreeBSD-src-44c5b8459b18fe23017b645ce085890525e711a2.zip FreeBSD-src-44c5b8459b18fe23017b645ce085890525e711a2.tar.gz |
Implement relative mixer adjustment.
PR: 46679 (similar functionality)
Diffstat (limited to 'usr.sbin/mixer')
-rw-r--r-- | usr.sbin/mixer/mixer.8 | 22 | ||||
-rw-r--r-- | usr.sbin/mixer/mixer.c | 42 |
2 files changed, 51 insertions, 13 deletions
diff --git a/usr.sbin/mixer/mixer.8 b/usr.sbin/mixer/mixer.8 index 3f5a926..1f5a571 100644 --- a/usr.sbin/mixer/mixer.8 +++ b/usr.sbin/mixer/mixer.8 @@ -37,19 +37,24 @@ .Nm .Op Fl f Ar device .Op Fl s -.Oo .Oo Ar dev -.Op Ar lvol Ns Op : Ns Ar rvol -.Cm | recsrc | +.Op Oo +|- Ns Oc Ns Ar lvol Ns Op : Ns Oo +|- Oc Ns Ar rvol Oc +.Ar ... +.Nm +.Op Fl f Ar device +.Op Fl s +.Cm recsrc +.Ar ... +.Nm +.Op Fl f Ar device +.Op Fl s .Sm off .Eo \&{ .Cm ^ | + | - | = .Sm on .Ec \&} Ns Cm rec .Ar rdev -.Oc .Ar ... -.Oc .Sh DESCRIPTION The .Nm @@ -87,6 +92,13 @@ arguments may be from 0 - 100. Omitting .Ar dev and including only the channel settings will change the main volume level. .Pp +If the left or right channel settings are prefixed with +.Sq + +or +.Sq - +the value following will be used as a relative adjustment, modifying the +current settings by the amount specified. +.Pp If the .Fl s flag is used, the current mixer values will be displayed in a format suitable diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c index d25a84e9ac..01b293d 100644 --- a/usr.sbin/mixer/mixer.c +++ b/usr.sbin/mixer/mixer.c @@ -35,7 +35,9 @@ usage(int devmask, int recmask) { int i, n; - printf("usage: mixer [-f device] [-s] [[dev [voll[:volr]] | recsrc | {^|+|-|=}rec recdev] ... ]\n"); + printf("usage: mixer [-f device] [-s] [dev [+|-][voll[:[+|-]volr]] ...\n" + " mixer [-f device] [-s] recsrc ...\n" + " mixer [-f device] [-s] {^|+|-|=}rec rdev ... \n"); printf(" devices: "); for (i = 0, n = 0; i < SOUND_MIXER_NRDEVICES; i++) if ((1 << i) & devmask) { @@ -91,6 +93,8 @@ main(int argc, char *argv[]) int devmask = 0, recmask = 0, recsrc = 0, orecsrc; int dusage = 0, drecsrc = 0, shortflag = 0; int l = 0, r = 0, t = 0; + char lstr[5], rstr[5]; + int n = 0, lrel = 0, rrel = 0; char ch; char *name; @@ -190,7 +194,24 @@ main(int argc, char *argv[]) break; } - switch(argc > 1 ? sscanf(argv[1], "%d:%d", &l, &r) : t) { +#define issign(c) (((c) == '+') || ((c) == '-')) + + if (argc > 1) { + n = sscanf(argv[1], "%7[^:]:%7s", lstr, rstr); + if (n > 0) { + if (issign(lstr[0])) + lrel = rrel = 1; + l = atoi(lstr); + } + if (n > 1) { + rrel = 0; + if (issign(rstr[0])) + rrel = 1; + r = atoi(rstr); + } + } + + switch(argc > 1 ? n : t) { case 0: if (ioctl(baz, MIXER_READ(dev),&bar)== -1) { warn("MIXER_READ"); @@ -208,6 +229,17 @@ main(int argc, char *argv[]) case 1: r = l; case 2: + if (ioctl(baz, MIXER_READ(dev),&bar)== -1) { + warn("MIXER_READ"); + argc--; argv++; + continue; + } + + if (lrel) + l = (bar & 0x7f) + l; + if (rrel) + r = ((bar >> 8) & 0x7f) + r; + if (l < 0) l = 0; else if (l > 100) @@ -217,12 +249,6 @@ main(int argc, char *argv[]) else if (r > 100) r = 100; - if (ioctl(baz, MIXER_READ(dev),&bar)== -1) { - warn("MIXER_READ"); - argc--; argv++; - continue; - } - printf("Setting the mixer %s from %d:%d to %d:%d.\n", names[dev], bar & 0x7f, (bar >> 8) & 0x7f, l, r); |