[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 2 commits: alsa-mixer: disable has_dB if max_dB is negative
PulseAudio Marge Bot
gitlab at gitlab.freedesktop.org
Mon Jan 18 15:50:08 UTC 2021
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
10ac01a2 by Benjamin Valentin at 2021-01-18T17:36:12+02:00
alsa-mixer: disable has_dB if max_dB is negative
Volume scaling in dB mode is broken if max dB is negative.
I have a Nobsound USB amplifier (1908:2220) that reports a dB range
of -127.07 dB to -128 dB in Alsa.
While this is likely a driver/device bug, in my naive imagination
userspace wouldn't bother too much with the absolute values and just set
out_dB(percent) = min_dB + (max_dB - min_dB) * percent
However, this is not what PulseAudio is doing, instead max_dB is used
as base_volume with which the desired software volume is multiplied
while min_dB does not seem to be taken into account.
The result is that with this device only a tiny portion of the volume
slider is usable.
Setting it to 97% already reaches min_dB which effectively turns any
(software) audio knob to an on/off switch.
To work around this, simply set the has_dB flag to false if max_dB is
negative.
This falls back to using raw Alsa values (ranging from 0 - 255), now
the settings in pavucontrol perfectly mirror those in alsamixer.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/447>
- - - - -
ac7f2d96 by Tanu Kaskinen at 2021-01-18T17:40:28+02:00
alsa-mixer: Accept negative max_dB when using decibel fixes
Sometimes decibel fixes are used as a trick to set a maximum hardware
volume, and in these cases max_dB may be negative yet still valid.
Here's an example:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/292#note_671300
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/447>
- - - - -
1 changed file:
- src/modules/alsa/alsa-mixer.c
Changes:
=====================================
src/modules/alsa/alsa-mixer.c
=====================================
@@ -1711,6 +1711,14 @@ static bool element_probe_volume(pa_alsa_element *e, snd_mixer_elem_t *me) {
else
e->has_dB = snd_mixer_selem_get_capture_dB_range(me, &min_dB, &max_dB) >= 0;
+ /* Assume decibel data to be incorrect if max_dB is negative. */
+ if (e->has_dB && max_dB < 0 && !e->db_fix) {
+ pa_alsa_mixer_id_to_string(buf, sizeof(buf), &e->alsa_id);
+ pa_log_warn("The decibel volume range for element %s (%li dB - %li dB) has negative maximum. "
+ "Disabling the decibel range.", buf, min_dB, max_dB);
+ e->has_dB = false;
+ }
+
/* Check that the kernel driver returns consistent limits with
* both _get_*_dB_range() and _ask_*_vol_dB(). */
if (e->has_dB && !e->db_fix) {
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/4868fcf5f344af613172f61d9105c02f3f07e1ab...ac7f2d96c7fc2d83f4a9fd74724ceaa9a634fe72
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/4868fcf5f344af613172f61d9105c02f3f07e1ab...ac7f2d96c7fc2d83f4a9fd74724ceaa9a634fe72
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210118/1ede46d3/attachment.htm>
More information about the pulseaudio-commits
mailing list