Bug 487508

Summary: Max volume is now 153% when changed via the slider in the widget (but not via keyboard shortcut)
Product: [Plasma] plasma-pa Reporter: Dashon <dashonwwIII>
Component: appletAssignee: Nate Graham <nate>
Status: RESOLVED FIXED    
Severity: normal CC: dashonwwIII, dmatteo002, isma.af, me, nate
Priority: NOR Keywords: regression
Version: git-stable-Plasma/6.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 6.1.0
Sentry Crash Report:
Attachments: Video of the slider going up to 153%

Description Dashon 2024-05-25 00:43:53 UTC
SUMMARY
Hey, I was testing out plasma 6.1 beta on Arch and I noticed that when you raise the maximum volume and then turn it up to max. It seems to top off a 153% now instead of the usual 150%. Just seemed kinda odd to have that extra 3%.

STEPS TO REPRODUCE
1. Open the plasma volume applet.
2. Click the raise maximum volume toggle.
3. Turn volume up to max.

OBSERVED RESULT
Max volume is 153%

EXPECTED RESULT
Max Volume should be 150%

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS 
KDE Plasma Version: 6.0.90
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1
Kernel Version: 6.9.1-zen1-2-zen (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 62.7 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3080/PCIe/SSE2
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7C95
System Version: 1.0
Comment 1 dmatteo002 2024-05-28 20:08:01 UTC
Can confirm the issue.

Operating System: Arch Linux 
KDE Plasma Version: 6.0.90
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1
Kernel Version: 6.9.2-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 2 Nate Graham 2024-06-07 13:54:54 UTC
I cannot reproduce this issue when I raise the volume using my keyboard's volume up key. Some questions:
1. How are you raising the volume; via that method, or a different one?
2. Can you attach a screen recording that shows the issue happening?
3. Can you attach a file with the contents of `pactl list`?
Comment 3 Dashon 2024-06-07 13:57:20 UTC
(In reply to Nate Graham from comment #2)
> I cannot reproduce this issue when I raise the volume using my keyboard's
> volume up key. Some questions:
> 1. How are you raising the volume; via that method, or a different one?
> 2. Can you attach a screen recording that shows the issue happening?
> 3. Can you attach a file with the contents of `pactl list`?

I'm raising it using the volume slider in the panel applet. I'll try to provide the the other info when I return home.
Comment 4 Nate Graham 2024-06-07 14:04:38 UTC
Aha! I can reproduce the issue when setting the volume via the slider. So no need for the rest of that information I requested, since I can now reproduce it myself.
Comment 5 dmatteo002 2024-06-07 14:10:21 UTC
Created attachment 170228 [details]
Video of the slider going up to 153%

For me it also does that only using the slider. That does not happen when using keyboard shortcut.
Comment 6 Ismael Asensio 2024-06-07 14:22:50 UTC
Also note that this value is provided by pulseaudio as the recomended maximum volumen presented to the user, which is set to +11dB (increment from the normal 0dB or 100%). This correspond to 153%, which is so close to 150% that might feel weird or a bug, but it is the result of converting between log and linear units.

See: https://www.freedesktop.org/software/pulseaudio/doxygen/volume_8h.html#a353b44010677b005abd390af732eb86e 

So this would be technically an upstream issue, but not a bug. Now, as a "consumer" of the library, we could fix the value to exactly 150% in PulseAudioQt, disregarding the upstream recommendation.
Comment 7 Nate Graham 2024-06-10 21:51:05 UTC
So the problem here is that maximum extended volume / maximum normal volume no longer equals a nice clean 1.5 like it used to:

Maximum extended volume: 99957
Maximum normal volume: 65536

Divide one by the other and you get 1.525. Multiply that by 100 to get a percent and then round it, and you've got a UI that says 153%.
Comment 8 Nate Graham 2024-06-10 22:29:39 UTC
Consulted with Ismael on this. The change that caused this to happen in Plasma 6 is that we moved to getting the data from PulseAudioQt instead of a locally vendored copy. Using the upstream volume values gives us a maximum value that's 153% due to aforementioned differences linear (percentage) and logarithmic (decibel) units.
Comment 9 Bug Janitor Service 2024-06-10 23:06:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-pa/-/merge_requests/267
Comment 10 Ismael Asensio 2024-06-11 18:15:32 UTC
Git commit 95abf2bd2df5e674c78960579de5684ee2dad5f3 by Ismael Asensio.
Committed on 11/06/2024 at 18:13.
Pushed by iasensio into branch 'master'.

Set Maximum Volume to 150%

The maximum UI value suggested by PulseAudio (PA_VOLUME_UI_MAX)
results in 153% (11dB), which can be seen (and reported) as a bug

See: https://www.freedesktop.org/software/pulseaudio/doxygen/volume_8h.html
FIXED-IN: 6.1

M  +3    -1    src/qml/plugin.cpp

https://invent.kde.org/plasma/plasma-pa/-/commit/95abf2bd2df5e674c78960579de5684ee2dad5f3
Comment 11 Ismael Asensio 2024-06-11 18:18:22 UTC
Git commit 383f275e06ce5b5d20c9dff3976be24fe986582d by Ismael Asensio.
Committed on 11/06/2024 at 18:16.
Pushed by iasensio into branch 'Plasma/6.1'.

Set Maximum Volume to 150%

The maximum UI value suggested by PulseAudio (PA_VOLUME_UI_MAX)
results in 153% (11dB), which can be seen (and reported) as a bug

See: https://www.freedesktop.org/software/pulseaudio/doxygen/volume_8h.html
FIXED-IN: 6.1


(cherry picked from commit 95abf2bd2df5e674c78960579de5684ee2dad5f3)

Co-authored-by: Ismael Asensio <isma.af@gmail.com>

M  +3    -1    src/qml/plugin.cpp

https://invent.kde.org/plasma/plasma-pa/-/commit/383f275e06ce5b5d20c9dff3976be24fe986582d