mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
pcm: softvol: 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
b0b720513e
commit
6dc2ed4090
1 changed files with 7 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue