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
* \param ctl CTL handle
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)
{
snd_ctl_hw_t *hw = handle->private_data;
element_info: snd_ctl_hw_elem_info,
element_read: snd_ctl_hw_elem_read,
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_info: snd_ctl_hw_hwdep_info,
pcm_next_device: snd_ctl_hw_pcm_next_device,
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_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_info)(snd_ctl_t *handle, snd_hwdep_info_t * info);
int (*pcm_next_device)(snd_ctl_t *handle, int *device);
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)
{
snd_ctl_shm_t *shm = ctl->private_data;
element_info: snd_ctl_shm_elem_info,
element_read: snd_ctl_shm_elem_read,
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_info: snd_ctl_shm_hwdep_info,
pcm_next_device: snd_ctl_shm_pcm_next_device,