[alsa-devel] alsactl adds volume controls?
Clemens Ladisch
clemens at ladisch.de
Fri Oct 8 16:42:25 CEST 2010
Colin Guthrie wrote:
> Hmm, just thinking about this (as I don't know the volume control logic
> particularly well in PA), the call snd_mixer_selem_set_playback_dB() is
> used with a dir argument of +1.
>
> From what I understand, this would allow me to say "set the volume to
> 50dB" and due to the +1 dir, it should select -46.499999 ( because -46.5
> mutes it).
>
> In this case however, the value of -99999.999dB is ultimately selected
> (aka 0).
>
> I'm wondering if the TLV fix actually affects how
> snd_mixer_selem_set_playback_dB() call works with the dir argument.
Uh, oh. snd_tlv_convert_from_dB() ignores the minimum-is-mute flag.
Please try this hack:
--- alsa-lib/src/control/tlv.c
+++ alsa-lib/src/control/tlv.c
@@ -335,6 +335,9 @@ int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax,
if (xdir > 0)
v += (max - min) - 1;
v = v / (max - min) + rangemin;
+ if (v == rangemin && xdir > 0 && (tlv[3] & 0x10000) &&
+ db_gain > SND_CTL_TLV_DB_GAIN_MUTE)
+ v++;
*value = v;
}
return 0;
More information about the Alsa-devel
mailing list