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