jack: don't override output_ports in connect()

If no ports are configured, don't overwrite the (NULL) configuration
with the port names of the first JACK server.  If the server changes
after a JACK reconnect, MPD won't attempt to auto-detect again.
This commit is contained in:
Max Kellermann 2009-01-30 19:44:58 +01:00
parent a93e73bea8
commit eeec32feaa

View File

@ -213,6 +213,8 @@ mpd_jack_test_default_device(void)
static bool
mpd_jack_connect(struct jack_data *jd)
{
const char *output_ports[2], **jports;
for (unsigned i = 0; i < G_N_ELEMENTS(jd->ringbuffer); ++i)
jd->ringbuffer[i] =
jack_ringbuffer_create(jd->ringbuffer_size);
@ -246,8 +248,6 @@ mpd_jack_connect(struct jack_data *jd)
if (jd->output_ports[1] == NULL) {
/* no output ports were configured - ask libjack for
defaults */
const char **jports;
jports = jack_get_ports(jd->client, NULL, NULL,
JackPortIsPhysical | JackPortIsInput);
if (jports == NULL) {
@ -255,26 +255,38 @@ mpd_jack_connect(struct jack_data *jd)
return false;
}
jd->output_ports[0] = g_strdup(jports[0]);
jd->output_ports[1] = g_strdup(jports[1] != NULL
? jports[1] : jports[0]);
g_debug("output_ports: %s %s",
jd->output_ports[0], jd->output_ports[1]);
free(jports);
output_ports[0] = jports[0];
output_ports[1] = jports[1] != NULL ? jports[1] : jports[0];
g_debug("output_ports: %s %s", jports[0], jports[1]);
} else {
/* use the configured output ports */
output_ports[0] = jd->output_ports[0];
output_ports[1] = jd->output_ports[1];
jports = NULL;
}
for (unsigned i = 0; i < G_N_ELEMENTS(jd->ports); ++i) {
int ret;
ret = jack_connect(jd->client, jack_port_name(jd->ports[i]),
jd->output_ports[i]);
output_ports[i]);
if (ret != 0) {
g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[i]);
output_ports[i]);
if (jports != NULL)
free(jports);
return false;
}
}
if (jports != NULL)
free(jports);
return true;
}