From nobody Mon Feb 26 23:22:47 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TkGqq61dQz5BtH0; Mon, 26 Feb 2024 23:22:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TkGqq3Hdjz4V62; Mon, 26 Feb 2024 23:22:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708989767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wIJqmChev0P+Fp4Xp4dzJFEXD3JDWcO9SUQ4GzKt0GA=; b=pEDCsQnm94/2vz+j6PC39fauQky5M1fQSmnDk4H2fcLZiVE100AgSqQr1OJKtSGu14571Y /WD1jGXZR3mceOB83xZdYNhnIQ3r+40qds2aLX38rG3DwEsF/iikAU74b3JUZXX9qETXmX CLbD0foyzfjfZJog4iTJ2YqmZlVdW64dQfL5iSfRQ1/y2/TI8uQdak+Sw2h8lGMSYiTjNF Bf18uB6WF584RIgkfHChGu5z3sQJ44fVV7ajHmW3+BgSDLba+id13KonsTbUAolu2TXedh Ejrl/8Fyk/r/kIuhg3KRHDsUT7meztR0D23F2K/T/Jr3RTTGKKObrcj2iCaJ4w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708989767; a=rsa-sha256; cv=none; b=uq5II4UW5M9vpwsf7kLG1DPf4w4pXw/fVCUv+8u2nIztcNnFgH/Z6B0JXoiuRj0crdeuMW s76MN2IiH32ZTB+sY7cTef/7g7bcCRQoA4WLJwG5hImWWkcv6S+rthE5tRmYugZBgLBUxD DvqYhbtvgiYzATreoROYKM6EGgTryePulro8n+e+NdUkUw89Nh/yONNXCxBl5XkJBUNxOt /hNxjDI7Il+oKDlxrDiyzhpxHLnEKsXlxcrl57vUlr6jEl4ysvVbmRY5v/JdCiqg9YCvzm fM7XK7gGtnUdqveGXsMaRAS0/3JXtNwtMI5RjEWDOZbxiaffzZCGG2MbaxCjIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708989767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wIJqmChev0P+Fp4Xp4dzJFEXD3JDWcO9SUQ4GzKt0GA=; b=bp6gQ9D6X3oylAQLQDWsGVg2y1iIl6DVRay5NyPGbNUwHMTc/3z8T21GdKgPnT44tUJf/8 5rf6dNr7+NyfGEyXDnfWFcYY8SNSby1iUzrtXvQqWjtTo5qNwOZ6tJATe3N7XbCUZiLGR9 84FZVW8DNQMWujIn5Cify7UFctF2f+3CmraXsXsoecWG0IGIGfTBOhCMKdKMgSlc+4bXsK bdiRcWy34tNIip8lya2/lgKw8K8GyHU475GyJ/3sq2tJKn0ooC0qaeszlFpzM9cUF2a6em z9fWDTPjEq/l+tHBFMBd1qfTExcXuoMzlp24HRaR6HmPXyBnQEFI4VXxZgX0tg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TkGqq2MH7zp4Q; Mon, 26 Feb 2024 23:22:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41QNMlLb028458; Mon, 26 Feb 2024 23:22:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41QNMlB6028455; Mon, 26 Feb 2024 23:22:47 GMT (envelope-from git) Date: Mon, 26 Feb 2024 23:22:47 GMT Message-Id: <202402262322.41QNMlB6028455@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 96a80ca9ba72 - stable/14 - mixer(8): Improve mute and recsrc controls List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 96a80ca9ba727a36e311b18d5f94626cf27355c9 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=96a80ca9ba727a36e311b18d5f94626cf27355c9 commit 96a80ca9ba727a36e311b18d5f94626cf27355c9 Author: Christos Margiolis AuthorDate: 2024-02-12 10:59:22 +0000 Commit: Christos Margiolis CommitDate: 2024-02-26 23:22:31 +0000 mixer(8): Improve mute and recsrc controls The input options of "dev.mute" (+, -, ^) and "dev.recsrc" (+, -, ^, =) are quite cryptic. Allow the input to also be an actual description of what these options do. + -> add (recsrc) - -> remove (recsrc) ^ -> toggle (recsrc, mute) = -> set (recsrc) 0 -> off (mute) 1 -> on (mute) Also, deprecate the use of the symbol options in the EXAMPLES section of the man page, by using the new descriptive options. In the future, we might want to get rid of the symbol options altogether, but preserve backwards compatibility for now. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: dev_submerge.ch, imp Differential Revision: https://reviews.freebsd.org/D43796 (cherry picked from commit cc7479d7dc9b895c0a2f4d3805315437e03d0cf6) --- usr.sbin/mixer/mixer.8 | 33 +++++++++++++++++--------------- usr.sbin/mixer/mixer.c | 52 +++++++++++++++++++++++--------------------------- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/usr.sbin/mixer/mixer.8 b/usr.sbin/mixer/mixer.8 index db0ec5f23a0c..75c6a81e3a55 100644 --- a/usr.sbin/mixer/mixer.8 +++ b/usr.sbin/mixer/mixer.8 @@ -114,7 +114,9 @@ with one of the available devices): .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 .mute Ta Cm off | on | toggle .It Ar dev Cm .recsrc Ta Cm ^ | + | - | = +.It Ar dev Cm .recsrc Ta Cm toggle | add | remove | set .El .Sm on .Pp @@ -150,14 +152,14 @@ The .Ar dev Ns Cm .mute control (un)mutes a device. The following values are available: -.Bl -tag -width = -offset indent -.It Cm 0 +.Bl -tag -width "xxxxxxxxxx" -offset indent +.It Cm 0 | off unmutes .Ar dev -.It Cm 1 +.It Cm 1 | on mutes .Ar dev -.It Cm ^ +.It Cm ^ | toggle toggles the mute of .Ar dev .El @@ -174,22 +176,23 @@ To modify the recording source you can use one of the following modifiers on a .Sy rec device: -.Bl -tag -width = -offset indent -.It Cm ^ +.Bl -tag -width "xxxxxxxxxx" -offset indent +.It Cm ^ | toggle toggles .Ar dev of possible recording devices -.It Cm + +.It Cm + | add adds .Ar dev to possible recording devices -.It Cm - +.It Cm - | remove removes .Ar dev from possible recording devices -.It Cm = -sets the recording device to +.It Cm = | set +makes .Ar dev +the only recording device. .El .Sh FILES .Bl -tag -width /dev/mixerN -compact @@ -250,16 +253,16 @@ $ mixer mic.volume=+0.10:-0.05 Toggle the mute for .Cm vol : .Bd -literal -offset indent -$ mixer vol.mute=^ +$ mixer vol.mute=toggle .Ed .Pp -Set +Add .Cm mic -and toggle +and remove .Cm line -recording sources: +from the recording devices: .Bd -literal -offset indent -$ mixer mic.recsrc=+ line.recsrc=^ +$ mixer mic.recsrc=add line.recsrc=remove .Ed .Pp Dump diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c index 0c0c37ccb2bc..83e97df19116 100644 --- a/usr.sbin/mixer/mixer.c +++ b/usr.sbin/mixer/mixer.c @@ -413,26 +413,24 @@ mod_mute(struct mix_dev *d, void *p) m = d->parent_mixer; cp = mixer_get_ctl(m->dev, C_MUT); val = p; - switch (*val) { - case '0': + if (strncmp(val, "off", strlen(val)) == 0 || *val == '0') opt = MIX_UNMUTE; - break; - case '1': + else if (strncmp(val, "on", strlen(val)) == 0 || *val == '1') opt = MIX_MUTE; - break; - case '^': + else if (strncmp(val, "toggle", strlen(val)) == 0 || *val == '^') opt = MIX_TOGGLEMUTE; - break; - default: - warnx("%c: no such modifier", *val); + else { + warnx("%s: no such modifier", val); return (-1); } n = MIX_ISMUTE(m, m->dev->devno); if (mixer_set_mute(m, opt) < 0) - warn("%s.%s=%c", m->dev->name, cp->name, *val); + warn("%s.%s=%s", m->dev->name, cp->name, val); else - printf("%s.%s: %d -> %d\n", - m->dev->name, cp->name, n, MIX_ISMUTE(m, m->dev->devno)); + printf("%s.%s: %s -> %s\n", + m->dev->name, cp->name, + n ? "on" : "off", + MIX_ISMUTE(m, m->dev->devno) ? "on" : "off"); return (0); } @@ -448,29 +446,26 @@ mod_recsrc(struct mix_dev *d, void *p) m = d->parent_mixer; cp = mixer_get_ctl(m->dev, C_SRC); val = p; - switch (*val) { - case '+': + if (strncmp(val, "add", strlen(val)) == 0 || *val == '+') opt = MIX_ADDRECSRC; - break; - case '-': + else if (strncmp(val, "remove", strlen(val)) == 0 || *val == '-') opt = MIX_REMOVERECSRC; - break; - case '=': + else if (strncmp(val, "set", strlen(val)) == 0 || *val == '=') opt = MIX_SETRECSRC; - break; - case '^': + else if (strncmp(val, "toggle", strlen(val)) == 0 || *val == '^') opt = MIX_TOGGLERECSRC; - break; - default: - warnx("%c: no such modifier", *val); + else { + warnx("%s: no such modifier", val); return (-1); } n = MIX_ISRECSRC(m, m->dev->devno); if (mixer_mod_recsrc(m, opt) < 0) - warn("%s.%s=%c", m->dev->name, cp->name, *val); + warn("%s.%s=%s", m->dev->name, cp->name, val); else - printf("%s.%s: %d -> %d\n", - m->dev->name, cp->name, n, MIX_ISRECSRC(m, m->dev->devno)); + printf("%s.%s: %s -> %s\n", + m->dev->name, cp->name, + n ? "add" : "remove", + MIX_ISRECSRC(m, m->dev->devno) ? "add" : "remove"); return (0); } @@ -493,7 +488,8 @@ print_mute(struct mix_dev *d, void *p) struct mixer *m = d->parent_mixer; const char *ctl_name = p; - printf("%s.%s=%d\n", m->dev->name, ctl_name, MIX_ISMUTE(m, m->dev->devno)); + printf("%s.%s=%s\n", m->dev->name, ctl_name, + MIX_ISMUTE(m, m->dev->devno) ? "on" : "off"); return (0); } @@ -506,7 +502,7 @@ print_recsrc(struct mix_dev *d, void *p) if (!MIX_ISRECSRC(m, m->dev->devno)) return (-1); - printf("%s.%s=+\n", m->dev->name, ctl_name); + printf("%s.%s=add\n", m->dev->name, ctl_name); return (0); }