mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-21 01:40:09 -05:00
tlv: Check out of range dB with SND_CTL_TLVT_DB_RANGE
When converting from dB value to raw value, the control's full range was not checked in case of SND_CTL_TLVT_DB_RANGE. Check out of range dB values, and return apropriate raw value for the caller. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
191c57805a
commit
16a2cad39b
1 changed files with 11 additions and 1 deletions
|
|
@ -285,13 +285,23 @@ int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax,
|
||||||
{
|
{
|
||||||
switch (tlv[0]) {
|
switch (tlv[0]) {
|
||||||
case SND_CTL_TLVT_DB_RANGE: {
|
case SND_CTL_TLVT_DB_RANGE: {
|
||||||
|
long dbmin, dbmax;
|
||||||
unsigned int pos, len;
|
unsigned int pos, len;
|
||||||
len = int_index(tlv[1]);
|
len = int_index(tlv[1]);
|
||||||
if (len > MAX_TLV_RANGE_SIZE)
|
if (len > MAX_TLV_RANGE_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
if (snd_tlv_get_dB_range(tlv, rangemin, rangemax,
|
||||||
|
&dbmin, &dbmax))
|
||||||
|
return -EINVAL;
|
||||||
|
if (db_gain <= dbmin) {
|
||||||
|
*value = rangemin;
|
||||||
|
return 0;
|
||||||
|
} else if (db_gain >= dbmax) {
|
||||||
|
*value = rangemax;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
pos = 2;
|
pos = 2;
|
||||||
while (pos + 4 <= len) {
|
while (pos + 4 <= len) {
|
||||||
long dbmin, dbmax;
|
|
||||||
rangemin = (int)tlv[pos];
|
rangemin = (int)tlv[pos];
|
||||||
rangemax = (int)tlv[pos + 1];
|
rangemax = (int)tlv[pos + 1];
|
||||||
if (!snd_tlv_get_dB_range(tlv + pos + 2,
|
if (!snd_tlv_get_dB_range(tlv + pos + 2,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue