On Sun, 08 Apr 2018 18:37:58 +0200, Charles Flèche wrote:
Hi all,
I'm iterating through subscribers with snd_seq_query_port_subscribers to disconnect them. It works most of the time, but when a2j (an alsa -> jack MIDI bridge) runs, snd_seq_query_port_subscribers does not update the subs index, and the next call returns 0, leading to an infinite loop. I have to manually increase the index when the disconnection fails (meaning that I hit an a2j connection).
while (snd_seq_query_port_subscribers(seq, subs) >= 0) { addr = *snd_seq_query_subscribe_get_addr(subs); if (snd_seq_disconnect_to(seq, port, addr.client, addr.port) < 0) { snd_seq_query_subscribe_set_index(subs, snd_seq_query_subscribe_get_index(subs) + 1); } }
- Is the non-updated subs index an expected behavior ?
Sort of, yes. It's no iterator operation like query_next_client. It just queries the given index and fills out the result. The user needs to iterate with incrementing the index manually.
- Is my fix a correct one or could it leads to other issues ?
It's the correct implementation.
HTH,
Takashi