From: Takashi Sakamoto Date: Wed, 15 Apr 2020 03:01:03 +0000 (+0900) Subject: seq: addr: add API to compare two instances X-Git-Tag: v0.1.0~147 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=b4c36afbcb7656829ae7d3871aef2404019e00ae;p=alsa-gobject.git seq: addr: add API to compare two instances It's convenient to compare two instances of address in ALSA Sequencer. Signed-off-by: Takashi Sakamoto --- diff --git a/src/seq/addr.c b/src/seq/addr.c index 67950d6..a4a1d56 100644 --- a/src/seq/addr.c +++ b/src/seq/addr.c @@ -50,3 +50,20 @@ void alsaseq_addr_get_port_id(const ALSASeqAddr *self, guint8 *port_id) { *port_id = self->port; } + +/** + * alsaseq_addr_equal: + * @self: A #ALSASeqAddr. + * @target: A #ALSASeqAddr to compare. + * + * Returns: whether the given object indicates the same element. + */ +gboolean alsaseq_addr_equal(const ALSASeqAddr *self, const ALSASeqAddr *target) +{ + const struct snd_seq_addr *lhs, *rhs; + + lhs = (const struct snd_seq_addr *)self; + rhs = (const struct snd_seq_addr *)target; + + return lhs->client == rhs->client && lhs->port == rhs->port; +} diff --git a/src/seq/addr.h b/src/seq/addr.h index 1bf2f46..14628e1 100644 --- a/src/seq/addr.h +++ b/src/seq/addr.h @@ -21,6 +21,8 @@ void alsaseq_addr_get_client_id(const ALSASeqAddr *self, guint8 *client_id); void alsaseq_addr_get_port_id(const ALSASeqAddr *self, guint8 *port_id); +gboolean alsaseq_addr_equal(const ALSASeqAddr *self, const ALSASeqAddr *target); + G_END_DECLS #endif diff --git a/src/seq/alsaseq.map b/src/seq/alsaseq.map index c1e6cc2..f002ff1 100644 --- a/src/seq/alsaseq.map +++ b/src/seq/alsaseq.map @@ -66,6 +66,7 @@ ALSA_GOBJECT_0_0_0 { "alsaseq_addr_new"; "alsaseq_addr_get_client_id"; "alsaseq_addr_get_port_id"; + "alsaseq_addr_equal"; "alsaseq_port_info_get_type"; "alsaseq_port_info_new";