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; int count = 0;
struct object *o; struct object *o;
const char *str; const char *str;
uint32_t id; uint32_t i, id;
regex_t port_regex, type_regex; regex_t port_regex, type_regex;
if ((str = getenv("PIPEWIRE_NODE")) != NULL) if ((str = getenv("PIPEWIRE_NODE")) != NULL)
@ -3461,30 +3461,32 @@ 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, pw_log_debug(NAME" %p: ports id:%d name:%s type:%s flags:%08lx", c, id,
port_name_pattern, type_name_pattern, flags); port_name_pattern, type_name_pattern, flags);
spa_list_for_each(o, &c->context.ports, link) { for (i = 0; i < 2; i++) {
pw_log_debug(NAME" %p: check port type:%d flags:%08lx name:%s", c, spa_list_for_each(o, &c->context.ports, link) {
o->port.type_id, o->port.flags, o->port.name); pw_log_debug(NAME" %p: check port type:%d flags:%08lx name:%s", c,
if (o->port.type_id == 2) o->port.type_id, o->port.flags, o->port.name);
continue; if (count == JACK_PORT_MAX)
if (!SPA_FLAG_CHECK(o->port.flags, flags)) break;
continue; if (o->port.type_id != i)
if (id != SPA_ID_INVALID && o->port.node_id != id)
continue;
if (port_name_pattern && port_name_pattern[0]) {
if (regexec(&port_regex, o->port.name, 0, NULL, 0) == REG_NOMATCH)
continue; continue;
} if (!SPA_FLAG_CHECK(o->port.flags, flags))
if (type_name_pattern && type_name_pattern[0]) { continue;
if (regexec(&type_regex, type_to_string(o->port.type_id), if (id != SPA_ID_INVALID && o->port.node_id != id)
0, NULL, 0) == REG_NOMATCH)
continue; continue;
}
pw_log_debug(NAME" %p: port %s matches (%d)", c, o->port.name, count); if (port_name_pattern && port_name_pattern[0]) {
res[count++] = o->port.name; if (regexec(&port_regex, o->port.name, 0, NULL, 0) == REG_NOMATCH)
if (count == JACK_PORT_MAX) continue;
break; }
if (type_name_pattern && type_name_pattern[0]) {
if (regexec(&type_regex, type_to_string(o->port.type_id),
0, NULL, 0) == REG_NOMATCH)
continue;
}
pw_log_debug(NAME" %p: port %s matches (%d)", c, o->port.name, count);
res[count++] = o->port.name;
}
} }
pw_thread_loop_unlock(c->context.loop); pw_thread_loop_unlock(c->context.loop);