[alsa-devel] [PATCH v2 04/13] topology: Add text section parser.

Takashi Iwai tiwai at suse.de
Wed Jul 1 18:03:27 CEST 2015


At Wed,  1 Jul 2015 14:44:26 +0100,
Liam Girdwood wrote:
> 
> +static int parse_text_values(snd_config_t *cfg, struct tplg_elem *elem)
> +{
> +	snd_config_iterator_t i, next;
> +	snd_config_t *n;
> +	const char *value = NULL;
> +	int j = 0;
> +
> +	tplg_dbg(" Text Values: %s\n", elem->id);
> +
> +	snd_config_for_each(i, next, cfg) {
> +		n = snd_config_iterator_entry(i);
> +
> +		if (j == SND_SOC_TPLG_NUM_TEXTS) {
> +			tplg_dbg("error: text string number exceeds %d\n", j);
> +			return -ENOMEM;
> +		}
> +
> +		/* get value */
> +		if (snd_config_get_string(n, &value) < 0)
> +			continue;
> +
> +		strncpy(&elem->texts[j][0], value,
> +			SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
> +		elem->texts[j][SNDRV_CTL_ELEM_ID_NAME_MAXLEN - 1] = 0;

There are multiple calls like this, so maybe it's worth to create a
simple helper to copy the ctl element id string instead of open coding
at each place.


Takashi


More information about the Alsa-devel mailing list