[alsa-devel] snd_mixer_selem_get_playback_volume return value outside allowed range

Raymond Yau superquad.vortex2 at gmail.com
Tue Jun 22 03:41:17 CEST 2010


2010/6/19 Colin Guthrie <gmane at colin.guthr.ie>

> 'Twas brillig, and Raymond Yau at 19/06/10 03:39 did gyre and gimble:
> > 2010/6/17 Clemens Ladisch <clemens at ladisch.de>
> >
> >> Raymond Yau wrote:
> >>> Should snd_mixer_selem_get_playback_volume() perform range check ?
> >>
> >> No, it's the responsibility of the control implementation to return
> >> valid values (and to check that values that are being set are valid).
> >>
> >>
> >> Regards,
> >> Clemens
> >> _
>


It is OK to clamp the volume so that the volume bar would not distort the
layout

but the display percentage under the volume bar is clamp to 100% and this
will mislead the user that alsamixer hangs since pressing up and down arrow
cannot change 100% to 101% or 100% to 90% ( displayed percentage remain at
100% for a very long time)

        value = ((volumes[0] - min) * 100 + (max - min) / 2) / (max - min);
        if (!(control->flags & HAS_VOLUME_1)) {
            sprintf(buf, "%d", value);
            display_string_in_field(values_y, frame_left - 2, buf, 8,
ALIGN_CENTER);
        } else {
            mvwprintw(mixer_widget.window, values_y, frame_left - 2, "%3d",
value);
            if (control->flags & IS_ACTIVE)
                wattrset(mixer_widget.window, attr_ctl_frame);
            waddstr(mixer_widget.window, "<>");
            if (control->flags & IS_ACTIVE)
                wattrset(mixer_widget.window, attr_mixer_active);
            value = ((volumes[1] - min) * 100 + (max - min) / 2) / (max -
min);
            wprintw(mixer_widget.window, "%-3d", value);
        }


More information about the Alsa-devel mailing list