Module Name: src
Committed By: isaki
Date: Wed Jul 21 06:14:58 UTC 2021
Modified Files:
src/sys/dev/audio: audio.c
Log Message:
AUDIO_SETINFO: fix a bug that the gain and the balance could not be set
at the same time. Fix PR kern/56308.
To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/audio/audio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.104 src/sys/dev/audio/audio.c:1.105
--- src/sys/dev/audio/audio.c:1.104 Tue Jun 8 09:46:04 2021
+++ src/sys/dev/audio/audio.c Wed Jul 21 06:14:58 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $ */
+/* $NetBSD: audio.c,v 1.105 2021/07/21 06:14:58 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.105 2021/07/21 06:14:58 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -7418,59 +7418,46 @@ audio_hw_setinfo(struct audio_softc *sc,
}
}
- /* Backup play.{gain,balance} */
+ /* play.{gain,balance} */
if (SPECIFIED(newpi->gain) || SPECIFIED_CH(newpi->balance)) {
au_get_gain(sc, &sc->sc_outports, &pgain, &pbalance);
if (oldai) {
oldpi->gain = pgain;
oldpi->balance = pbalance;
}
+
+ if (SPECIFIED(newpi->gain))
+ pgain = newpi->gain;
+ if (SPECIFIED_CH(newpi->balance))
+ pbalance = newpi->balance;
+ error = au_set_gain(sc, &sc->sc_outports, pgain, pbalance);
+ if (error) {
+ audio_printf(sc,
+ "setting play.gain=%d/balance=%d failed: "
+ "errno=%d\n",
+ pgain, pbalance, error);
+ goto abort;
+ }
}
- /* Backup record.{gain,balance} */
+
+ /* record.{gain,balance} */
if (SPECIFIED(newri->gain) || SPECIFIED_CH(newri->balance)) {
au_get_gain(sc, &sc->sc_inports, &rgain, &rbalance);
if (oldai) {
oldri->gain = rgain;
oldri->balance = rbalance;
}
- }
- if (SPECIFIED(newpi->gain)) {
- error = au_set_gain(sc, &sc->sc_outports,
- newpi->gain, pbalance);
- if (error) {
- audio_printf(sc,
- "setting play.gain=%d failed: errno=%d\n",
- newpi->gain, error);
- goto abort;
- }
- }
- if (SPECIFIED(newri->gain)) {
- error = au_set_gain(sc, &sc->sc_inports,
- newri->gain, rbalance);
- if (error) {
- audio_printf(sc,
- "setting record.gain=%d failed: errno=%d\n",
- newri->gain, error);
- goto abort;
- }
- }
- if (SPECIFIED_CH(newpi->balance)) {
- error = au_set_gain(sc, &sc->sc_outports,
- pgain, newpi->balance);
- if (error) {
- audio_printf(sc,
- "setting play.balance=%d failed: errno=%d\n",
- newpi->balance, error);
- goto abort;
- }
- }
- if (SPECIFIED_CH(newri->balance)) {
- error = au_set_gain(sc, &sc->sc_inports,
- rgain, newri->balance);
+
+ if (SPECIFIED(newri->gain))
+ rgain = newri->gain;
+ if (SPECIFIED_CH(newri->balance))
+ rbalance = newri->balance;
+ error = au_set_gain(sc, &sc->sc_inports, rgain, rbalance);
if (error) {
audio_printf(sc,
- "setting record.balance=%d failed: errno=%d\n",
- newri->balance, error);
+ "setting record.gain=%d/balance=%d failed: "
+ "errno=%d\n",
+ rgain, rbalance, error);
goto abort;
}
}