[pulseaudio-discuss] pactl percentage bug fix
Sean Greenslade
sean at seangreenslade.com
Sat Jun 4 07:48:57 UTC 2022
On Fri, Jun 03, 2022 at 06:19:20PM +0100, Patrick May wrote:
> Here is the problem:
>
> https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/utils/pactl.c
>
> In src/utils/pactl.c:
>
> Between line 2530 and line 2535, in function parse_volume:
>
> These two 'if' statements will BOTH execute if the input string contains
> both a '.' and ends with a '%'.
>
> This results in vol_flags having VOL_PERCENT and VOL_LINEAR or'd in and set,
> which is equivalent in effect to '*vol_flags |= VOL_DECIBEL'
> (because VOL_PERCENT is 1 and VOL_LINEAR is 2, and VOL_DECIBEL is 3. Refer
> to line 76)
> So from then on the function is erroneously acting as if the input string
> was a decibel value, instead of a percentage.
>
> Suggested fix:
> Change line 2532 from this
> if (pa_endswith(vs, "%")) {
> To this:
> else if (pa_endswith(vs, "%")) {
>
> I apologise for my rudeness earlier but this was not the first time
> pulseaudio bugs have BLASTED EXTREMELY LOUD NOISE AT 100% THROUGH MY
> HEADPHONES and I was very upset.
>
> I don't have a git account or any of the stuff necessary to actually submit
> a patch so I would appreciate if someone or pulseaudio dev would take note
> of this and make the necessary change
I dug into this issue and found a couple of different bugs in this code.
I've submitted a merge request with my fixes:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/716
While debugging, I did notice another issue that I was uncertain of how
to solve. The detection of absolute values vs. relative values is based
on the presence of a plus or minus at the start of the value. This is
fine for everything except decibels, since absolute decibel values will
often be negative numbers. The way the code sits now, it's impossible to
pass an absolute negative decibel value. Probably not a huge deal, but
it seemed worth pointing out.
--Sean
More information about the pulseaudio-discuss
mailing list