I could figure it, finally: snd_seq_get_any_client_info
to get informations about the first client (there should be at least one, the system one) and snd_seq_query_next_client
. to get the next one.
Here is a snippet to list MIDI clients:
static void list_clients(void) {
int count = 0;
int status;
snd_seq_client_info_t* info;
snd_seq_client_info_alloca(&info);
status = snd_seq_get_any_client_info(seq_handle, 0, info);
while (status >= 0) {
count += 1;
int id = snd_seq_client_info_get_client(info);
char const* name = snd_seq_client_info_get_name(info);
int num_ports = snd_seq_client_info_get_num_ports(info);
printf("Client ā%sā #%i, with %i ports\n", name, id, num_ports);
status = snd_seq_query_next_client(seq_handle, info);
}
printf("Found %i clients\n", count);
}
The snippet assumes seq_handle
is declared and initialized elsewhere (initialized with snd_seq_open
).
The use of 0
as the client ID in the invocation of snd_seq_get_any_client_info
, is a guess: ALSA uses negative numbers for errors, so I guess the first valid client ID is 0.