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>
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;
+}
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);