aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-30 19:44:58 +0100
committerMax Kellermann <max@duempel.org>2009-01-30 19:44:58 +0100
commiteeec32feaa83a6a83b7bec1e0c47079145ba90d8 (patch)
treedf81086554ee6b603fbc82cd0ebfcd69840260e5 /src
parenta93e73bea8dd7659d2af6f3a3045e8a3406263fc (diff)
downloadmpd-eeec32feaa83a6a83b7bec1e0c47079145ba90d8.tar.gz
mpd-eeec32feaa83a6a83b7bec1e0c47079145ba90d8.tar.xz
mpd-eeec32feaa83a6a83b7bec1e0c47079145ba90d8.zip
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.
Diffstat (limited to '')
-rw-r--r--src/output/jack_plugin.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index 3a2fc7cad..4d2f3dfbf 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -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;
}