Add a variable to track whether the actual volume is set or not.
Suppose this:
min volume: -126 max volume: 0
then when user wants to set some constant volume to -10, it would fail.
While the alsa values are typically positive, some values are "funky"
and have negative values. It is desirable to fix this at the alsa
level so that the numbers are positive, but it's not technically
invalid, and thus we have to support it.
Discussed here:
http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/9832
and
http://thread.gmane.org/gmane.linux.alsa.devel/85459
snd_mixer_selem_id_t *sid = NULL;
int r = 0;
long volume = -1;
+ pa_bool_t volume_set = FALSE;
pa_assert(m);
pa_assert(e);
switch (e->volume_use) {
case PA_ALSA_VOLUME_OFF:
volume = e->min_volume;
+ volume_set = TRUE;
break;
case PA_ALSA_VOLUME_ZERO:
long dB = 0;
volume = decibel_fix_get_step(e->db_fix, &dB, +1);
+ volume_set = TRUE;
}
break;
case PA_ALSA_VOLUME_CONSTANT:
volume = e->constant_volume;
+ volume_set = TRUE;
break;
default:
pa_assert_not_reached();
}
- if (volume >= 0) {
+ if (volume_set) {
if (e->direction == PA_ALSA_DIRECTION_OUTPUT)
r = snd_mixer_selem_set_playback_volume_all(me, volume);
else