[alsa-devel] snd_seq_query_port_subscribers not updating subs index

Charles Flèche charles.fleche at gmail.com
Thu Apr 12 16:49:27 CEST 2018


> Sort of, yes

>From the snd_seq_query_port_subscribers doc: "To list up all the
subscriptions, call this function with the index numbers from 0 until this
returns a negative value."

So does it mean than in certain cases snd_seq_query_port_subscribers
increments the index itself, and sometime it does not ?

Thanks, Takashi

On Thu, Apr 12, 2018 at 4:44 PM, Takashi Iwai <tiwai at suse.de> wrote:

> 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);
> >   }
> > }
> >
> > 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.
>
> > 2. Is my fix a correct one or could it leads to other issues ?
>
> It's the correct implementation.
>
>
> HTH,
>
> Takashi
>


More information about the Alsa-devel mailing list