mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 02:35:43 +01:00
topology: pre-process-class: function to get attribute type
Add a helper function to get attribute type from the attribute definition and convert them to SND_CONFIG_TYPE_* values. When no type if provided for an attribute, type defaults to integer. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
0b0c16d4a7
commit
d8e9466e59
2 changed files with 34 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
The full GNU General Public License is included in this distribution
|
||||
in the file called LICENSE.GPL.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <alsa/input.h>
|
||||
|
@ -175,3 +176,34 @@ const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg
|
|||
|
||||
return unique_name;
|
||||
}
|
||||
|
||||
/* get attribute type from the definition */
|
||||
snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp,
|
||||
snd_config_t *attr)
|
||||
{
|
||||
snd_config_t *type;
|
||||
const char *s;
|
||||
int ret;
|
||||
|
||||
/* default to integer if no type is given */
|
||||
ret = snd_config_search(attr, "type", &type);
|
||||
if (ret < 0)
|
||||
return SND_CONFIG_TYPE_INTEGER;
|
||||
|
||||
ret = snd_config_get_string(type, &s);
|
||||
assert(ret >= 0);
|
||||
|
||||
if (!strcmp(s, "string"))
|
||||
return SND_CONFIG_TYPE_STRING;
|
||||
|
||||
if (!strcmp(s, "compound"))
|
||||
return SND_CONFIG_TYPE_COMPOUND;
|
||||
|
||||
if (!strcmp(s, "real"))
|
||||
return SND_CONFIG_TYPE_REAL;
|
||||
|
||||
if (!strcmp(s, "integer64"))
|
||||
return SND_CONFIG_TYPE_INTEGER64;
|
||||
|
||||
return SND_CONFIG_TYPE_INTEGER;
|
||||
}
|
||||
|
|
|
@ -37,11 +37,12 @@ bool tplg_class_is_attribute_immutable(const char *attr, snd_config_t *class_cfg
|
|||
bool tplg_class_is_attribute_unique(const char *attr, snd_config_t *class_cfg);
|
||||
const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg_pp,
|
||||
snd_config_t *class);
|
||||
snd_config_type_t tplg_class_get_attribute_type(struct tplg_pre_processor *tplg_pp,
|
||||
snd_config_t *attr);
|
||||
|
||||
/* config helpers */
|
||||
snd_config_t *tplg_find_config(snd_config_t *config, const char *name);
|
||||
int tplg_config_make_add(snd_config_t **config, const char *id, snd_config_type_t type,
|
||||
snd_config_t *parent);
|
||||
|
||||
char *tplg_snprintf(char *fmt, ...);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue