]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added ctl_elem_lock and unlock code...
authorJaroslav Kysela <perex@perex.cz>
Thu, 19 Apr 2001 13:53:39 +0000 (13:53 +0000)
committerJaroslav Kysela <perex@perex.cz>
Thu, 19 Apr 2001 13:53:39 +0000 (13:53 +0000)
src/control/control.c
src/control/control_hw.c
src/control/control_local.h
src/control/control_shm.c

index 3042ae26830ffede61ddc269502acc53673d1829..a07f1ca688d5d88565480dbd04d96101e50f095b 100644 (file)
@@ -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);
 }
 
+/**
+ * \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
index d2d3bed77a3e6a710de446815be146de7c048bbe..51966db794253ea0c222f9bf043fde698b32425b 100644 (file)
@@ -163,6 +163,22 @@ static int snd_ctl_hw_elem_write(snd_ctl_t *handle, snd_ctl_elem_value_t *contro
        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;
@@ -255,6 +271,8 @@ snd_ctl_ops_t snd_ctl_hw_ops = {
        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,
index 0246d5a3d7d9f8a31e752fb1694c4128bc605302..69ae2faa84d31bb2f50edcd412f797256892223a 100644 (file)
@@ -33,6 +33,8 @@ typedef struct _snd_ctl_ops {
        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);
index f525f178721950a1b544458cd3a59ebd0e896d65..cbc5aef9ee65e6b22d33ec1064267ba43beaea20 100644 (file)
@@ -207,6 +207,34 @@ static int snd_ctl_shm_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
        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;
@@ -362,6 +390,8 @@ snd_ctl_ops_t snd_ctl_shm_ops = {
        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,