]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
seq: add global method to get information of port in client
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 1 Apr 2020 09:13:28 +0000 (18:13 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Fri, 3 Apr 2020 13:06:25 +0000 (22:06 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/seq/alsaseq.map
src/seq/port-info.c
src/seq/privates.h
src/seq/query.c
src/seq/query.h

index 96d1858d7587b9697e96283c114bb9d753981f9f..afef3a678eb6fee71fa03516abc5dbe736600acd 100644 (file)
@@ -22,6 +22,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsaseq_get_client_id_list";
     "alsaseq_get_client_info";
     "alsaseq_get_port_id_list";
+    "alsaseq_get_port_info";
 
     "alsaseq_system_info_get_type";
 
index 75464ea9ba606ef167d5b04a0a8a1086b2ef6d30..35dd698b8895094721916a045eb9a5b4ca7cab08 100644 (file)
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
-#include "port-info.h"
+#include "privates.h"
 
 struct _ALSASeqPortInfoPrivate {
     struct snd_seq_port_info info;
@@ -249,3 +249,11 @@ ALSASeqPortInfo *alsaseq_port_info_new()
 {
     return g_object_new(ALSASEQ_TYPE_PORT_INFO, NULL);
 }
+
+void seq_port_info_refer_private(ALSASeqPortInfo *self,
+                                 struct snd_seq_port_info **info)
+{
+    ALSASeqPortInfoPrivate *priv = alsaseq_port_info_get_instance_private(self);
+
+    *info = &priv->info;
+}
index fe693b9f23fb7867b0151d98c3a9c91ab6c81387..0db1e9f5c61ca26f57c7f654aebad7c59fc4d71d 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "system-info.h"
 #include "client-info.h"
+#include "port-info.h"
 
 #include <sound/asequencer.h>
 
@@ -26,6 +27,9 @@ void seq_system_info_refer_private(ALSASeqSystemInfo *self,
 void seq_client_info_refer_private(ALSASeqClientInfo *self,
                                    struct snd_seq_client_info **info);
 
+void seq_port_info_refer_private(ALSASeqPortInfo *self,
+                                 struct snd_seq_port_info **info);
+
 G_END_DECLS
 
 #endif
index 93a5e29fd25c96f59cf1aeb1dc2a9b23727af025..402e032992081dd182a2f4ea03bf6b66586bf125 100644 (file)
@@ -341,3 +341,49 @@ void alsaseq_get_port_id_list(guint client_id, guint **entries,
     *entries = list;
     *entry_count = count;
 }
+
+/**
+ * alsaseq_get_port_info:
+ * @client_id: The numerical ID of client to query. One of
+ *             ALSASeqSpecificClientId is available as well as any numerica
+ *             value.
+ * @port_id: The numerical ID of port in the client. One of
+ *           ALSASeqSpecificPortId is available as well as any numerical value.
+ * @port_info: (out): A #ALSASeqPortInfo for the port.
+ * @error: A #GError.
+ *
+ * Get the information of port in client.
+ */
+void alsaseq_get_port_info(guint client_id, guint port_id,
+                           ALSASeqPortInfo **port_info, GError **error)
+{
+    char *devnode;
+    struct snd_seq_port_info *info;
+    int fd;
+
+    alsaseq_get_seq_devnode(&devnode, error);
+    if (*error != NULL)
+        return;
+
+    *port_info = g_object_new(ALSASEQ_TYPE_PORT_INFO, NULL);
+    seq_port_info_refer_private(*port_info, &info);
+
+    fd = open(devnode, O_RDONLY);
+    g_free(devnode);
+    if (fd < 0) {
+        generate_error(error, errno);
+        g_object_unref(*port_info);
+        *port_info = NULL;
+        return;
+    }
+
+    info->addr.client = client_id;
+    info->addr.port = port_id;
+    if (ioctl(fd, SNDRV_SEQ_IOCTL_GET_PORT_INFO, info) < 0)
+        generate_error(error, errno);
+    close(fd);
+    if (*error != NULL) {
+        g_object_unref(*port_info);
+        *port_info = NULL;
+    }
+}
index b063142620a85bc6d92eabd294c90b555bf3e25e..1713306c1f4d1be641a05829a42dedde57e9a5c4 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <seq/system-info.h>
 #include <seq/client-info.h>
+#include <seq/port-info.h>
 
 G_BEGIN_DECLS
 
@@ -25,6 +26,9 @@ void alsaseq_get_client_info(guint client_id, ALSASeqClientInfo **client_info,
 void alsaseq_get_port_id_list(guint client_id, guint **entries,
                               gsize *entry_count, GError **error);
 
+void alsaseq_get_port_info(guint client_id, guint port_id,
+                           ALSASeqPortInfo **port_info, GError **error);
+
 G_END_DECLS
 
 #endif