[alsa-lib][PATCH 5/6] pcm: softvol: use position offset macro of TLV data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 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);
 }
 
-- 
2.14.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux