diff options
Diffstat (limited to 'plugins/alsa/alsa-core-ctl.c')
-rw-r--r-- | plugins/alsa/alsa-core-ctl.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/alsa/alsa-core-ctl.c b/plugins/alsa/alsa-core-ctl.c index 020c13c..e747090 100644 --- a/plugins/alsa/alsa-core-ctl.c +++ b/plugins/alsa/alsa-core-ctl.c @@ -232,6 +232,7 @@ PUBLIC int CtlElemIdSetLong(SoftMixerT *mixer, AlsaSndCtlT *sndcard, snd_ctl_ele snd_ctl_elem_info_t *elemInfo; const char* name; int error, numid; + long min, max; snd_ctl_elem_info_alloca(&elemInfo); snd_ctl_elem_info_set_id(elemInfo, elemId); @@ -247,6 +248,19 @@ PUBLIC int CtlElemIdSetLong(SoftMixerT *mixer, AlsaSndCtlT *sndcard, snd_ctl_ele error = snd_ctl_elem_read(sndcard->ctl, elemData); if (error) goto OnErrorExit; + switch(snd_ctl_elem_info_get_type(elemInfo)) { + case SND_CTL_ELEM_TYPE_INTEGER: + min = snd_ctl_elem_info_get_min(elemInfo); + max = snd_ctl_elem_info_get_max(elemInfo); + + value = (value < min) ? min : value; + value = (value > max) ? max : value; + break; + + default: + break; + } + for (int index = 0; index < count; index++) { snd_ctl_elem_value_set_integer(elemData, index, value); } |