aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/jack_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-29 18:11:30 +0100
committerMax Kellermann <max@duempel.org>2009-01-29 18:12:52 +0100
commit3a070d3d23052d4306a2ef26b89585d96e235129 (patch)
tree5887f9dc48995617d7487cda6f28273f35327de2 /src/output/jack_plugin.c
parentbbf0453709dd4e1e24d0ee7874aab7aae7c9b303 (diff)
downloadmpd-3a070d3d23052d4306a2ef26b89585d96e235129.tar.gz
mpd-3a070d3d23052d4306a2ef26b89585d96e235129.tar.xz
mpd-3a070d3d23052d4306a2ef26b89585d96e235129.zip
jack: allocate ring buffers before connecting
If the ring buffers are allocated after jack_activate(), mpd_jack_process() might segfault because it attempts to access them.
Diffstat (limited to 'src/output/jack_plugin.c')
-rw-r--r--src/output/jack_plugin.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/output/jack_plugin.c b/src/output/jack_plugin.c
index c05f6a77d..d16eb0443 100644
--- a/src/output/jack_plugin.c
+++ b/src/output/jack_plugin.c
@@ -217,6 +217,9 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
jd->audio_format = audio_format;
+ jd->ringbuffer[0] = jack_ringbuffer_create(jd->ringbuffer_size);
+ jd->ringbuffer[1] = jack_ringbuffer_create(jd->ringbuffer_size);
+
if ((jd->client = jack_client_new(mpd_jack_name(jd))) == NULL) {
g_warning("jack server not running?");
return -1;
@@ -263,11 +266,6 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
if ( jd->output_ports[1] ) {
const char *name = mpd_jack_name(jd);
- jd->ringbuffer[0] = jack_ringbuffer_create(jd->ringbuffer_size);
- jd->ringbuffer[1] = jack_ringbuffer_create(jd->ringbuffer_size);
- memset(jd->ringbuffer[0]->buf, 0, jd->ringbuffer[0]->size);
- memset(jd->ringbuffer[1]->buf, 0, jd->ringbuffer[1]->size);
-
port_name = g_malloc(sizeof(port_name[0]) * (7 + strlen(name)));
sprintf(port_name, "%s:left", name);