Re: [pulseaudio-discuss] pactl percentage bug fix

2022-06-04 Thread Patrick May

I tested it with

pactl -- set-sink-volume 0 0db

and it sets the volume to 100%. So the ability to specify absolute 
decibel values is only useful if you like blasting stuff at greater than 
or equal to 100% volume


On 04/06/2022 08:48, Sean Greenslade wrote:


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



Re: [pulseaudio-discuss] pactl percentage bug fix

2022-06-04 Thread Sean Greenslade
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