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

index d64a61b043501a8fe1bbbae88b94ba274bedc70f..cf6cddd23aa120adfd8503c7cc52d5f902538d55 100644 (file)
@@ -23,6 +23,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsaseq_get_client_info";
     "alsaseq_get_port_id_list";
     "alsaseq_get_port_info";
+    "alsaseq_get_client_pool";
 
     "alsaseq_system_info_get_type";
 
index 3245b96c9be03a671a4d28c44e2e52329516f0fc..6776b253c5423d50040c841200378203839f11bd 100644 (file)
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
-#include "client-pool.h"
-
-#include <sound/asequencer.h>
+#include "privates.h"
 
 struct _ALSASeqClientPoolPrivate {
     struct snd_seq_client_pool pool;
@@ -140,3 +138,12 @@ static void alsaseq_client_pool_init(ALSASeqClientPool *self)
 {
     return;
 }
+
+void seq_client_pool_refer_private(ALSASeqClientPool *self,
+                                   struct snd_seq_client_pool **pool)
+{
+    ALSASeqClientPoolPrivate *priv =
+                                alsaseq_client_pool_get_instance_private(self);
+
+    *pool = &priv->pool;
+}
index 0db1e9f5c61ca26f57c7f654aebad7c59fc4d71d..3d3407a57a1e99074c1b68ff78b5f944bae43114 100644 (file)
@@ -10,6 +10,7 @@
 #include "system-info.h"
 #include "client-info.h"
 #include "port-info.h"
+#include "client-pool.h"
 
 #include <sound/asequencer.h>
 
@@ -30,6 +31,9 @@ void seq_client_info_refer_private(ALSASeqClientInfo *self,
 void seq_port_info_refer_private(ALSASeqPortInfo *self,
                                  struct snd_seq_port_info **info);
 
+void seq_client_pool_refer_private(ALSASeqClientPool *self,
+                                   struct snd_seq_client_pool **pool);
+
 G_END_DECLS
 
 #endif
index 402e032992081dd182a2f4ea03bf6b66586bf125..39f57899631264ea7c363afcaf1a0581696bc64c 100644 (file)
@@ -387,3 +387,45 @@ void alsaseq_get_port_info(guint client_id, guint port_id,
         *port_info = NULL;
     }
 }
+
+/**
+ * alsaseq_get_client_pool:
+ * @client_id: The numerical ID of client to query. One of
+ *             ALSASeqSpecificClientId is available as well as any numerical
+ *             value.
+ * @client_pool: (out): The information of memory pool for the client.
+ * @error: A #GError.
+ *
+ * Get statistical information of memory pool for the given client.
+ */
+void alsaseq_get_client_pool(gint client_id, ALSASeqClientPool **client_pool,
+                             GError **error)
+{
+    char *devnode;
+    int fd;
+    struct snd_seq_client_pool *pool;
+
+    alsaseq_get_seq_devnode(&devnode, error);
+    if (*error != NULL)
+        return;
+
+    fd = open(devnode, O_RDONLY);
+    g_free(devnode);
+    if (fd < 0) {
+        generate_error(error, errno);
+        return;
+    }
+
+    *client_pool = g_object_new(ALSASEQ_TYPE_CLIENT_POOL, NULL);
+    seq_client_pool_refer_private(*client_pool, &pool);
+
+    pool->client = client_id;
+    if (ioctl(fd, SNDRV_SEQ_IOCTL_GET_CLIENT_POOL, pool) < 0) {
+        generate_error(error, errno);
+        close(fd);
+        g_object_unref(*client_pool);
+        return;
+    }
+
+    close(fd);
+}
index 1713306c1f4d1be641a05829a42dedde57e9a5c4..e2bb56743266c275a5c5df3e689c714b230c5ec4 100644 (file)
@@ -8,6 +8,7 @@
 #include <seq/system-info.h>
 #include <seq/client-info.h>
 #include <seq/port-info.h>
+#include <seq/client-pool.h>
 
 G_BEGIN_DECLS
 
@@ -29,6 +30,9 @@ void alsaseq_get_port_id_list(guint client_id, guint **entries,
 void alsaseq_get_port_info(guint client_id, guint port_id,
                            ALSASeqPortInfo **port_info, GError **error);
 
+void alsaseq_get_client_pool(gint client_id, ALSASeqClientPool **client_pool,
+                             GError **error);
+
 G_END_DECLS
 
 #endif