Module Name: src
Committed By: snj
Date: Wed Jul 28 14:59:02 UTC 2021
Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c
Log Message:
Pull up following revision(s) (requested by isaki in ticket #1325):
sys/dev/audio/audio.c: revision 1.105
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.28.2.22 -r1.28.2.23 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.28.2.22 src/sys/dev/audio/audio.c:1.28.2.23
--- src/sys/dev/audio/audio.c:1.28.2.22 Wed May 5 17:01:41 2021
+++ src/sys/dev/audio/audio.c Wed Jul 28 14:59:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.28.2.22 2021/05/05 17:01:41 martin Exp $ */
+/* $NetBSD: audio.c,v 1.28.2.23 2021/07/28 14:59:02 snj Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.22 2021/05/05 17:01:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.23 2021/07/28 14:59:02 snj Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -7381,59 +7381,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;
}
}