]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ctl: add an API to set dimension levels to element information
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 29 Jun 2016 13:43:00 +0000 (22:43 +0900)
committerTakashi Iwai <tiwai@suse.de>
Thu, 30 Jun 2016 06:42:17 +0000 (08:42 +0200)
In a former commit, 'struct snd_ctl_elem_info' is used as a 'container' to
transfer extra fields of element information for APIs to add an element
set. The extra fields should be filled in advance of call of the APIs.
Currently, dimension level is in the extra fields and no APIs to set it.

This commit adds an API to set dimension level to the information
structure. This API is expected to be used in advance of usage of APIs
to add an element set, for nothing others. When the information structure
is extended in future, then the similar APIs shall be added for the new
feature.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/control.h
src/control/control.c

index b14edee30fab1e31ce85afcb14ae1376ab2be19c..cd60d90fc211f0e5fe1de23578fc97ad30eb1841 100644 (file)
@@ -408,6 +408,8 @@ void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val);
 const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj);
 int snd_ctl_elem_info_get_dimensions(const snd_ctl_elem_info_t *obj);
 int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int idx);
+int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info,
+                                   const int dimension[4]);
 void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr);
 unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj);
 snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj);
index 70b166b81e40904107e15a6d813ad953575bbeb9..2ad3e0d57d86595cbf10ef511291b2d132bbda77 100644 (file)
@@ -2457,6 +2457,36 @@ int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int
 }
 use_default_symbol_version(__snd_ctl_elem_info_get_dimension, snd_ctl_elem_info_get_dimension, ALSA_0.9.3);
 
+/**
+ * \brief Set width to a specified dimension level of given element information.
+ * \param info Information of an element.
+ * \param dimension Dimension width for each level by member unit.
+ * \return Zero on success, otherwise a negative error code.
+ *
+ * \par Errors:
+ * <dl>
+ * <dt>-EINVAL
+ * <dd>Invalid arguments are given as parameters.
+ * </dl>
+ */
+int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info,
+                                   const int dimension[4])
+{
+       unsigned int i;
+
+       if (info == NULL)
+               return -EINVAL;
+
+       for (i = 0; i < ARRAY_SIZE(info->dimen.d); i++) {
+               if (dimension[i] < 0)
+                       return -EINVAL;
+
+               info->dimen.d[i] = dimension[i];
+       }
+
+       return 0;
+}
+
 /**
  * \brief Get CTL element identifier of a CTL element id/info
  * \param obj CTL element id/info