[nas] [PATCH] changed method of setting the input gain
Erik Auerswald
auerswal at unix-ag.uni-kl.de
Thu Jul 27 20:50:29 MDT 2006
Hi,
On Thu, Jul 27, 2006 at 06:13:58PM -0600, Jon Trulson wrote:
> On Thu, 27 Jul 2006, Erik Auerswald wrote:
> >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:
> >>>>>> - i want nas to always use *and report* the current mixer
> >>>>>> settings.
> [...]
>
> I have applied this patch.
Attached patch contains some corrections to this:
- error handling if ioctl() fails
- correct detection if ioctl() failed
- inverse gainScale handling
- added gainScale handling to input gain (to have consistent behaviour)
- updated documentation for effect of not having a mixer open
- added documentation for default values
- corrected default value of ReleaseDevice in gram.y
> Surprise, the SEGV is gone too :) Actually, I had already
> determined that it was a compiler optimization bug with it's
> attempt to inline initMixer.
:-)
Erik
-------------- next part --------------
Index: server/nasd.conf.eg
===================================================================
--- server/nasd.conf.eg (revision 170)
+++ server/nasd.conf.eg (working copy)
@@ -7,7 +7,7 @@
# set this to 0 for no debugging, a larger number equals more debugging
-# info...
+# info... (defaults to 0)
Debug 0
# be verbose, comment out if you don't want it
@@ -15,19 +15,23 @@
# set this to "yes" or "no" to indicate whether nasd should release the
# audio device when finished playing a sound.
+# defaults to "yes"
# Only the voxware, hpux, and sun servers understand this for now.
ReleaseDevice "yes"
# set this to "yes" or "no" to indicate whether nasd should keep the mixer
# device open when releasing the audio device.
+# defaults to "yes"
# Only the voxware server understands this for now.
KeepMixer "yes"
# init the mixer on startup? Voxware only.
+# defaults to "yes"
MixerInit "yes"
# 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"
OutDevType "EXT"
# These are all used by voxware, nowhere else yet.
Index: server/nasd.conf.man
===================================================================
--- server/nasd.conf.man (revision 170)
+++ server/nasd.conf.man (working copy)
@@ -21,25 +21,28 @@
.PP
.B verbose
Sets a flag telling the server to report what it's trying to do with each
-setting in the config file.
+setting in the config file. This option is off by default.
.PP
.B debug <number>
Sets the debug flag, which will provide a trace of the server's activities
on stderr. Set <num> to 0 to disable debug messages, 99 for *alot* of
-debug messages.
+debug messages. This option defaults to 0.
.PP
.B ReleaseDevice "YES" | "NO"
Set to "YES" or "NO". Defines whether the server should release the audio
-device when finished playing or recording a sound. (voxware, hpux, sun)
+device when finished playing or recording a sound. This option defaults
+to "YES". (voxware, hpux, sun)
.PP
.B KeepMixer "YES" | "NO"
Set to "YES" or "NO". Defines whether the server should keep the mixer open
-when releasing the audio device. (voxware)
+when releasing the audio device. Without an open mixer device the
+server will always report the default gain and line mode and cannot change
+them either. This option defaults to "YES". (voxware)
.PP
.B MixerInit "YES" | "NO"
Set to "YES" or "NO". Defines whether the server will init the mixer
device on startup. Later changes of gain or input mode will change the
-mixer settings. (voxware)
+mixer settings. This option defaults to "YES". (voxware)
.PP
.B OutDevType "EXT" | "INT"
For HPUX servers, define to "EXT" to use the external output device
@@ -65,7 +68,7 @@
.B gainscale number
This factor (expressed as a percentage) is applied to all volume-setting
requests. This lets the server transparently limit the actual
-maximum volume that can be set by clients.
+maximum volume that can be set by clients. The default is 100.
.PP
.B maxrate number
The maximum number of samples per second that we'll drive the
Index: server/dda/voxware/auvoxware.c
===================================================================
--- server/dda/voxware/auvoxware.c (revision 170)
+++ server/dda/voxware/auvoxware.c (working copy)
@@ -359,12 +359,17 @@
osLogMsg("readMixerOutputGain: "
"%s: ioctl(%d, MIXER_READ(SOUND_MIXER_PCM)) failed: %s\n",
sndStatOut.mixer, mixerfd, strerror(errno));
+ return sndStatOut.gain;
}
- pcm_level = pcm_level >> 8;
} else {
- pcm_level = sndStatOut.gain;
+ return sndStatOut.gain;
}
+ pcm_level = ((pcm_level & 0xFF) + (pcm_level >> 8)) / 2;
+ if (sndStatOut.gainScale) {
+ pcm_level *= 100;
+ pcm_level /= sndStatOut.gainScale;
+ }
return pcm_level;
}
@@ -378,12 +383,13 @@
osLogMsg("readMixerInputMode: "
"%s: ioctl(%d, MIXER_READ(SOUND_MIXER_RECSRC)) failed: "
"%s\n", sndStatOut.mixer, mixerfd, strerror(errno));
+ return 1<<SOUND_MIXER_LINE;
}
if (!(input_mode & (SOUND_MASK_MIC | SOUND_MIXER_LINE))) {
- input_mode = 1<<SOUND_MIXER_LINE;
+ return 1<<SOUND_MIXER_LINE;
}
} else {
- input_mode = 1<<SOUND_MIXER_LINE;
+ return 1<<SOUND_MIXER_LINE;
}
return input_mode;
@@ -400,55 +406,61 @@
if (mixerfd != -1) {
switch (recControlMode) {
case useMixerIGain:
- if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_IGAIN),&in_level) != -1) {
+ if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_IGAIN),&in_level) == -1) {
osLogMsg("readMixerInputGain: %s: "
"ioctl(MIXER_READ(SOUND_MIXER_IGAIN)) failed: %s\n",
sndStatOut.mixer, strerror(errno));
+ return sndStatIn.gain;
}
- in_level = in_level >> 8;
break;
case useMixerRecLev:
- if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_RECLEV),&in_level) != -1){
+ if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_RECLEV),&in_level) == -1){
osLogMsg("readMixerInputGain: "
"%s: ioctl(%d, MIXER_READ(SOUND_MIXER_RECLEV)) failed:"
" %s\n", sndStatOut.mixer, mixerfd, strerror(errno));
+ return sndStatIn.gain;
}
- in_level = in_level >> 8;
break;
case useMixerLineMic:
if (recsrc & SOUND_MASK_LINE) {
if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_LINE), &in_level)
- != -1) {
+ == -1) {
osLogMsg("readMixerInputGain: "
"%s: ioctl(%d, MIXER_READ(SOUND_MIXER_LINE)) "
"failed: %s\n",
sndStatOut.mixer, mixerfd, strerror(errno));
+ return sndStatIn.gain;
}
- in_level = in_level >> 8;
} else if (recsrc & SOUND_MASK_MIC) {
if (ioctl(mixerfd, MIXER_READ(SOUND_MIXER_MIC), &in_level)
- != -1) {
+ == -1) {
osLogMsg("readMixerInputGain: "
"%s: ioctl(%d, MIXER_READ(SOUND_MIXER_MIC)) "
"failed: %s\n",
sndStatOut.mixer, mixerfd, strerror(errno));
+ return sndStatIn.gain;
}
- in_level = in_level >> 8;
} else {
- in_level = sndStatIn.gain;
+ return sndStatIn.gain;
}
break;
default:
osLogMsg("readMixerInputGain: "
"unknown value %d of recControlMode\n", recControlMode);
+ return sndStatIn.gain;
}
} else {
- in_level = sndStatIn.gain;
+ return sndStatIn.gain;
}
+ in_level = ((in_level & 0xFF) + (in_level >> 8)) / 2;
+ if (sndStatIn.gainScale) {
+ in_level *= 100;
+ in_level /= sndStatIn.gainScale;
+ }
return in_level;
}
@@ -465,7 +477,7 @@
osLogMsg("mixerInputModeToNAS: input mode %d is neither LINE (%d) "
"nor MIC (%d)\n", input_mode, SOUND_MASK_LINE, SOUND_MASK_MIC);
- return AuDeviceInputModeNone;
+ return AuDeviceInputModeLineIn;
}
static int
@@ -1078,6 +1090,11 @@
else
inputAttenuation = 100;
+ if (sndStatIn.gainScale) {
+ inputAttenuation *= sndStatIn.gainScale;
+ inputAttenuation /= 100;
+ }
+
if (lineMode == AuDeviceLineModeHigh) {
recsrc = SOUND_MASK_MIC & recmask;
} else if (lineMode == AuDeviceLineModeLow) {
Index: server/dia/gram.y
===================================================================
--- server/dia/gram.y (revision 170)
+++ server/dia/gram.y (working copy)
@@ -55,8 +55,8 @@
j = parsebool($2);
if (j == -1) {
- /* error - default to no */
- NasConfig.DoDeviceRelease = FALSE;
+ /* error - default to yes */
+ NasConfig.DoDeviceRelease = TRUE;
} else
NasConfig.DoDeviceRelease = j;
}
More information about the Nas
mailing list