[alsa-cvslog] alsa-lib: ALSA library repository branch, master now at v1.0.23-8-g2a94d80
Brought to you by:
perex
From: <nor...@al...> - 2010-07-20 10:56:23
|
Hello, This is an automated email from the git hooks/update script, it was generated because a ref change was pushed to the repository. Updating branch, master, via 2a94d80407f620c256021707503b14377d4701d1 (commit) via d81ce4ea7af917f992aa0529c29db590d566ae7a (commit) via 16a2cad39b7ee29e34b92d39d72eebfc88f8dc22 (commit) from 191c57805a791925ab5992f127a1cb5f4ab56c9c (commit) - Log ----------------------------------------------------------------- commit 2a94d80407f620c256021707503b14377d4701d1 Author: Peter Ujfalusi <pet...@no...> AuthorDate: Tue Jul 20 10:34:54 2010 +0300 Commit: Takashi Iwai <ti...@su...> CommitDate: Tue Jul 20 12:56:03 2010 +0200 tlv: Remove tailing tab after snd_ctl_get_dB_range function Cosmetic fix. There was a tab instead of new line after snd_ctl_get_dB_range function. Signed-off-by: Peter Ujfalusi <pet...@no...> Signed-off-by: Takashi Iwai <ti...@su...> commit d81ce4ea7af917f992aa0529c29db590d566ae7a Author: Peter Ujfalusi <pet...@no...> AuthorDate: Tue Jul 20 10:34:53 2010 +0300 Commit: Takashi Iwai <ti...@su...> CommitDate: Tue Jul 20 12:55:51 2010 +0200 tlv: Handle 'holes' in SND_CTL_TLVT_DB_RANGE array When converting from dB to raw value, and DB_RANGE is used with non overlapping map, dB value in between the sub ranges will be not found. For example, if the control has the following: 0: -10dB 1: -5dB 2: 0dB 3: 2dB 4: 4dB static const unsigned int nonoverlapping_tlv[] = { TLV_DB_RANGE_HEAD(2), 0, 2, TLV_DB_SCALE_ITEM(-1000, 500, 0), 3, 4, TLV_DB_SCALE_ITEM(200, 200, 0), }; Range 1: -10 .. 0dB Range 2: 2 .. 4dB If user asks for 1dB the snd_tlv_convert_from_dB will not find the raw value, since the 1dB is not part of either range. To fix this, we will store the previous non maching range's maximum raw value. If the dB value is not found in the next range, we will check, if the requested dB value is in between the current and the previous range, and if it is than pick the apropriate raw value based on the xdir (up or down rounding). Signed-off-by: Peter Ujfalusi <pet...@no...> Signed-off-by: Takashi Iwai <ti...@su...> commit 16a2cad39b7ee29e34b92d39d72eebfc88f8dc22 Author: Peter Ujfalusi <pet...@no...> AuthorDate: Tue Jul 20 10:34:52 2010 +0300 Commit: Takashi Iwai <ti...@su...> CommitDate: Tue Jul 20 12:55:41 2010 +0200 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 <pet...@no...> Signed-off-by: Takashi Iwai <ti...@su...> ----------------------------------------------------------------------- Diffstat: src/control/tlv.c | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) Patch -------------- (max 1500 lines) diff --git a/src/control/tlv.c b/src/control/tlv.c index 0ff052e..ba52752 100644 --- a/src/control/tlv.c +++ b/src/control/tlv.c @@ -285,13 +285,24 @@ int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax, { switch (tlv[0]) { case SND_CTL_TLVT_DB_RANGE: { + long dbmin, dbmax, prev_rangemax; unsigned int pos, len; len = int_index(tlv[1]); if (len > MAX_TLV_RANGE_SIZE) 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; + prev_rangemax = 0; while (pos + 4 <= len) { - long dbmin, dbmax; rangemin = (int)tlv[pos]; rangemax = (int)tlv[pos + 1]; if (!snd_tlv_get_dB_range(tlv + pos + 2, @@ -301,6 +312,11 @@ int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax, return snd_tlv_convert_from_dB(tlv + pos + 2, rangemin, rangemax, db_gain, value, xdir); + else if (db_gain < dbmin) { + *value = xdir ? rangemin : prev_rangemax; + return 0; + } + prev_rangemax = rangemax; pos += int_index(tlv[pos + 3]) + 4; } return -EINVAL; @@ -426,7 +442,7 @@ int snd_ctl_get_dB_range(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, return snd_tlv_get_dB_range(info.tlv, info.minval, info.maxval, min, max); } - + /** * \brief Convert the volume value to dB on the given control element * \param ctl the control handler ------- End of patch hooks/update --- Git Source Code Management System hooks/update refs/heads/master \ 191c57805a791925ab5992f127a1cb5f4ab56c9c \ 2a94d80407f620c256021707503b14377d4701d1 |