diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-05-21 17:14:22 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-05-25 13:24:34 +0900 |
commit | e1b2705c5dc6c888924dda8f57c88edeb43494ba (patch) | |
tree | cd5bd817bfcec80166b7192bbfa648cafe77e88d | |
parent | bc9049aa6f9297a4927ec6e5720bd38276660309 (diff) | |
download | tdemultimedia-e1b2705c5dc6c888924dda8f57c88edeb43494ba.tar.gz tdemultimedia-e1b2705c5dc6c888924dda8f57c88edeb43494ba.zip |
KMix: fixed rounding error on volume reading. This was preventing 1% volume increase steps from working properly.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | kmix/kmix.h | 2 | ||||
-rw-r--r-- | kmix/mixer.cpp | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/kmix/kmix.h b/kmix/kmix.h index e24c457a..c41beb65 100644 --- a/kmix/kmix.h +++ b/kmix/kmix.h @@ -65,7 +65,7 @@ KMixWindow : public TDEMainWindow, virtual public KMixIface void setVolume(int percentage); void increaseVolume(int percentage); void decreaseVolume(int percentage); - int volume(); + int volume(); void setAbsoluteVolume(long absoluteVolume); long absoluteVolume(); diff --git a/kmix/mixer.cpp b/kmix/mixer.cpp index d8e93fc4..150b196d 100644 --- a/kmix/mixer.cpp +++ b/kmix/mixer.cpp @@ -570,7 +570,9 @@ int Mixer::volume( int deviceidx ) } else { - return ( vol.getVolume( Volume::LEFT )*100) / volumeRange ; + // Make sure to round correctly, otherwise the volume level will always be 1% too low + // and increments of 1% of top of the value read will result in no change to the actual level + return ((100.0 * vol.getVolume(Volume::LEFT) + volumeRange / 2) / volumeRange); } } |