Skip to content

Round volume to avoid increasing or decreasing by more than stepSize

Nate Graham requested to merge ngraham/plasma-pa:round-volume into master

Sometimes when you increase or decrease the volume using the key on your keyboard or a global shortcut, it will change by more than the stepSize. For example when you're at 40% volume and go up when a stepSize of 5%, sometimes it will change to 46% volume, not 45%.

The reason for this is that the Volume number we get from PulseAudio and then manipulate is a float. So we have to round it down to avoid accumulating errors over time. The percentage display function already rounds, so let's do the same thing in the functions to increase and decrease the volume.

We should also use Math.floor() rather than Math.round() to ensure consistency in the values we're using.

BUG: 434769 FIXED-IN: 5.21.4

Merge request reports

Loading