jack: sort midi ports before audio ports

for compatibility reasons return the audio ports before the midi
ports. Most apps just try to link the first hw ports they see and
jack always lists the hw audio ports first.
This commit is contained in:
Wim Taymans 2019-09-19 15:26:06 +02:00
parent f777c04ea6
commit b85b88b53d

View file

@ -3443,7 +3443,7 @@ const char ** jack_get_ports (jack_client_t *client,
int count = 0;
struct object *o;
const char *str;
uint32_t id;
uint32_t i, id;
regex_t port_regex, type_regex;
if ((str = getenv("PIPEWIRE_NODE")) != NULL)
@ -3461,10 +3461,13 @@ const char ** jack_get_ports (jack_client_t *client,
pw_log_debug(NAME" %p: ports id:%d name:%s type:%s flags:%08lx", c, id,
port_name_pattern, type_name_pattern, flags);
for (i = 0; i < 2; i++) {
spa_list_for_each(o, &c->context.ports, link) {
pw_log_debug(NAME" %p: check port type:%d flags:%08lx name:%s", c,
o->port.type_id, o->port.flags, o->port.name);
if (o->port.type_id == 2)
if (count == JACK_PORT_MAX)
break;
if (o->port.type_id != i)
continue;
if (!SPA_FLAG_CHECK(o->port.flags, flags))
continue;
@ -3483,8 +3486,7 @@ const char ** jack_get_ports (jack_client_t *client,
pw_log_debug(NAME" %p: port %s matches (%d)", c, o->port.name, count);
res[count++] = o->port.name;
if (count == JACK_PORT_MAX)
break;
}
}
pw_thread_loop_unlock(c->context.loop);