aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-29 23:12:16 +0100
committerMax Kellermann <max@duempel.org>2009-01-29 23:12:16 +0100
commit3baeddbcaea54cd45c36c93edd6a1948cd16d102 (patch)
treebecd9147baff1a245bf89c686e3ef97a5a5cb2c3 /src/output
parent5bcf415ad050e404ab5c74b8398e8e1558bcdb17 (diff)
downloadmpd-3baeddbcaea54cd45c36c93edd6a1948cd16d102.tar.gz
mpd-3baeddbcaea54cd45c36c93edd6a1948cd16d102.tar.xz
mpd-3baeddbcaea54cd45c36c93edd6a1948cd16d102.zip
jack: fail if jack_get_ports() returns NULL
When jack_get_ports() returns NULL, we cannot have any ports to connect to, and the device cannot play anything.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/jack_plugin.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index f6d0f9b8c..0159aa633 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -214,8 +214,6 @@ mpd_jack_test_default_device(void)
static int
mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
{
- const char **jports;
-
jd->audio_format = audio_format;
jd->ringbuffer[0] = jack_ringbuffer_create(jd->ringbuffer_size);
@@ -253,10 +251,18 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
return -1;
}
- /* hay que buscar que hay */
- if (!jd->output_ports[1] &&
- (jports = jack_get_ports(jd->client, NULL, NULL,
- JackPortIsPhysical | JackPortIsInput))) {
+ 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) {
+ g_warning("no ports found");
+ return -1;
+ }
+
jd->output_ports[0] = g_strdup(jports[0]);
jd->output_ports[1] = g_strdup(jports[1] != NULL
? jports[1] : jports[0]);
@@ -265,19 +271,17 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
free(jports);
}
- if ( jd->output_ports[1] ) {
- if ( (jack_connect(jd->client, jack_port_name(jd->ports[0]),
- jd->output_ports[0])) != 0 ) {
- g_warning("%s is not a valid Jack Client / Port",
- jd->output_ports[0]);
- return -1;
- }
- if ( (jack_connect(jd->client, jack_port_name(jd->ports[0]),
- jd->output_ports[1])) != 0 ) {
- g_warning("%s is not a valid Jack Client / Port",
- jd->output_ports[1]);
- return -1;
- }
+ if ( (jack_connect(jd->client, jack_port_name(jd->ports[0]),
+ jd->output_ports[0])) != 0 ) {
+ g_warning("%s is not a valid Jack Client / Port",
+ jd->output_ports[0]);
+ return -1;
+ }
+ if ( (jack_connect(jd->client, jack_port_name(jd->ports[0]),
+ jd->output_ports[1])) != 0 ) {
+ g_warning("%s is not a valid Jack Client / Port",
+ jd->output_ports[1]);
+ return -1;
}
return 1;