Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15, 6.3, 6.4, 6.5, 6.6, 6.7
-
None
Description
When using a value of 1.0 for a linear to logarithmic conversion, QAudio::convertVolume() returns an invalid result (around 0.99).
This is caused by the following formula:
return 1 - std::exp(-volume * LOG100);
While conceptually valid, the exception of 1 is not considered, while, interestingly enough, the opposite conversion does consider that possibility by returning 1 if the given value is >0.99.
This would lead to inconsistent results. For instance, considering the example in the convertVolume documentation, to convert the slider value to the player volume, a maximum volume (100, thus 1.0) will correctly set the player to 1, but if, for some reason, the slider needs to be set back based on the player volume, then the slider would be set to 99 instead of the expected 100.
Examples for which this is unreliable:
- store the volume with QSetting, which would make appropriate to save the player volume, instead of the slider value; when restoring the slider value based on the volume, it will be set to 99 instead of 100;
- accurate slider repositioning while moving (to display the exact volume "tick") for audio devices that do not provide continuous 0-100 ranges, based on the real volume set;
Right now I just skip the conversion if the source is 1.0, but I still believe that the function should be fixed with the 1.0 exception.