mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
- added support for user control elements
This commit is contained in:
parent
701d0614f1
commit
4a54759f1f
5 changed files with 83 additions and 3 deletions
|
|
@ -252,6 +252,48 @@ int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
|
|||
return ctl->ops->element_info(ctl, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Create and add an user CTL element
|
||||
* \param ctl CTL handle
|
||||
* \param info CTL element info
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*
|
||||
* Note that the new element is locked!
|
||||
*/
|
||||
int snd_ctl_elem_add(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
|
||||
{
|
||||
assert(ctl && info && info->id.name[0]);
|
||||
return ctl->ops->element_add(ctl, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Replace an user CTL element
|
||||
* \param ctl CTL handle
|
||||
* \param info CTL element info
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*
|
||||
* Note that the new element is locked!
|
||||
*/
|
||||
int snd_ctl_elem_replace(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
|
||||
{
|
||||
assert(ctl && info && info->id.name[0]);
|
||||
return ctl->ops->element_replace(ctl, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Remove an user CTL element
|
||||
* \param ctl CTL handle
|
||||
* \param id CTL element identification
|
||||
* \return 0 on success otherwise a negative error code
|
||||
*
|
||||
* Note that the new element is locked!
|
||||
*/
|
||||
int snd_ctl_elem_remove(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
||||
{
|
||||
assert(ctl && id && (id->name[0] || id->numid));
|
||||
return ctl->ops->element_remove(ctl, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get CTL element value
|
||||
* \param ctl CTL handle
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const char *_snd_module_control_hw = "";
|
|||
#endif
|
||||
|
||||
#define SNDRV_FILE_CONTROL "/dev/snd/controlC%i"
|
||||
#define SNDRV_CTL_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 2)
|
||||
#define SNDRV_CTL_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 3)
|
||||
|
||||
typedef struct {
|
||||
int card;
|
||||
|
|
@ -142,6 +142,30 @@ static int snd_ctl_hw_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_elem_add(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_ADD, info) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_elem_replace(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_REPLACE, info) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_elem_remove(snd_ctl_t *handle, snd_ctl_elem_id_t *id)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_REMOVE, id) < 0)
|
||||
return -errno;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_elem_read(snd_ctl_t *handle, snd_ctl_elem_value_t *control)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
|
|
@ -272,6 +296,9 @@ snd_ctl_ops_t snd_ctl_hw_ops = {
|
|||
.card_info = snd_ctl_hw_card_info,
|
||||
.element_list = snd_ctl_hw_elem_list,
|
||||
.element_info = snd_ctl_hw_elem_info,
|
||||
.element_add = snd_ctl_hw_elem_add,
|
||||
.element_replace = snd_ctl_hw_elem_replace,
|
||||
.element_remove = snd_ctl_hw_elem_remove,
|
||||
.element_read = snd_ctl_hw_elem_read,
|
||||
.element_write = snd_ctl_hw_elem_write,
|
||||
.element_lock = snd_ctl_hw_elem_lock,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ typedef struct _snd_ctl_ops {
|
|||
int (*card_info)(snd_ctl_t *handle, snd_ctl_card_info_t *info);
|
||||
int (*element_list)(snd_ctl_t *handle, snd_ctl_elem_list_t *list);
|
||||
int (*element_info)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
|
||||
int (*element_add)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
|
||||
int (*element_replace)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
|
||||
int (*element_remove)(snd_ctl_t *handle, snd_ctl_elem_id_t *id);
|
||||
int (*element_read)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
|
||||
int (*element_write)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
|
||||
int (*element_lock)(snd_ctl_t *handle, snd_ctl_elem_id_t *lock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue