From ad70d7943a3caffc11046bf78d8165e4d229580f Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Wed, 1 Apr 2020 18:13:28 +0900 Subject: [PATCH] seq: user_client: add APIs to set/get memory pool in client Signed-off-by: Takashi Sakamoto --- src/seq/alsaseq.map | 2 ++ src/seq/user-client.c | 51 +++++++++++++++++++++++++++++++++++++++ src/seq/user-client.h | 9 +++++++ tests/alsaseq-user-client | 2 ++ 4 files changed, 64 insertions(+) diff --git a/src/seq/alsaseq.map b/src/seq/alsaseq.map index cf6cddd..b05a348 100644 --- a/src/seq/alsaseq.map +++ b/src/seq/alsaseq.map @@ -40,6 +40,8 @@ ALSA_GOBJECT_0_0_0 { "alsaseq_user_client_create_port"; "alsaseq_user_client_update_port"; "alsaseq_user_client_delete_port"; + "alsaseq_user_client_set_pool"; + "alsaseq_user_client_get_pool"; "alsaseq_addr_get_type"; "alsaseq_addr_new"; diff --git a/src/seq/user-client.c b/src/seq/user-client.c index d33bd44..fb3fd50 100644 --- a/src/seq/user-client.c +++ b/src/seq/user-client.c @@ -261,3 +261,54 @@ void alsaseq_user_client_delete_port(ALSASeqUserClient *self, if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_DELETE_PORT, info) < 0) generate_error(error, errno); } + +/** + * alsaseq_user_client_set_pool: + * @self: A #ALSASeqUserClient. + * @client_pool: A #ALSASeqClientPool to be configured for the client. + * @error: A #GError. + * + * Configure memory pool in the client. + */ +void alsaseq_user_client_set_pool(ALSASeqUserClient *self, + ALSASeqClientPool *client_pool, + GError **error) +{ + ALSASeqUserClientPrivate *priv; + struct snd_seq_client_pool *pool; + + g_return_if_fail(ALSASEQ_IS_USER_CLIENT(self)); + g_return_if_fail(ALSASEQ_IS_CLIENT_POOL(client_pool)); + priv = alsaseq_user_client_get_instance_private(self); + + seq_client_pool_refer_private(client_pool, &pool); + pool->client = priv->client_id; + if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_SET_CLIENT_POOL, pool) < 0) + generate_error(error, errno); +} + +/** + * alsaseq_user_client_get_pool: + * @self: A #ALSASeqUserClient. + * @client_pool: (inout): A #ALSASeqClientPool to be configured for the client. + * @error: A #GError. + * + * Get information of memory pool in the client. + */ +void alsaseq_user_client_get_pool(ALSASeqUserClient *self, + ALSASeqClientPool *const *client_pool, + GError **error) +{ + ALSASeqUserClientPrivate *priv; + struct snd_seq_client_pool *pool; + + g_return_if_fail(ALSASEQ_IS_USER_CLIENT(self)); + g_return_if_fail(*client_pool != NULL); + g_return_if_fail(ALSASEQ_IS_CLIENT_POOL(*client_pool)); + priv = alsaseq_user_client_get_instance_private(self); + + seq_client_pool_refer_private(*client_pool, &pool); + pool->client = priv->client_id; + if (ioctl(priv->fd, SNDRV_SEQ_IOCTL_GET_CLIENT_POOL, pool) < 0) + generate_error(error, errno); +} diff --git a/src/seq/user-client.h b/src/seq/user-client.h index 1bbe191..fa98f35 100644 --- a/src/seq/user-client.h +++ b/src/seq/user-client.h @@ -7,6 +7,7 @@ #include #include +#include G_BEGIN_DECLS @@ -72,6 +73,14 @@ void alsaseq_user_client_delete_port(ALSASeqUserClient *self, ALSASeqPortInfo *port_info, guint8 port_id, GError **error); +void alsaseq_user_client_set_pool(ALSASeqUserClient *self, + ALSASeqClientPool *client_pool, + GError **error); + +void alsaseq_user_client_get_pool(ALSASeqUserClient *self, + ALSASeqClientPool *const *client_pool, + GError **error); + G_END_DECLS #endif diff --git a/tests/alsaseq-user-client b/tests/alsaseq-user-client index 72d7900..90960ef 100644 --- a/tests/alsaseq-user-client +++ b/tests/alsaseq-user-client @@ -21,6 +21,8 @@ methods = ( 'create_port', 'update_port', 'delete_port', + 'set_pool', + 'get_pool', ) signals = () -- 2.47.3