aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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;
}