From: Takashi Sakamoto Date: Wed, 1 Apr 2020 09:13:28 +0000 (+0900) Subject: seq: add global method to get information of memory pool for any client X-Git-Tag: v0.1.0~287 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=0e278591157da4673689e9f4b69fc2ca9b1d3bee;p=alsa-gobject.git seq: add global method to get information of memory pool for any client Signed-off-by: Takashi Sakamoto --- diff --git a/src/seq/alsaseq.map b/src/seq/alsaseq.map index d64a61b..cf6cddd 100644 --- a/src/seq/alsaseq.map +++ b/src/seq/alsaseq.map @@ -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"; diff --git a/src/seq/client-pool.c b/src/seq/client-pool.c index 3245b96..6776b25 100644 --- a/src/seq/client-pool.c +++ b/src/seq/client-pool.c @@ -1,7 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -#include "client-pool.h" - -#include +#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; +} diff --git a/src/seq/privates.h b/src/seq/privates.h index 0db1e9f..3d3407a 100644 --- a/src/seq/privates.h +++ b/src/seq/privates.h @@ -10,6 +10,7 @@ #include "system-info.h" #include "client-info.h" #include "port-info.h" +#include "client-pool.h" #include @@ -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 diff --git a/src/seq/query.c b/src/seq/query.c index 402e032..39f5789 100644 --- a/src/seq/query.c +++ b/src/seq/query.c @@ -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); +} diff --git a/src/seq/query.h b/src/seq/query.h index 1713306..e2bb567 100644 --- a/src/seq/query.h +++ b/src/seq/query.h @@ -8,6 +8,7 @@ #include #include #include +#include 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