summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlieven moors <lievenmoors@gmail.com>2010-03-15 18:13:11 +0100
committerTakashi Iwai <tiwai@suse.de>2010-03-25 12:21:58 +0100
commitb5f5ebcbe68e92d623e8ca4978042f648aa218cd (patch)
treea9ddcb6d463e4d66f5de2e859e60190941188881
parentf0658f37dc1c416e8f8415971b44afd6977ceb5c (diff)
aconnect -x: Do not update index after removal of connection.
Signed-off-by: lieven moors <lievenmoors@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--seq/aconnect/aconnect.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/seq/aconnect/aconnect.c b/seq/aconnect/aconnect.c
index 1a50666..8c66cfd 100644
--- a/seq/aconnect/aconnect.c
+++ b/seq/aconnect/aconnect.c
@@ -192,52 +192,33 @@ static void remove_connection(snd_seq_t *seq, snd_seq_client_info_t *cinfo,
snd_seq_port_info_t *pinfo, int count)
{
snd_seq_query_subscribe_t *query;
+ snd_seq_port_info_t *port;
+ snd_seq_port_subscribe_t *subs;
snd_seq_query_subscribe_alloca(&query);
snd_seq_query_subscribe_set_root(query, snd_seq_port_info_get_addr(pinfo));
-
snd_seq_query_subscribe_set_type(query, SND_SEQ_QUERY_SUBS_READ);
snd_seq_query_subscribe_set_index(query, 0);
- for (; snd_seq_query_port_subscribers(seq, query) >= 0;
- snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1)) {
- snd_seq_port_info_t *port;
- snd_seq_port_subscribe_t *subs;
+
+ snd_seq_port_info_alloca(&port);
+ snd_seq_port_subscribe_alloca(&subs);
+
+ while (snd_seq_query_port_subscribers(seq, query) >= 0) {
const snd_seq_addr_t *sender = snd_seq_query_subscribe_get_root(query);
const snd_seq_addr_t *dest = snd_seq_query_subscribe_get_addr(query);
- snd_seq_port_info_alloca(&port);
- if (snd_seq_get_any_port_info(seq, dest->client, dest->port, port) < 0)
- continue;
- if (!(snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_SUBS_WRITE))
- continue;
- if (snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_NO_EXPORT)
- continue;
- snd_seq_port_subscribe_alloca(&subs);
- snd_seq_port_subscribe_set_queue(subs, snd_seq_query_subscribe_get_queue(query));
- snd_seq_port_subscribe_set_sender(subs, sender);
- snd_seq_port_subscribe_set_dest(subs, dest);
- snd_seq_unsubscribe_port(seq, subs);
- }
- snd_seq_query_subscribe_set_type(query, SND_SEQ_QUERY_SUBS_WRITE);
- snd_seq_query_subscribe_set_index(query, 0);
- for (; snd_seq_query_port_subscribers(seq, query) >= 0;
- snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1)) {
- snd_seq_port_info_t *port;
- snd_seq_port_subscribe_t *subs;
- const snd_seq_addr_t *dest = snd_seq_query_subscribe_get_root(query);
- const snd_seq_addr_t *sender = snd_seq_query_subscribe_get_addr(query);
- snd_seq_port_info_alloca(&port);
- if (snd_seq_get_any_port_info(seq, sender->client, sender->port, port) < 0)
- continue;
- if (!(snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_SUBS_READ))
+ if (snd_seq_get_any_port_info(seq, dest->client, dest->port, port) < 0 ||
+ !(snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_SUBS_WRITE) ||
+ (snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_NO_EXPORT)) {
+ snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1);
continue;
- if (snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_NO_EXPORT)
- continue;
- snd_seq_port_subscribe_alloca(&subs);
+ }
snd_seq_port_subscribe_set_queue(subs, snd_seq_query_subscribe_get_queue(query));
snd_seq_port_subscribe_set_sender(subs, sender);
snd_seq_port_subscribe_set_dest(subs, dest);
- snd_seq_unsubscribe_port(seq, subs);
+ if (snd_seq_unsubscribe_port(seq, subs) < 0) {
+ snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1);
+ }
}
}