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



The following reply was made to PR kern/52781; it has been noted by GNATS.

From: Nathanial Sloss <nat%netbsd.org@localhost>
To: matthew green <mrg%eterna.com.au@localhost>
Cc: gnats-bugs%netbsd.org@localhost,
 kern-bug-people%netbsd.org@localhost,
 gnats-admin%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost,
 bouyer%antioche.eu.org@localhost,
 matthew green <mrg%eterna.com.au@localhost>
Subject: Re: kern/52781: audioctl can't set output gain
Date: Sun, 20 May 2018 18:59:16 +1000

 --Boundary-00=_mjTAbY2peAxnZyL
 Content-Type: Text/Plain;
   charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 
 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
 
 --Boundary-00=_mjTAbY2peAxnZyL
 Content-Type: text/x-patch;
   charset="ISO-8859-1";
   name="audio-1gain.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="audio-1gain.diff"
 
 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) {
 
 --Boundary-00=_mjTAbY2peAxnZyL--
 


Home | Main Index | Thread Index | Old Index