]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
seq: add global method to get information of client for ALSA Sequencer
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/client-info.c
src/seq/privates.h
src/seq/query.c
src/seq/query.h

index 27cc71733199a878aa5b1bdaf9b045bd92943efa..2c444a758cc61fd035d0d100df429272cb0463cf 100644 (file)
@@ -20,6 +20,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsaseq_get_seq_devnode";
     "alsaseq_get_system_info";
     "alsaseq_get_client_id_list";
+    "alsaseq_get_client_info";
 
     "alsaseq_system_info_get_type";
 
index f49359a87a7df3d3267d1af6775a039480042c93..fa8d281098463b154b7c12227c28144f7036a969 100644 (file)
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
-#include "client-info.h"
 #include "privates.h"
 
 #include <errno.h>
@@ -166,7 +165,7 @@ static void alsaseq_client_info_class_init(ALSASeqClientInfoClass *klass)
 
     seq_client_info_props[SEQ_CLIENT_INFO_PROP_PROCESS_ID] =
         g_param_spec_long("process-id", "process-id",
-                          "The process ID for uset client, otherwise -1.",
+                          "The process ID for user client, otherwise -1.",
                           G_MINLONG, G_MAXLONG,
                           -1,
                           G_PARAM_READABLE);
@@ -290,3 +289,12 @@ void alsaseq_client_info_get_event_filter(ALSASeqClientInfo *self,
         }
     }
 }
+
+void seq_client_info_refer_private(ALSASeqClientInfo *self,
+                                   struct snd_seq_client_info **info)
+{
+    ALSASeqClientInfoPrivate *priv =
+                                alsaseq_client_info_get_instance_private(self);
+
+    *info = &priv->info;
+}
index 68316f9593911459b9369eb636250ff16afdd1fc..fe693b9f23fb7867b0151d98c3a9c91ab6c81387 100644 (file)
@@ -8,6 +8,7 @@
 #include <glib-object.h>
 
 #include "system-info.h"
+#include "client-info.h"
 
 #include <sound/asequencer.h>
 
@@ -22,6 +23,9 @@ GQuark alsaseq_error_quark(void);
 void seq_system_info_refer_private(ALSASeqSystemInfo *self,
                                    struct snd_seq_system_info **info);
 
+void seq_client_info_refer_private(ALSASeqClientInfo *self,
+                                   struct snd_seq_client_info **info);
+
 G_END_DECLS
 
 #endif
index ce0ca138e3c6e9518bf096e66cc4ee8a4ed7721b..0c5a35d99df4af4931957b33dfbd8695a670073b 100644 (file)
@@ -225,3 +225,46 @@ void alsaseq_get_client_id_list(guint **entries, gsize *entry_count,
     *entries = list;
     *entry_count = count;
 }
+
+/**
+ * alsaseq_get_client_info:
+ * @client_id: The numerical ID of client to query. One of
+ *             ALSASeqSpecificClientId is available as well as any numerical
+ *             value.
+ * @client_info: (out): A #ALSASeqClientInfo for the client.
+ * @error: A #GError.
+ *
+ * Get the information of client according to the numerical ID.
+ */
+void alsaseq_get_client_info(guint client_id, ALSASeqClientInfo **client_info,
+                             GError **error)
+{
+    char *devnode;
+    struct snd_seq_client_info *info;
+    int fd;
+
+    alsaseq_get_seq_devnode(&devnode, error);
+    if (*error != NULL)
+        return;
+
+    *client_info = g_object_new(ALSASEQ_TYPE_CLIENT_INFO, NULL);
+    seq_client_info_refer_private(*client_info, &info);
+
+    fd = open(devnode, O_RDONLY);
+    g_free(devnode);
+    if (fd < 0) {
+        generate_error(error, errno);
+        g_object_unref(*client_info);
+        *client_info = NULL;
+        return;
+    }
+
+    info->client = client_id;
+    if (ioctl(fd, SNDRV_SEQ_IOCTL_GET_CLIENT_INFO, info) < 0)
+        generate_error(error, errno);
+    close(fd);
+    if (*error != NULL) {
+        g_object_unref(*client_info);
+        *client_info = NULL;
+    }
+}
index 7a07f49f387ad1bfaa3cf50b299448a5a7a99100..49a01b2c7baffa3c9667253dd6acc11da93c3c54 100644 (file)
@@ -6,6 +6,7 @@
 #include <glib-object.h>
 
 #include <seq/system-info.h>
+#include <seq/client-info.h>
 
 G_BEGIN_DECLS
 
@@ -18,6 +19,9 @@ void alsaseq_get_system_info(ALSASeqSystemInfo **system_info, GError **error);
 void alsaseq_get_client_id_list(guint **entries, gsize *entry_count,
                                 GError **error);
 
+void alsaseq_get_client_info(guint client_id, ALSASeqClientInfo **client_info,
+                            GError **error);
+
 G_END_DECLS
 
 #endif