mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 02:35:43 +01:00
topology: pre-process-class: add funcion to get the name of the unique attribute in a class
Every class must have a unique attribute that will be used to instantiate the object. The value provided for this attribute must be unique within the same alsaconf node for objects of the same class. Add a helper function to get the name of the attribute that must have a unique value in the object instance. For example, when instantiating 2 buffer widgets within a pipeline, they must be given unique instance attribute values as: Object.Widget.buffer.0{} and Object.Widget.buffer.1{}. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
7bf31094e2
commit
0b0c16d4a7
2 changed files with 27 additions and 0 deletions
|
@ -150,3 +150,28 @@ snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_
|
|||
free(attr_str);
|
||||
return attr;
|
||||
}
|
||||
|
||||
/* get the name of the attribute that must have a unique value in the object instance */
|
||||
const char *tplg_class_get_unique_attribute_name(struct tplg_pre_processor *tplg_pp,
|
||||
snd_config_t *class)
|
||||
{
|
||||
snd_config_t *unique;
|
||||
const char *unique_name, *class_id;
|
||||
int ret;
|
||||
|
||||
if (snd_config_get_id(class, &class_id) < 0)
|
||||
return NULL;
|
||||
|
||||
ret = snd_config_search(class, "attributes.unique", &unique);
|
||||
if (ret < 0) {
|
||||
SNDERR("No unique attribute in class '%s'\n", class_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (snd_config_get_string(unique, &unique_name) < 0) {
|
||||
SNDERR("Invalid name for unique attribute in class '%s'\n", class_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return unique_name;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ snd_config_t *tplg_class_find_attribute_by_name(struct tplg_pre_processor *tplg_
|
|||
bool tplg_class_is_attribute_mandatory(const char *attr, snd_config_t *class_cfg);
|
||||
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);
|
||||
|
||||
/* config helpers */
|
||||
snd_config_t *tplg_find_config(snd_config_t *config, const char *name);
|
||||
|
|
Loading…
Reference in a new issue