2010/6/17 Takashi Iwai <tiwai@xxxxxxx> > At Thu, 17 Jun 2010 08:35:54 +0800, > Raymond Yau wrote: > > > > > > http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=c9b86f49a8a1a8c337bf0c1b7f12749e8be781ed > > > > your patch did not fix the buggy driver (e.g. alsa-pulse plugin) which > > return volume outside the alllowed range > > > > > > amixer -D pulse > > Simple mixer control 'Master',0 > > Capabilities: pvolume pswitch pswitch-joined > > Playback channels: Front Left - Front Right > > Limits: Playback 0 - 65536 > > Mono: > > Front Left: Playback 98304 [150%] [on] > > Front Right: Playback 98304 [150%] [on] > > > > > > > > > > Should snd_mixer_selem_get_playback_volume() perform range check ? > > > > tatic int get_volume_ops(snd_mixer_elem_t *elem, int dir, > > snd_mixer_selem_channel_id_t channel, long *value) > > { > > selem_none_t *s = snd_mixer_elem_get_private(elem); > > if (s->selem.caps & SM_CAP_GVOLUME) > > dir = SM_PLAY; > > if ((unsigned int) channel >= s->str[dir].channels) > > return -EINVAL; > > *value = s->str[dir].vol[channel]; > > + if (*value > s->str[dir].max) > > + return -EINVAL; > > + if (*value < s->str[dir].min) > > + return -EINVAL; > > return 0; > > Some sanity check would be nice, but returning -EINVAL here isn't > correct, at least. -EINVAL should be returned when the caller gives a > wrong value (e.g. a wrong channel value). > > > Takashi > But the application can use snd_mixer_selem_set_playback_volume_range() to set min and max of the control , is there any reason allow the application to set this range ? it seem that snd_mixer_selem_set_playback_volume did not performe any range check correct me if I am wrong, I seem able to use snd_mixer_selem_set_playback_volume to -1 for the pulse device and there is no error return , but I get another value when use snd_mixer_selem_get_playback_volume BTW, amixer has -nocheck option to bypass the range check but this option seem unable to set the value of "Master playback volume" toabove max _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel