A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset of TLV data. This commit applies a code optimization.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- src/pcm/pcm_softvol.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c index 0eaeacef..f08208f8 100644 --- a/src/pcm/pcm_softvol.c +++ b/src/pcm/pcm_softvol.c @@ -31,6 +31,8 @@ #include "pcm_local.h" #include "pcm_plugin.h"
+#include <sound/tlv.h> + #ifndef PIC /* entry for static linking */ const char *_snd_module_pcm_softvol = ""; @@ -708,10 +710,11 @@ static void snd_pcm_softvol_dump(snd_pcm_t *pcm, snd_output_t *out) static int add_tlv_info(snd_pcm_softvol_t *svol, snd_ctl_elem_info_t *cinfo) { unsigned int tlv[4]; - tlv[0] = SND_CTL_TLVT_DB_SCALE; - tlv[1] = 2 * sizeof(int); - tlv[2] = (int)(svol->min_dB * 100); - tlv[3] = (int)((svol->max_dB - svol->min_dB) * 100 / svol->max_val); + tlv[SNDRV_CTL_TLVO_TYPE] = SND_CTL_TLVT_DB_SCALE; + tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(int); + tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = (int)(svol->min_dB * 100); + tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] = + (int)((svol->max_dB - svol->min_dB) * 100 / svol->max_val); return snd_ctl_elem_tlv_write(svol->ctl, &cinfo->id, tlv); }