mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
control: add __snd_ctl_add_elem_set() helper
It simplifies the add_elem_set functions and we need it for UCM. It's an internal function. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
83e4c1ab77
commit
03cb988179
2 changed files with 33 additions and 49 deletions
|
|
@ -436,6 +436,25 @@ static inline int set_user_access(snd_ctl_elem_info_t *info)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __snd_ctl_add_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
|
unsigned int element_count,
|
||||||
|
unsigned int member_count)
|
||||||
|
{
|
||||||
|
if (ctl == NULL || info->id.name[0] == '\0')
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (set_user_access(info))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
info->owner = element_count;
|
||||||
|
info->count = member_count;
|
||||||
|
|
||||||
|
if (!validate_element_member_dimension(info))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return ctl->ops->element_add(ctl, info);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create and add some user-defined control elements of integer type.
|
* \brief Create and add some user-defined control elements of integer type.
|
||||||
* \param ctl A handle of backend module for control interface.
|
* \param ctl A handle of backend module for control interface.
|
||||||
|
|
@ -489,23 +508,15 @@ int snd_ctl_add_integer_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
unsigned int numid;
|
unsigned int numid;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
if (info == NULL)
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (set_user_access(info))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
info->type = SND_CTL_ELEM_TYPE_INTEGER;
|
info->type = SND_CTL_ELEM_TYPE_INTEGER;
|
||||||
info->owner = element_count;
|
|
||||||
info->count = member_count;
|
|
||||||
info->value.integer.min = min;
|
info->value.integer.min = min;
|
||||||
info->value.integer.max = max;
|
info->value.integer.max = max;
|
||||||
info->value.integer.step = step;
|
info->value.integer.step = step;
|
||||||
|
|
||||||
if (!validate_element_member_dimension(info))
|
err = __snd_ctl_add_elem_set(ctl, info, element_count, member_count);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
err = ctl->ops->element_add(ctl, info);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
numid = snd_ctl_elem_id_get_numid(&info->id);
|
numid = snd_ctl_elem_id_get_numid(&info->id);
|
||||||
|
|
@ -579,23 +590,15 @@ int snd_ctl_add_integer64_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
unsigned int numid;
|
unsigned int numid;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
if (info == NULL)
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (set_user_access(info))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
info->type = SND_CTL_ELEM_TYPE_INTEGER64;
|
info->type = SND_CTL_ELEM_TYPE_INTEGER64;
|
||||||
info->owner = element_count;
|
|
||||||
info->count = member_count;
|
|
||||||
info->value.integer64.min = min;
|
info->value.integer64.min = min;
|
||||||
info->value.integer64.max = max;
|
info->value.integer64.max = max;
|
||||||
info->value.integer64.step = step;
|
info->value.integer64.step = step;
|
||||||
|
|
||||||
if (!validate_element_member_dimension(info))
|
err = __snd_ctl_add_elem_set(ctl, info, element_count, member_count);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
err = ctl->ops->element_add(ctl, info);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
numid = snd_ctl_elem_id_get_numid(&info->id);
|
numid = snd_ctl_elem_id_get_numid(&info->id);
|
||||||
|
|
@ -658,22 +661,14 @@ int snd_ctl_add_boolean_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
unsigned int element_count,
|
unsigned int element_count,
|
||||||
unsigned int member_count)
|
unsigned int member_count)
|
||||||
{
|
{
|
||||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
if (info == NULL)
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (set_user_access(info))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
info->type = SND_CTL_ELEM_TYPE_BOOLEAN;
|
info->type = SND_CTL_ELEM_TYPE_BOOLEAN;
|
||||||
info->owner = element_count;
|
|
||||||
info->count = member_count;
|
|
||||||
info->value.integer.min = 0;
|
info->value.integer.min = 0;
|
||||||
info->value.integer.max = 1;
|
info->value.integer.max = 1;
|
||||||
|
|
||||||
if (!validate_element_member_dimension(info))
|
return __snd_ctl_add_elem_set(ctl, info, element_count, member_count);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
return ctl->ops->element_add(ctl, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -729,11 +724,7 @@ int snd_ctl_add_enumerated_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
char *buf, *p;
|
char *buf, *p;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0' ||
|
if (info == NULL || labels == NULL)
|
||||||
labels == NULL)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (set_user_access(info))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
info->type = SND_CTL_ELEM_TYPE_ENUMERATED;
|
info->type = SND_CTL_ELEM_TYPE_ENUMERATED;
|
||||||
|
|
@ -757,10 +748,7 @@ int snd_ctl_add_enumerated_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
p += strlen(labels[i]) + 1;
|
p += strlen(labels[i]) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validate_element_member_dimension(info))
|
err = __snd_ctl_add_elem_set(ctl, info, element_count, member_count);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
err = ctl->ops->element_add(ctl, info);
|
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
|
|
@ -810,20 +798,12 @@ int snd_ctl_add_bytes_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
unsigned int element_count,
|
unsigned int element_count,
|
||||||
unsigned int member_count)
|
unsigned int member_count)
|
||||||
{
|
{
|
||||||
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
if (info == NULL)
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (set_user_access(info))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
info->type = SND_CTL_ELEM_TYPE_BYTES;
|
info->type = SND_CTL_ELEM_TYPE_BYTES;
|
||||||
info->owner = element_count;
|
|
||||||
info->count = member_count;
|
|
||||||
|
|
||||||
if (!validate_element_member_dimension(info))
|
return __snd_ctl_add_elem_set(ctl, info, element_count, member_count);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
return ctl->ops->element_add(ctl, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -106,3 +106,7 @@ int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid);
|
||||||
int INTERNAL(snd_ctl_elem_info_get_dimensions)(const snd_ctl_elem_info_t *obj);
|
int INTERNAL(snd_ctl_elem_info_get_dimensions)(const snd_ctl_elem_info_t *obj);
|
||||||
int INTERNAL(snd_ctl_elem_info_get_dimension)(const snd_ctl_elem_info_t *obj, unsigned int idx);
|
int INTERNAL(snd_ctl_elem_info_get_dimension)(const snd_ctl_elem_info_t *obj, unsigned int idx);
|
||||||
#endif /* INTERNAL */
|
#endif /* INTERNAL */
|
||||||
|
|
||||||
|
int __snd_ctl_add_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
||||||
|
unsigned int element_count,
|
||||||
|
unsigned int member_count);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue