jack: use jack_port_name() instead of g_malloc()+sprintf()

libjack's jack_port_name() function returns the effective port name,
we don't need to do it manually.
This commit is contained in:
Max Kellermann 2009-01-29 23:12:10 +01:00
parent 67cf2ee6e4
commit 5bcf415ad0

View File

@ -215,7 +215,6 @@ static int
mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format) mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
{ {
const char **jports; const char **jports;
char *port_name;
jd->audio_format = audio_format; jd->audio_format = audio_format;
@ -267,27 +266,18 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
} }
if ( jd->output_ports[1] ) { if ( jd->output_ports[1] ) {
const char *name = mpd_jack_name(jd); if ( (jack_connect(jd->client, jack_port_name(jd->ports[0]),
port_name = g_malloc(sizeof(port_name[0]) * (7 + strlen(name)));
sprintf(port_name, "%s:left", name);
if ( (jack_connect(jd->client, port_name,
jd->output_ports[0])) != 0 ) { jd->output_ports[0])) != 0 ) {
g_warning("%s is not a valid Jack Client / Port", g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[0]); jd->output_ports[0]);
g_free(port_name);
return -1; return -1;
} }
sprintf(port_name, "%s:right", name); if ( (jack_connect(jd->client, jack_port_name(jd->ports[0]),
if ( (jack_connect(jd->client, port_name,
jd->output_ports[1])) != 0 ) { jd->output_ports[1])) != 0 ) {
g_warning("%s is not a valid Jack Client / Port", g_warning("%s is not a valid Jack Client / Port",
jd->output_ports[1]); jd->output_ports[1]);
g_free(port_name);
return -1; return -1;
} }
g_free(port_name);
} }
return 1; return 1;