]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsamixer: fix division by zero
authorClemens Ladisch <clemens@ladisch.de>
Fri, 19 Feb 2010 16:07:20 +0000 (17:07 +0100)
committerClemens Ladisch <clemens@ladisch.de>
Fri, 19 Feb 2010 16:07:20 +0000 (17:07 +0100)
The attempt to divide by max-min fails if a control has only one valid
value.  In this case, adjust the maximum so that the computation can
succeed; the control will look like 0%.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
alsamixer/mixer_display.c

index 9eadcc9a4b92aab43e8b49a5d3dfceaf0a8489d6..260c9b03bb15b871c06a5d83fb64552ccb6060ae 100644 (file)
@@ -462,6 +462,8 @@ static void display_control(unsigned int control_index)
                        err = snd_mixer_selem_get_capture_volume_range(control->elem, &min, &max);
                if (err < 0)
                        return;
+               if (min == max)
+                       max = min + 1;
 
                if (control->flags & IS_ACTIVE)
                        wattrset(mixer_widget.window, 0);