# HG changeset patch # User reimar # Date 1367704552 0 # Node ID 1f8e6c375fc33e30c8724cdf15b0d769f2a809a8 # Parent a8fc00cb36c3eae07ff6f0742cdfcd8e3f84ba57 Make code simpler and more flexible. diff -r a8fc00cb36c3 -r 1f8e6c375fc3 libao2/ao_jack.c --- a/libao2/ao_jack.c Sat May 04 21:44:42 2013 +0000 +++ b/libao2/ao_jack.c Sat May 04 21:55:52 2013 +0000 @@ -245,12 +245,12 @@ if (!port_name) port_flags |= JackPortIsPhysical; matching_ports = jack_get_ports(client, port_name, NULL, port_flags); - if (!matching_ports || !matching_ports[0]) { + i = 0; + while (matching_ports && matching_ports[i]) i++; + if (!i) { mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] no physical ports available\n"); goto err_out; } - i = 1; - while (matching_ports[i]) i++; if (channels > i) channels = i; num_ports = channels; @@ -268,7 +268,7 @@ mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] activate failed\n"); goto err_out; } - for (i = 0; i < num_ports; i++) { + for (i = 0; i < num_ports && matching_ports && matching_ports[i]; i++) { if (jack_connect(client, jack_port_name(ports[i]), matching_ports[i])) { mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] connecting failed\n"); goto err_out;