From nobody Mon Feb 12 11:00:23 2024 X-Original-To: dev-commits-src-main@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 4TYM1h2b3vz59ZYl; Mon, 12 Feb 2024 11:00:24 +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 4TYM1h0LLSz4Vn0; Mon, 12 Feb 2024 11:00:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707735624; 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=uQrOaTQMMuj6xCyGIxaGjyP9QLQKb3zUGAeq0+RanRo=; b=VxckLDQy5CTDdFEG1i/u5ShGDX3YlcwgCGpWOrjS8fatJjE+Z5Ukr4Mp/tQS+DeoGvdrn4 burVYPYD84OY+yBkab/w45LTlf+r4WBgIy9h+F4u1lThXFBTbAZ8LK4rrDZ5MXpGE6mx3s bU25+kVo6PLTENM3QAtrc/EREM7bnCRy0TRyZROwzEez6MvwE6ueF8QiEzJgqFJaNITwnS JPdD1Q6vvterjCTL6MGg62zAlOONtExeEg4R1qqwbpeySeEwuaTztweoyj8u48q+etwb2V udmndrHk1MUXtQvRtFwJ98aljLe89OVvnded7ZhPV95X4Tjc+9DUPxYZiWy1zw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707735624; a=rsa-sha256; cv=none; b=KhID5WSf23yTLA7TyU+iOZ7yit3/E5kb9Kdo8pfpf5rzjIYeGwx1XGh4iGS2pieHJxhb1a cxb+ZZaQFIxqwvj+ba3AOjz65vtyEGScCUMuuFe4YVJWJ1y/ZidWcLYXGfiZVdmZE16pS9 7+mjgGZdfMYLPZ3FFkeHTH7TWLj9LN0IpJgQ+FAXVN32hEB+QxgnryOzPNi8Wx1YcYb674 yhz5ZAhRy1fJW2ywsPlSTYPRSUPMo+ZwPKo6yjiKHOW2uWKMVnGdQva+4xc7saQX5E1UZ4 t6MlPFG+78+xKJ72FCQAnYBULwkPCaHiwlgrdPRMMMu+hNV8FtcHCWc/7+ic1g== 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=1707735624; 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=uQrOaTQMMuj6xCyGIxaGjyP9QLQKb3zUGAeq0+RanRo=; b=W79tQ1Orz2VCCcy+pNNyR/nYrRU1eL7dQf6FLuISUpcibsOyqoAnUVaFVL7Ya07fIFk/TH VvyK8I6M1NUMUiuPHiCzR7QDPEwKxk7PL3LA9v/G16PrCvAqzpskjNiKne24aejgspAuYx g1rI6C4r1uTayi0ylKtsQvvXfTHTlxosHk19Sw1r9njlOU3grXEPuY0+elywkvX3WktDjI ruqmu8+35stG5HWUw/LHBVsVAqlls/u6T0ul7zh88fuWgXo3KVUuEhq1Ma38J4fuoIuZHI Xkb0NGTBERQSGqjgVVYPuzfKqBNUscdBr1LEy2fgYkA3b8BndWr0xEQOkgljqw== 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 4TYM1g6XTGzPDQ; Mon, 12 Feb 2024 11:00:23 +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 41CB0NGV033388; Mon, 12 Feb 2024 11:00:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41CB0N7s033386; Mon, 12 Feb 2024 11:00:23 GMT (envelope-from git) Date: Mon, 12 Feb 2024 11:00:23 GMT Message-Id: <202402121100.41CB0N7s033386@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 5daa7cf42f45 - main - mixer(8): Use new mixer if we change the default unit List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 5daa7cf42f4551cb2f4a452fd038807925320eac Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=5daa7cf42f4551cb2f4a452fd038807925320eac commit 5daa7cf42f4551cb2f4a452fd038807925320eac Author: Christos Margiolis AuthorDate: 2024-02-12 10:59:28 +0000 Commit: Christos Margiolis CommitDate: 2024-02-12 11:00:05 +0000 mixer(8): Use new mixer if we change the default unit If we use the -d option to change the default unit, close the current mixer and open the one we set as the default to avoid printing and applying changes (if any) to the old one. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D43809 --- usr.sbin/mixer/mixer.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c index 83e97df19116..47d8e6359b73 100644 --- a/usr.sbin/mixer/mixer.c +++ b/usr.sbin/mixer/mixer.c @@ -118,8 +118,21 @@ main(int argc, char *argv[]) initctls(m); - if (dflag && set_dunit(m, dunit) < 0) - goto parse; + if (dflag) { + if (set_dunit(m, dunit) < 0) + goto parse; + else { + /* + * Open current mixer since we changed the default + * unit, otherwise we'll print and apply changes to the + * old one. + */ + (void)mixer_close(m); + if ((m = mixer_open(NULL)) == NULL) + errx(1, "cannot open default mixer"); + initctls(m); + } + } if (sflag) { printrecsrc(m, oflag); (void)mixer_close(m);