[nas] [PATCH] changed method of setting the input gain

Erik Auerswald auerswal at unix-ag.uni-kl.de
Thu Jul 27 08:31:24 MDT 2006


Hi,

On Thu, Jul 27, 2006 at 09:01:28AM -0400, Paul Fox wrote:
> another couple of thoughts:
> 
> erik wrote:
>  > On Wed, Jul 26, 2006 at 04:10:54AM +0200, Erik Auerswald wrote:
>  > > > On Tue, 25 Jul 2006, Paul Fox wrote:
>  > > > >erik wrote:
>  > > > >> Several programs can use the mixer device at the same time so this
>  > > > >> should not be problematic.
>  ...
>  > > > >do you think it even needs to be configurable?  any reason not to
>  ...
>  > > I'd say it does not need to be configurable. I've just checked the OSS
>  > > programming manual and it's official that several programms can open the
>  > > mixer device at the same time. And I agree that a seperate boolean
>  > > should be used if it should be configurable nevertheless.
>  > 
>  > There was already a variable to control this (but no code did use it).
>  > The attached patch implements this config variable for the voxware
>  > server.
> 
> if neither of us thinks this needs to be configurable, so we
> really need the new configuration variable?  ;-)  it's fine if 
> you've decided its needed, but i'd rather not add knobs if we
> don't need them.

Since the variable does already exist I decided to use it:

[erik at fal nas-svn]$ grep -irF --exclude='*.svn-base' keepmixer server/
server/dda/voxware/auvoxware.c:    if (NasConfig.DoKeepMixer) {
server/dia/nasconf.h:    int DoKeepMixer;

If you two don't like it I can take it out again. I would then remove
the existing variable definitions from the code.

> i notice that when writing, we do this:
>     gusvolume = g | (g << 8);
>     if (mixerfd != -1)
>         if (ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_PCM), &gusvolume) == -1)
>             osLogMsg("setPhysicalOutputGain: "
>                      "%s: ioctl(MIXER_WRITE(SOUND_MIXER_PCM)) failed: %s\n",
>                      sndStatOut.mixer, strerror(errno));
> 
> but when reading, you do this:
>  > +        if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_PCM), &pcm_level) == -1) {
>  > +            osLogMsg("readMixerOutputGain: "
>  > +                     "%s: ioctl(%d, MIXER_READ(SOUND_MIXER_PCM)) failed: %s\n",
>  > +                     sndStatOut.mixer, mixerfd, strerror(errno));
>  > +        }
>  > +        pcm_level = pcm_level >> 8;
> 
> is this tossing out one channel of level?  (i need to find a
> voxware manual.) if so, i think that instead we should average
> the two channels, in case someone set them very differently:
>          gain = ((pcm_level & 0xff) + ((pcm_level >> 8 ) & 0xff)) / 2 ;
> or something like that.

Since the NAS server only knows one gain value (implicitely used for
both channels) an average is not really better than tossing away one
channel IMHO (indeed, I'm tossing away one channel). But if you prefer
the average I can incorporate this into the next patch version.

Erik



More information about the Nas mailing list