/**
* \brief Create and add some user-defined control elements of integer type.
* \param ctl A handle of backend module for control interface.
- * \param id ID of the first new element.
+ * \param info Common iformation for a new element set, with ID of the first new
+ * element.
* \param element_count The number of elements added by this operation.
* \param member_count The number of members which a element has to
* represent its states.
* \par Compatibility:
* This function is added in version 1.1.2.
*/
-int snd_ctl_elem_add_integer_set(snd_ctl_t *ctl, snd_ctl_elem_id_t *id,
+int snd_ctl_elem_add_integer_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
unsigned int element_count,
unsigned int member_count,
long min, long max, long step)
{
- snd_ctl_elem_info_t info = {0};
snd_ctl_elem_value_t data = {0};
unsigned int i;
unsigned int j;
unsigned int numid;
int err;
- assert(ctl && id && id->name[0]);
+ assert(ctl && info && info->id.name[0]);
- info.id = *id;
- info.type = SND_CTL_ELEM_TYPE_INTEGER;
- info.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_USER;
- info.owner = element_count;
- info.count = member_count;
- info.value.integer.min = min;
- info.value.integer.max = max;
- info.value.integer.step = step;
-
- err = ctl->ops->element_add(ctl, &info);
+ info->type = SND_CTL_ELEM_TYPE_INTEGER;
+ info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_USER;
+ info->owner = element_count;
+ info->count = member_count;
+ info->value.integer.min = min;
+ info->value.integer.max = max;
+ info->value.integer.step = step;
+
+ err = ctl->ops->element_add(ctl, info);
if (err < 0)
return err;
- numid = snd_ctl_elem_id_get_numid(&info.id);
+ numid = snd_ctl_elem_id_get_numid(&info->id);
/* Set initial value to all of members in all of added elements. */
- data.id = info.id;
+ data.id = info->id;
for (i = 0; i < element_count; i++) {
snd_ctl_elem_id_set_numid(&data.id, numid + i);
return err;
}
- *id = info.id;
return 0;
}
/**
* \brief Create and add some user-defined control elements of integer64 type.
* \param ctl A handle of backend module for control interface.
- * \param id ID of the first new control element.
+ * \param info Common iformation for a new element set, with ID of the first new
+ * element.
* \param element_count The number of elements added by this operation.
* \param member_count The number of members which a element has to
* represent its states.
* \par Compatibility:
* This function is added in version 1.1.2.
*/
-int snd_ctl_elem_add_integer64_set(snd_ctl_t *ctl, snd_ctl_elem_id_t *id,
+int snd_ctl_elem_add_integer64_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
unsigned int element_count,
unsigned int member_count,
long long min, long long max, long long step)
{
- snd_ctl_elem_info_t info = {0};
snd_ctl_elem_value_t data = {0};
unsigned int i;
unsigned int j;
unsigned int numid;
int err;
- assert(ctl && id && id->name[0]);
+ assert(ctl && info && info->id.name[0]);
- info.id = *id;
- info.type = SND_CTL_ELEM_TYPE_INTEGER64;
- info.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_USER;
- info.owner = element_count;
- info.count = member_count;
- info.value.integer64.min = min;
- info.value.integer64.max = max;
- info.value.integer64.step = step;
-
- err = ctl->ops->element_add(ctl, &info);
+ info->type = SND_CTL_ELEM_TYPE_INTEGER64;
+ info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_USER;
+ info->owner = element_count;
+ info->count = member_count;
+ info->value.integer64.min = min;
+ info->value.integer64.max = max;
+ info->value.integer64.step = step;
+
+ err = ctl->ops->element_add(ctl, info);
if (err < 0)
return err;
- numid = snd_ctl_elem_id_get_numid(&info.id);
+ numid = snd_ctl_elem_id_get_numid(&info->id);
/* Set initial value to all of members in all of added elements. */
- data.id = info.id;
+ data.id = info->id;
for (i = 0; i < element_count; i++) {
snd_ctl_elem_id_set_numid(&data.id, numid + i);
return err;
}
- *id = info.id;
return 0;
}
/**
* \brief Create and add some user-defined control elements of boolean type.
* \param ctl A handle of backend module for control interface.
- * \param id ID of the new control element.
+ * \param info Common iformation for a new element set, with ID of the first new
+ * element.
* \param element_count The number of elements added by this operation.
* \param member_count The number of members which a element has to
* represent its states.
* \par Compatibility:
* This function is added in version 1.1.2.
*/
-int snd_ctl_elem_add_boolean_set(snd_ctl_t *ctl, snd_ctl_elem_id_t *id,
+int snd_ctl_elem_add_boolean_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
unsigned int element_count,
unsigned int member_count)
{
- snd_ctl_elem_info_t info = {0};
- int err;
-
- assert(ctl && id && id->name[0]);
+ assert(ctl && info && info->id.name[0]);
- info.id = *id;
- info.type = SND_CTL_ELEM_TYPE_BOOLEAN;
- info.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_USER;
- info.owner = element_count;
- info.count = member_count;
- info.value.integer.min = 0;
- info.value.integer.max = 1;
-
- err = ctl->ops->element_add(ctl, &info);
- if (err >= 0)
- *id = info.id;
+ info->type = SND_CTL_ELEM_TYPE_BOOLEAN;
+ info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_USER;
+ info->owner = element_count;
+ info->count = member_count;
+ info->value.integer.min = 0;
+ info->value.integer.max = 1;
- return err;
+ return ctl->ops->element_add(ctl, info);
}
/**
* \brief Create and add some user-defined control elements of enumerated type.
* \param ctl A handle of backend module for control interface.
- * \param id ID of the first new element.
+ * \param info Common iformation for a new element set, with ID of the first new
+ * element.
* \param element_count The number of elements added by this operation.
* \param member_count The number of members which a element has to
* represent its states.
* \par Compatibility:
* This function is added in version 1.1.2.
*/
-int snd_ctl_elem_add_enumerated_set(snd_ctl_t *ctl, snd_ctl_elem_id_t *id,
+int snd_ctl_elem_add_enumerated_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
unsigned int element_count,
unsigned int member_count,
unsigned int items,
const char *const labels[])
{
- snd_ctl_elem_info_t info = {0};
unsigned int i, bytes;
char *buf, *p;
int err;
- assert(ctl && id && id->name[0] && labels);
+ assert(ctl && info && info->id.name[0] && labels);
- info.id = *id;
- info.type = SND_CTL_ELEM_TYPE_ENUMERATED;
- info.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_USER;
- info.owner = element_count;
- info.count = member_count;
- info.value.enumerated.items = items;
+ info->type = SND_CTL_ELEM_TYPE_ENUMERATED;
+ info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_USER;
+ info->owner = element_count;
+ info->count = member_count;
+ info->value.enumerated.items = items;
bytes = 0;
for (i = 0; i < items; ++i)
buf = malloc(bytes);
if (buf == NULL)
return -ENOMEM;
- info.value.enumerated.names_ptr = (uintptr_t)buf;
- info.value.enumerated.names_length = bytes;
+ info->value.enumerated.names_ptr = (uintptr_t)buf;
+ info->value.enumerated.names_length = bytes;
p = buf;
for (i = 0; i < items; ++i) {
strcpy(p, labels[i]);
p += strlen(labels[i]) + 1;
}
- err = ctl->ops->element_add(ctl, &info);
- if (err >= 0)
- *id = info.id;
+ err = ctl->ops->element_add(ctl, info);
free(buf);
/**
* \brief Create and add some user-defined control elements of bytes type.
* \param ctl A handle of backend module for control interface.
- * \param id ID of the first new element.
+ * \param info Common iformation for a new element set, with ID of the first new
+ * element.
* \param element_count The number of elements added by this operation.
* \param member_count The number of members which a element has to
* represent its states.
* \par Compatibility:
* This function is added in version 1.1.2.
*/
-int snd_ctl_elem_add_bytes_set(snd_ctl_t *ctl, snd_ctl_elem_id_t *id,
+int snd_ctl_elem_add_bytes_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
unsigned int element_count,
unsigned int member_count)
{
- snd_ctl_elem_info_t info = {0};
- int err;
-
- assert(ctl && id && id->name[0]);
+ assert(ctl && info && info->id.name[0]);
- info.id = *id;
- info.type = SND_CTL_ELEM_TYPE_BYTES;
- info.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
- SNDRV_CTL_ELEM_ACCESS_USER;
- info.owner = element_count;
- info.count = member_count;
-
- err = ctl->ops->element_add(ctl, &info);
- if (err >= 0)
- *id = info.id;
+ info->type = SND_CTL_ELEM_TYPE_BYTES;
+ info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_USER;
+ info->owner = element_count;
+ info->count = member_count;
- return err;
+ return ctl->ops->element_add(ctl, info);
}
/**
unsigned int member_count,
long min, long max, long step)
{
- snd_ctl_elem_id_t local_id = {0};
+ snd_ctl_elem_info_t info = {0};
- local_id = *id;
+ info.id = *id;
- return snd_ctl_elem_add_integer_set(ctl, &local_id, 1, member_count,
+ return snd_ctl_elem_add_integer_set(ctl, &info, 1, member_count,
min, max, step);
}
unsigned int member_count,
long long min, long long max, long long step)
{
- snd_ctl_elem_id_t local_id = {0};
+ snd_ctl_elem_info_t info = {0};
- local_id = *id;
+ info.id = *id;
- return snd_ctl_elem_add_integer64_set(ctl, &local_id, 1, member_count,
+ return snd_ctl_elem_add_integer64_set(ctl, &info, 1, member_count,
min, max, step);
}
int snd_ctl_elem_add_boolean(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
unsigned int member_count)
{
- snd_ctl_elem_id_t local_id = {0};
+ snd_ctl_elem_info_t info = {0};
- local_id = *id;
+ info.id = *id;
- return snd_ctl_elem_add_boolean_set(ctl, &local_id, 1, member_count);
+ return snd_ctl_elem_add_boolean_set(ctl, &info, 1, member_count);
}
/**
unsigned int member_count, unsigned int items,
const char *const labels[])
{
- snd_ctl_elem_id_t local_id = {0};
+ snd_ctl_elem_info_t info = {0};
- local_id = *id;
+ info.id = *id;
- return snd_ctl_elem_add_enumerated_set(ctl, &local_id, 1, member_count,
+ return snd_ctl_elem_add_enumerated_set(ctl, &info, 1, member_count,
items, labels);
}