]> git.alsa-project.org Git - alsa-lib.git/commitdiff
control: Add UMP device query support
authorTakashi Iwai <tiwai@suse.de>
Sun, 25 Dec 2022 11:09:51 +0000 (12:09 +0100)
committerTakashi Iwai <tiwai@suse.de>
Tue, 6 Jun 2023 13:13:27 +0000 (15:13 +0200)
Add a function to query the next available UMP device via control
interface, just like the existing one for rawmidi.  As the UMP rawmidi
is compatible with the standard rawmidi, no extra helper for the
rawmidi_info is present.  Ditto for the preferred subdevice, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/control.h
src/Versions.in
src/control/control.c
src/control/control_hw.c
src/control/control_local.h

index d0c40d2fa32b2e06eed1ce4f9f24d8165f11da0a..a2439d78057a3ccd4870f20c5d9434df7b81ceac 100644 (file)
@@ -417,6 +417,7 @@ int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev);
 int snd_ctl_rawmidi_next_device(snd_ctl_t *ctl, int * device);
 int snd_ctl_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info);
 int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev);
+int snd_ctl_ump_next_device(snd_ctl_t *ctl, int *device);
 #endif
 int snd_ctl_set_power_state(snd_ctl_t *ctl, unsigned int state);
 int snd_ctl_get_power_state(snd_ctl_t *ctl, unsigned int *state);
index 3315fa2840e0459440a68e64f9defe81769cd774..ee17cf289c0ec5b437182cd3b8314429b5386ebc 100644 (file)
@@ -153,4 +153,5 @@ ALSA_1.2.10 {
   global:
 
     @SYMBOL_PREFIX@snd_ump_*;
+    @SYMBOL_PREFIX@snd_ctl_ump_next_device;
 } ALSA_1.2.9;
index d3ecc6e9501ac3554f4baea4e499b1c868d58f24..7168ff8d2d35ee0c1d3b94a63caf3f2f0089f69f 100644 (file)
@@ -1267,6 +1267,20 @@ int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
        return ctl->ops->rawmidi_prefer_subdevice(ctl, subdev);
 }
 
+/**
+ * \brief Get next UMP device number
+ * \param ctl CTL handle
+ * \param device current device on entry and next device on return
+ * \return 0 on success otherwise a negative error code
+ */
+int snd_ctl_ump_next_device(snd_ctl_t *ctl, int *device)
+{
+       assert(ctl && device);
+       if (ctl->ops->ump_next_device)
+               return ctl->ops->ump_next_device(ctl, device);
+       return -ENXIO;
+}
+
 /**
  * \brief Set Power State to given SND_CTL_POWER_* value and do the power management
  * \param ctl CTL handle
index a927cdfee441eae662aa84e08492b845aa9aa0c5..95d6d07d22d122660a24c89df79b7d5b41a902fd 100644 (file)
@@ -325,6 +325,14 @@ static int snd_ctl_hw_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev)
        return 0;
 }
 
+static int snd_ctl_hw_ump_next_device(snd_ctl_t *handle, int *device)
+{
+       snd_ctl_hw_t *hw = handle->private_data;
+       if (ioctl(hw->fd, SNDRV_CTL_IOCTL_UMP_NEXT_DEVICE, device) < 0)
+               return -errno;
+       return 0;
+}
+
 static int snd_ctl_hw_set_power_state(snd_ctl_t *handle, unsigned int state)
 {
        snd_ctl_hw_t *hw = handle->private_data;
@@ -379,6 +387,7 @@ static const snd_ctl_ops_t snd_ctl_hw_ops = {
        .rawmidi_next_device = snd_ctl_hw_rawmidi_next_device,
        .rawmidi_info = snd_ctl_hw_rawmidi_info,
        .rawmidi_prefer_subdevice = snd_ctl_hw_rawmidi_prefer_subdevice,
+       .ump_next_device = snd_ctl_hw_ump_next_device,
        .set_power_state = snd_ctl_hw_set_power_state,
        .get_power_state = snd_ctl_hw_get_power_state,
        .read = snd_ctl_hw_read,
index b84dc4291c293936ada961a18dbc2df8cdc1b5e5..aa05bac849137fc1c7e7182b505f026010057ccc 100644 (file)
@@ -47,6 +47,7 @@ typedef struct _snd_ctl_ops {
        int (*rawmidi_next_device)(snd_ctl_t *handle, int *device);
        int (*rawmidi_info)(snd_ctl_t *handle, snd_rawmidi_info_t * info);
        int (*rawmidi_prefer_subdevice)(snd_ctl_t *handle, int subdev);
+       int (*ump_next_device)(snd_ctl_t *handle, int *device);
        int (*set_power_state)(snd_ctl_t *handle, unsigned int state);
        int (*get_power_state)(snd_ctl_t *handle, unsigned int *state);
        int (*read)(snd_ctl_t *handle, snd_ctl_event_t *event);