mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	control: use position offset macro of TLV data
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>
This commit is contained in:
		
							parent
							
								
									5eb78219f6
								
							
						
					
					
						commit
						f61193c96c
					
				
					 4 changed files with 51 additions and 40 deletions
				
			
		| 
						 | 
				
			
			@ -938,10 +938,10 @@ int snd_ctl_elem_tlv_read(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
 | 
			
		|||
	 * and compare the returned value after ioctl for checking
 | 
			
		||||
	 * the validity of TLV.
 | 
			
		||||
	 */
 | 
			
		||||
	tlv[0] = -1;
 | 
			
		||||
	tlv[1] = 0;
 | 
			
		||||
	tlv[SNDRV_CTL_TLVO_TYPE] = -1;
 | 
			
		||||
	tlv[SNDRV_CTL_TLVO_LEN] = 0;
 | 
			
		||||
	err = snd_ctl_tlv_do(ctl, 0, id, tlv, tlv_size);
 | 
			
		||||
	if (err >= 0 && tlv[0] == (unsigned int)-1)
 | 
			
		||||
	if (err >= 0 && tlv[SNDRV_CTL_TLVO_TYPE] == (unsigned int)-1)
 | 
			
		||||
		err = -ENXIO;
 | 
			
		||||
	return err;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -967,7 +967,8 @@ int snd_ctl_elem_tlv_write(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
 | 
			
		|||
			   const unsigned int *tlv)
 | 
			
		||||
{
 | 
			
		||||
	assert(ctl && id && (id->name[0] || id->numid) && tlv);
 | 
			
		||||
	return snd_ctl_tlv_do(ctl, 1, id, (unsigned int *)tlv, tlv[1] + 2 * sizeof(unsigned int));
 | 
			
		||||
	return snd_ctl_tlv_do(ctl, 1, id, (unsigned int *)tlv,
 | 
			
		||||
			tlv[SNDRV_CTL_TLVO_LEN] + 2 * sizeof(unsigned int));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -991,7 +992,8 @@ int snd_ctl_elem_tlv_command(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
 | 
			
		|||
			     const unsigned int *tlv)
 | 
			
		||||
{
 | 
			
		||||
	assert(ctl && id && (id->name[0] || id->numid) && tlv);
 | 
			
		||||
	return snd_ctl_tlv_do(ctl, -1, id, (unsigned int *)tlv, tlv[1] + 2 * sizeof(unsigned int));
 | 
			
		||||
	return snd_ctl_tlv_do(ctl, -1, id, (unsigned int *)tlv,
 | 
			
		||||
			tlv[SNDRV_CTL_TLVO_LEN] + 2 * sizeof(unsigned int));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue