2010/6/19 Colin Guthrie gmane@colin.guthr.ie
'Twas brillig, and Raymond Yau at 19/06/10 03:39 did gyre and gimble:
2010/6/17 Clemens Ladisch clemens@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); }