[alsa-lib][PATCH 4/6] pcm: hw: 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_hw.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 65b198c5..a728b23b 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1199,6 +1199,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
 	snd_ctl_t *ctl;
 	snd_ctl_elem_id_t id = {0};
 	unsigned int tlv[2048], *start;
+	unsigned int type;
 	snd_pcm_chmap_query_t **map;
 	int i, ret, nums;
 
@@ -1223,9 +1224,10 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
 	/* FIXME: the parser below assumes that the TLV only contains
 	 * chmap-related blocks
 	 */
-	if (tlv[0] != SND_CTL_TLVT_CONTAINER) {
-		if (!is_chmap_type(tlv[0])) {
-			SYSMSG("Invalid TLV type %d\n", tlv[0]);
+	type = tlv[SNDRV_CTL_TLVO_TYPE];
+	if (type != SND_CTL_TLVT_CONTAINER) {
+		if (!is_chmap_type(type)) {
+			SYSMSG("Invalid TLV type %d\n", type);
 			return NULL;
 		}
 		start = tlv;
@@ -1234,7 +1236,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
 		unsigned int *p;
 		int size;
 		start = tlv + 2;
-		size = tlv[1];
+		size = tlv[SNDRV_CTL_TLVO_LEN];
 		nums = 0;
 		for (p = start; size > 0; ) {
 			if (!is_chmap_type(p[0])) {
-- 
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