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

Erik Auerswald auerswal at unix-ag.uni-kl.de
Fri Jul 28 21:47:58 MDT 2006


Hi,

On Wed, Jul 26, 2006 at 04:10:54AM +0200, Erik Auerswald wrote:
> On Tue, Jul 25, 2006 at 06:31:06PM -0600, Jon Trulson wrote:
> > On Tue, 25 Jul 2006, Paul Fox wrote:
> > >erik wrote:
> > >> On Mon, Jul 24, 2006 at 11:12:18PM -0400, Paul Fox wrote:
> 
> > >btw, i think i like the idea of having finer-grained boolean options,
> > >rather than a large set of mixerinit values.  but you two have a idea
> > >of how that should work, so i'll leave that up to you.
> > 
> >   Aww common!  I love yacc'ing around in config... :)
> 
> I'm in favour of finer grained boolean options whenever the controlled
> features are independent. I'm not too sure about the mixer (re-)
> initialization. We could use a MixerReInit option that does whatever is
> specified by MixerInit on any reopen of the audio device. But the
> combination MixerInit no, MixerReInit yes would be a bit strange.

The attached patch implements Jon's proposed mixer init mode 2. I
decided to use a new boolean variable because this way old configs are
still compatible. The default setting of the new option is off so the
behaviour stays the same for old configs.

Erik
-------------- next part --------------
Index: server/nasd.conf.eg
===================================================================
--- server/nasd.conf.eg	(revision 172)
+++ server/nasd.conf.eg	(working copy)
@@ -29,6 +29,12 @@
 # defaults to "yes"
 MixerInit	"yes"			
 
+# Initialize the mixer settings on every audio device open?
+# Settings are only initialized if MixerInit is set to "yes".
+# Voxware only.
+# defaults to "no"
+ReInitMixer "no"
+
 # This is used on hpux.  Set to "INT" to use the internal speaker,
 #  set to "EXT" to use the external device (headphone/speakers).
 # defaults to "EXT"
Index: server/nasd.conf.man
===================================================================
--- server/nasd.conf.man	(revision 172)
+++ server/nasd.conf.man	(working copy)
@@ -44,6 +44,12 @@
 device on startup. Later changes of gain or input mode will change the
 mixer settings. This option defaults to "YES". (voxware)
 .PP
+.B ReInitMixer "YES" | "NO"
+Set to "YES" or "NO". Defines whether the server will re-init the mixer
+device on every audio device open. The mixer is re-initialized only if it is
+initialized at startup (see \fBMixerInit\fR option). This option defaults
+to "NO". (voxware)
+.PP
 .B OutDevType "EXT" | "INT"
 For HPUX servers, define to "EXT" to use the external output device
 (headphone/speakers) or "INT" for the internal output device (internal
Index: server/dda/voxware/auvoxware.c
===================================================================
--- server/dda/voxware/auvoxware.c	(revision 172)
+++ server/dda/voxware/auvoxware.c	(working copy)
@@ -232,6 +232,7 @@
 static int stereodevs = 0;      /* Channels supporting stereo */
 
 int VOXMixerInit = TRUE;        /* overridden by nasd.conf */
+int VOXReInitMixer = FALSE;     /* overridden by nasd.conf */
 
 /* end of VOXware driver mixer control variables */
 
@@ -480,6 +481,13 @@
     return AuDeviceInputModeLineIn;
 }
 
+static void
+setMixerDefaults(void)
+{
+    setPhysicalOutputGain(auDefaultOutputGain);
+    setPhysicalInputGainAndLineMode(auDefaultInputGain, AuDeviceLineModeLow);
+}
+
 static int
 createServerComponents(AuUint32 * auServerDeviceListSize,
                        AuUint32 * auServerBucketListSize,
@@ -625,9 +633,7 @@
     if (!initialized) {
         initialized = AuTrue;
         if (!leave_mixer) {
-            setPhysicalOutputGain(auDefaultOutputGain);
-            setPhysicalInputGainAndLineMode(auDefaultInputGain,
-                                            AuDeviceLineModeLow);
+            setMixerDefaults();
         }
 
         /* JET - close the device if requested... only needs to happen
@@ -1194,6 +1200,9 @@
 
     if (relinquish_device) {
         openDevice(AuTrue);
+        if (VOXReInitMixer && VOXMixerInit) {
+            setMixerDefaults();
+        }
     }
 #ifdef sco
     if (!processFlowEnabled) {
Index: server/dda/voxware/config.c
===================================================================
--- server/dda/voxware/config.c	(revision 172)
+++ server/dda/voxware/config.c	(working copy)
@@ -13,6 +13,7 @@
 
 extern SndStat sndStatOut, sndStatIn, *confStat;
 extern int VOXMixerInit;
+extern int VOXReInitMixer;
 
 void
 ddaSetConfig(int token, void *value)
@@ -177,6 +178,12 @@
         VOXMixerInit = num;
         break;
 
+    case REINITMIXER:
+        num = (int) value;
+
+        VOXReInitMixer = num;
+        break;
+
     default:                   /* ignore any other tokens */
         if (NasConfig.DoDebug > 5)
             osLogMsg("config: ddaSetConfig() : unknown token %d, ignored\n", token);
Index: server/dia/lex.l
===================================================================
--- server/dia/lex.l	(revision 172)
+++ server/dia/lex.l	(working copy)
@@ -34,6 +34,7 @@
 [Mm][Ii][Xx][Ee][Rr]                    { return MIXER; }
 [Rr][Ee][Aa][Dd][Ww][Rr][Ii][Tt][Ee]    { return READWRITE; }
 [Mm][Ii][Xx][Ee][Rr][Ii][Nn][Ii][Tt]    { return MIXERINIT; }
+[Rr][Ee][Ii][Nn][Ii][Tt][Mm][Ii][Xx][Ee][Rr]    { return REINITMIXER; }
 [Oo][Uu][Tt][Dd][Ee][Vv][Tt][Yy][Pp][Ee]  { return OUTDEVTYPE; }
 [Ff][Oo][Rr][Cc][Ee][Rr][Aa][Tt][Ee]    { return FORCERATE; }
 [Aa][Uu][Tt][Oo][Oo][Pp][Ee][Nn]        { return AUTOOPEN; }
Index: server/dia/gram.y
===================================================================
--- server/dia/gram.y	(revision 172)
+++ server/dia/gram.y	(working copy)
@@ -29,7 +29,7 @@
 %token <num> MINFRAGS MAXRATE MINRATE NUMCHANS MIXER DEVICE NUMBER 
 %token <num> CDEBUG VERBOSE
 %token <num> READWRITE FORCERATE AUTOOPEN GAIN GAINSCALE
-%token <num> RELEASEDEVICE KEEPMIXER OUTDEVTYPE MIXERINIT
+%token <num> RELEASEDEVICE KEEPMIXER OUTDEVTYPE MIXERINIT REINITMIXER
 %token <ptr> STRING 
 
 %type <ptr> string
@@ -73,6 +73,8 @@
                         }
                 | MIXERINIT string
                         { ddaSetConfig(MIXERINIT, (void *)parsebool($2)); }  
+                | REINITMIXER string
+                        { ddaSetConfig(REINITMIXER, (void *)parsebool($2)); }  
                 | OUTDEVTYPE string
                         { ddaSetConfig(OUTDEVTYPE, (void *)$2); }  
                 ;


More information about the Nas mailing list