mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Added ctl_elem_lock and unlock code...
This commit is contained in:
parent
192d3c9226
commit
12a47782cb
4 changed files with 74 additions and 0 deletions
|
|
@ -229,6 +229,30 @@ int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
|
||||||
return ctl->ops->element_write(ctl, control);
|
return ctl->ops->element_write(ctl, control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Lock CTL element
|
||||||
|
* \param ctl CTL handle
|
||||||
|
* \param control CTL element id pointer
|
||||||
|
* \return 0 on success otherwise a negative error code
|
||||||
|
*/
|
||||||
|
int snd_ctl_elem_lock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
||||||
|
{
|
||||||
|
assert(ctl && id);
|
||||||
|
return ctl->ops->element_lock(ctl, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Unlock CTL element
|
||||||
|
* \param ctl CTL handle
|
||||||
|
* \param control CTL element id pointer
|
||||||
|
* \return 0 on success otherwise a negative error code
|
||||||
|
*/
|
||||||
|
int snd_ctl_elem_unlock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
||||||
|
{
|
||||||
|
assert(ctl && id);
|
||||||
|
return ctl->ops->element_unlock(ctl, id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get next hardware dependent device number
|
* \brief Get next hardware dependent device number
|
||||||
* \param ctl CTL handle
|
* \param ctl CTL handle
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,22 @@ static int snd_ctl_hw_elem_write(snd_ctl_t *handle, snd_ctl_elem_value_t *contro
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int snd_ctl_hw_elem_lock(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_LOCK, id) < 0)
|
||||||
|
return -errno;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int snd_ctl_hw_elem_unlock(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_UNLOCK, id) < 0)
|
||||||
|
return -errno;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
|
static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
|
||||||
{
|
{
|
||||||
snd_ctl_hw_t *hw = handle->private_data;
|
snd_ctl_hw_t *hw = handle->private_data;
|
||||||
|
|
@ -255,6 +271,8 @@ snd_ctl_ops_t snd_ctl_hw_ops = {
|
||||||
element_info: snd_ctl_hw_elem_info,
|
element_info: snd_ctl_hw_elem_info,
|
||||||
element_read: snd_ctl_hw_elem_read,
|
element_read: snd_ctl_hw_elem_read,
|
||||||
element_write: snd_ctl_hw_elem_write,
|
element_write: snd_ctl_hw_elem_write,
|
||||||
|
element_lock: snd_ctl_hw_elem_lock,
|
||||||
|
element_unlock: snd_ctl_hw_elem_unlock,
|
||||||
hwdep_next_device: snd_ctl_hw_hwdep_next_device,
|
hwdep_next_device: snd_ctl_hw_hwdep_next_device,
|
||||||
hwdep_info: snd_ctl_hw_hwdep_info,
|
hwdep_info: snd_ctl_hw_hwdep_info,
|
||||||
pcm_next_device: snd_ctl_hw_pcm_next_device,
|
pcm_next_device: snd_ctl_hw_pcm_next_device,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ typedef struct _snd_ctl_ops {
|
||||||
int (*element_info)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
|
int (*element_info)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
|
||||||
int (*element_read)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
|
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_write)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
|
||||||
|
int (*element_lock)(snd_ctl_t *handle, snd_ctl_elem_id_t *lock);
|
||||||
|
int (*element_unlock)(snd_ctl_t *handle, snd_ctl_elem_id_t *unlock);
|
||||||
int (*hwdep_next_device)(snd_ctl_t *handle, int *device);
|
int (*hwdep_next_device)(snd_ctl_t *handle, int *device);
|
||||||
int (*hwdep_info)(snd_ctl_t *handle, snd_hwdep_info_t * info);
|
int (*hwdep_info)(snd_ctl_t *handle, snd_hwdep_info_t * info);
|
||||||
int (*pcm_next_device)(snd_ctl_t *handle, int *device);
|
int (*pcm_next_device)(snd_ctl_t *handle, int *device);
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,34 @@ static int snd_ctl_shm_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int snd_ctl_shm_elem_lock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
||||||
|
{
|
||||||
|
snd_ctl_shm_t *shm = ctl->private_data;
|
||||||
|
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||||
|
int err;
|
||||||
|
ctrl->u.element_lock = *id;
|
||||||
|
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_LOCK;
|
||||||
|
err = snd_ctl_shm_action(ctl);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
*id = ctrl->u.element_lock;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int snd_ctl_shm_elem_unlock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
||||||
|
{
|
||||||
|
snd_ctl_shm_t *shm = ctl->private_data;
|
||||||
|
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||||
|
int err;
|
||||||
|
ctrl->u.element_unlock = *id;
|
||||||
|
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_UNLOCK;
|
||||||
|
err = snd_ctl_shm_action(ctl);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
*id = ctrl->u.element_unlock;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
|
static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
|
||||||
{
|
{
|
||||||
snd_ctl_shm_t *shm = ctl->private_data;
|
snd_ctl_shm_t *shm = ctl->private_data;
|
||||||
|
|
@ -362,6 +390,8 @@ snd_ctl_ops_t snd_ctl_shm_ops = {
|
||||||
element_info: snd_ctl_shm_elem_info,
|
element_info: snd_ctl_shm_elem_info,
|
||||||
element_read: snd_ctl_shm_elem_read,
|
element_read: snd_ctl_shm_elem_read,
|
||||||
element_write: snd_ctl_shm_elem_write,
|
element_write: snd_ctl_shm_elem_write,
|
||||||
|
element_lock: snd_ctl_shm_elem_lock,
|
||||||
|
element_unlock: snd_ctl_shm_elem_unlock,
|
||||||
hwdep_next_device: snd_ctl_shm_hwdep_next_device,
|
hwdep_next_device: snd_ctl_shm_hwdep_next_device,
|
||||||
hwdep_info: snd_ctl_shm_hwdep_info,
|
hwdep_info: snd_ctl_shm_hwdep_info,
|
||||||
pcm_next_device: snd_ctl_shm_pcm_next_device,
|
pcm_next_device: snd_ctl_shm_pcm_next_device,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue