]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: softvol: use position offset macro of TLV data
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 15 May 2018 12:36:38 +0000 (21:36 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 15 May 2018 16:03:13 +0000 (18:03 +0200)
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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_softvol.c

index 0eaeaceffd57890cfa961866247e188e7ccc2b56..f08208f8dbc9340b47b558b0a5c7f0d859646c26 100644 (file)
@@ -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);
 }