[nas] [PATCH] consistent gain setting in voxware server

Erik Auerswald auerswal at unix-ag.uni-kl.de
Thu Jul 20 12:07:16 MDT 2006


Hi,

On Wed, Jul 19, 2006 at 11:08:11PM -0600, Jon Trulson wrote:
> On Thu, 20 Jul 2006, Erik Auerswald wrote:
> >On Wed, Jul 12, 2006 at 10:35:24PM -0600, Jon Trulson wrote:
> >>On Wed, 12 Jul 2006, Erik Auerswald wrote:
> >>>
> >>>P.S. I did not change the behaviour of setting the input gain because
> >>>this is implemented differently and I don't use NAS for input so I don't
> >>>know if it works correctly or not.
> >>>
> >>
> >>        Nice, I had noticed that that did not seem to be working
> >>        correctly :)  Applied.
> >
> >I just did some recording tests (on linux/x86, ALSA, kernel 2.6):
> >
> >- the input gain is only set when recording has already started
> > -> I'll write a patch to make this work just like the output gain
> 
>         Ok...

The attached patch implements this. Note that both audemo and aurecord
set input gain and line mode themselves, overriding any previous
changes. The changes can be observed when starting to play via the NAS
server since in- and output device are openend by the same function
everytime something is played or recorded.

Erik
-------------- next part --------------
Index: server/dda/voxware/auvoxware.c
===================================================================
--- server/dda/voxware/auvoxware.c	(revision 159)
+++ server/dda/voxware/auvoxware.c	(working copy)
@@ -220,7 +220,9 @@
 static AuBool  leave_mixer = 0;
 static AuBool  share_in_out = 0;
 
-static int      Letsplay;
+static int      Letsplay;       /* output gain */
+static int      Letsrecord;     /* input gain */
+static int      Recordfrom;     /* input line mode */
 static int      level[100];
 static int      mixerfd;	/* The mixer device */
 static int      devmask = 0;	/* Bitmask for supported mixer devices */
@@ -975,20 +977,47 @@
     inputAttenuation = g;
   else
     inputAttenuation = 100;
+
+  Letsrecord = inputAttenuation;
+  Recordfrom = lineMode;
   
   inputAttenuation = inputAttenuation << 8 | inputAttenuation;
   
   if (lineMode == AuDeviceLineModeHigh) {
-    ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_MIC), &inputAttenuation);
-    ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_LINE), &zero);
+    if (mixerfd != -1) {
+      ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_MIC), &inputAttenuation);
+      ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_LINE), &zero);
+    }
   }
  
   if (lineMode == AuDeviceLineModeLow) {
-    ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_LINE), &inputAttenuation);
-    ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_MIC), &zero);
+    if (mixerfd != -1) {
+      ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_LINE), &inputAttenuation);
+      ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_MIC), &zero);
+    }
   }
 }
 
+static AuFixedPoint
+getPhysicalInputGain(void)
+{
+    AuInt16         inputGain;
+
+    inputGain = Letsrecord;
+
+    return AuFixedPointFromSum(inputGain, 0);
+}
+
+static AuInt8
+getPhysicalLineMode(void)
+{
+    AuInt8          lineMode;
+
+    lineMode = Recordfrom;
+
+    return lineMode;
+}
+
 static void enableProcessFlow(void)
 {
   AuUint8        *p;
@@ -1002,6 +1031,8 @@
     {
       openDevice(AuTrue);
       setPhysicalOutputGain(getPhysicalOutputGain());
+      setPhysicalInputGainAndLineMode(getPhysicalInputGain(),
+                                      getPhysicalLineMode());
     }
 
 #ifdef sco


More information about the Nas mailing list