diff --git a/NEWS b/NEWS index 9ee17962a..190ef1015 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.20.17 (not yet released) * output - alsa: fix crash bug with 8 channels +* mixer + - alsa: fix rounding error at volume 0 * fix real-time and idle scheduling with Musl * Android - fix compatibility with Android 4.0 diff --git a/src/mixer/plugins/volume_mapping.c b/src/mixer/plugins/volume_mapping.c index 4e559cf54..2078d346d 100644 --- a/src/mixer/plugins/volume_mapping.c +++ b/src/mixer/plugins/volume_mapping.c @@ -139,6 +139,13 @@ static int set_normalized_volume(snd_mixer_elem_t *elem, return set_raw[ctl_dir](elem, value); } + /* two special cases to avoid rounding errors at 0% and + 100% */ + if (volume <= 0) + return set_dB[ctl_dir](elem, min, dir); + else if (volume >= 100) + return set_dB[ctl_dir](elem, max, dir); + if (use_linear_dB_scale(min, max)) { value = lrint_dir(volume * (max - min), dir) + min; return set_dB[ctl_dir](elem, value, dir);