NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/52781: audioctl can't set output gain



Hi, 

On Sun, 20 May 2018 17:27:17 matthew green wrote:
> play.gain is the traditional way the "sun audio" interface has
> worked, so any other tool that thought this was a master volume
> (which it has been, until recently) has to be updated, whether
> it is a C program or a script.

I believe this is the way to go, but it's possibly too soon for those with 
existing software.

> 
> that's not particularly nice for the end users, so i would like
> to at least restore the original functionality if there is one
> vchan only, if not more generally.
> 

How about the attached patch it will set the hw gain also if their is only one 
channel open (recording or playback).  If this is good I'll document this 
behaviour and update the spec.

Best regards,

Nat
Index: audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio.c,v
retrieving revision 1.456
diff -u -p -r1.456 audio.c
--- audio.c	17 May 2018 11:35:31 -0000	1.456
+++ audio.c	20 May 2018 08:44:55 -0000
@@ -4755,27 +4755,32 @@ done:
 			goto cleanup;
 	}
 	if (SPECIFIED(p->gain)) {
-		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
+		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
+						 vc == &sc->sc_mixring) {
 			au_get_gain(sc, &sc->sc_outports, &gain, &balance);
 			error = au_set_gain(sc, &sc->sc_outports, p->gain, balance);
 			if (error)
 				goto cleanup;
-		} else
+		}
+		if (sc->sc_usemixer)
 			vc->sc_swvol = p->gain;
 	}
 
 	if (SPECIFIED(r->gain)) {
-		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
+		if (sc->sc_recopens == 1 || !sc->sc_usemixer ||
+						 vc == &sc->sc_mixring) {
 			au_get_gain(sc, &sc->sc_inports, &gain, &balance);
 			error = au_set_gain(sc, &sc->sc_inports, r->gain, balance);
 			if (error)
 				goto cleanup;
-		} else
+		}
+		if (sc->sc_usemixer)
 			vc->sc_recswvol = r->gain;
 	}
 
 	if (SPECIFIED_CH(p->balance)) {
-		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
+		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
+						 vc == &sc->sc_mixring) {
 			au_get_gain(sc, &sc->sc_outports, &gain, &balance);
 			error = au_set_gain(sc, &sc->sc_outports, gain, p->balance);
 			if (error)
@@ -4783,7 +4788,8 @@ done:
 		}
 	}
 	if (SPECIFIED_CH(r->balance)) {
-		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
+		if (sc->sc_recopens == 1 || !sc->sc_usemixer ||
+						 vc == &sc->sc_mixring) {
 			au_get_gain(sc, &sc->sc_inports, &gain, &balance);
 			error = au_set_gain(sc, &sc->sc_inports, gain, r->balance);
 			if (error)
@@ -4932,13 +4938,17 @@ audiogetinfo(struct audio_softc *sc, str
 		r->avail_ports = sc->sc_inports.allports;
 		p->avail_ports = sc->sc_outports.allports;
 
-		if (!sc->sc_usemixer || vc == &sc->sc_mixring) {
+		if (sc->sc_recopens == 1 || !sc->sc_usemixer ||
+						 vc == &sc->sc_mixring) {
 			au_get_gain(sc, &sc->sc_inports, &r->gain, &r->balance);
+		} else
+			r->gain = vc->sc_recswvol;
+
+		if (sc->sc_opens == 1 || !sc->sc_usemixer ||
+						 vc == &sc->sc_mixring) {
 			au_get_gain(sc, &sc->sc_outports, &p->gain, &p->balance);
-		} else {
+		} else
 			p->gain = vc->sc_swvol;
-			r->gain = vc->sc_recswvol;
-		}
 	}
 
 	if (sc->sc_monitor_port != -1 && buf_only_mode == 0) {


Home | Main Index | Thread Index | Old Index