[alsa-devel] [PATCH 4/5] control: add a function to add an element of bytes type
Takashi Sakamoto
o-takashi at sakamocchi.jp
Mon Feb 15 14:33:12 CET 2016
ALSA Ctl core allows userspace applications to add elements of bytes type,
while there's no APIs for this purpose in alsa-lib.
This commit adds the missing function.
Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
src/control/control.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/control/control.c b/src/control/control.c
index 3533ffe..38d66e8 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -488,6 +488,51 @@ int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
}
/**
+ * \brief Create and add a user-defined control element of bytes type.
+ * \param[in] ctl Control device handle.
+ * \param[in/out] id ID of the new control element.
+ * \param[in] channels The number of channels which one control element includes
+ * \return Zero on success, otherwise a negative error code.
+ *
+ * This function creates a user control element, This control element is not
+ * controlled by device drivers in kernel but that is handled by the same way as
+ * the control elements added by the device drivers.
+ *
+ * The fields of \a id, except numid, must be set with unique values to identify
+ * the new element. After returning, all fields of \a id are filled.
+ *
+ * All of channels in the new element are locked; these values are initialized
+ * with the minimum value.
+ *
+ * \par Errors:
+ * <dl>
+ * <dt>-EBUSY<dd>A control element with ID \a id already exists.
+ * <dt>-EINVAL<dd>\a channels is not between 1 to 511.
+ * <dt>-ENOMEM<dd>Out of memory, or there are too many user control elements.
+ * <dt>-ENXIO<dd>This driver does not support (bytes) user controls.
+ * <dt>-ENODEV<dd>Device unplugged.
+ * </dl>
+ *
+ * \par Compatibility:
+ * This function is added in ALSA 1.1.1.
+ */
+int snd_ctl_elem_add_bytes(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
+ unsigned int channels)
+{
+ snd_ctl_elem_info_t *info;
+
+ assert(ctl && id && id->name[0]);
+
+ snd_ctl_elem_info_alloca(&info);
+ info->id = *id;
+ info->type = SND_CTL_ELEM_TYPE_BYTES;
+ info->owner = 1;
+ info->count = channels;
+
+ return ctl->ops->element_add(ctl, info);
+}
+
+/**
* \brief Create and add a user-defined control element of IEC958 type.
* \param[in] ctl CTL handle
* \param[in/out] id ID of the new control element.
--
2.5.0
More information about the Alsa-devel
mailing list