aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/jack_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-18 19:24:14 +0100
committerMax Kellermann <max@duempel.org>2009-01-18 19:24:14 +0100
commit73e466cfef6497aff840cfac35d80d74e7b0fd0c (patch)
tree2a6281a39d0c1b75aef3a52d98fcfc504f10d261 /src/output/jack_plugin.c
parent86f6233f464a6894b2b63faa87e297f99d61a187 (diff)
downloadmpd-73e466cfef6497aff840cfac35d80d74e7b0fd0c.tar.gz
mpd-73e466cfef6497aff840cfac35d80d74e7b0fd0c.tar.xz
mpd-73e466cfef6497aff840cfac35d80d74e7b0fd0c.zip
jack: parse "ports" setting with g_strsplit()
Don't modify the configured string.
Diffstat (limited to 'src/output/jack_plugin.c')
-rw-r--r--src/output/jack_plugin.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index 8b78d524d..5723a04ca 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -189,7 +189,6 @@ mpd_jack_init(struct audio_output *ao,
struct block_param *bp;
char *endptr;
int val;
- char *cp = NULL;
jd = mpd_jack_new();
jd->ao = ao;
@@ -199,28 +198,16 @@ mpd_jack_init(struct audio_output *ao,
return jd;
if ( (bp = getBlockParam(param, "ports")) ) {
- g_debug("output_ports=%s", bp->value);
+ char **ports = g_strsplit(bp->value, ",", 0);
- if (!(cp = strchr(bp->value, ',')))
- g_error("expected comma and a second value for '%s' "
- "at line %d: %s",
- bp->name, bp->line, bp->value);
+ if (ports[0] == NULL || ports[1] == NULL || ports[2] != NULL)
+ g_error("two port names expected in line %d",
+ bp->line);
- *cp = '\0';
- jd->output_ports[0] = g_strdup(bp->value);
- *cp++ = ',';
+ jd->output_ports[0] = ports[0];
+ jd->output_ports[1] = ports[1];
- if (!*cp)
- g_error("expected a second value for '%s' at line %d: %s",
- bp->name, bp->line, bp->value);
-
- jd->output_ports[1] = g_strdup(cp);
-
- if (strchr(cp,','))
- g_error("Only %d values are supported for '%s' "
- "at line %d",
- (int)G_N_ELEMENTS(jd->output_ports),
- bp->name, bp->line);
+ g_free(ports);
}
if ( (bp = getBlockParam(param, "ringbuffer_size")) ) {