From e1ee4505debf118f8f16c322decf1457061ae979 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 14 Jan 2007 02:08:24 +0000 Subject: jack: fix multiple segfaults when jackd hasn't been started git-svn-id: https://svn.musicpd.org/mpd/trunk@5250 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/audioOutputs/audioOutput_jack.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/audioOutputs') diff --git a/src/audioOutputs/audioOutput_jack.c b/src/audioOutputs/audioOutput_jack.c index 46bbfa668..186f3396f 100644 --- a/src/audioOutputs/audioOutput_jack.c +++ b/src/audioOutputs/audioOutput_jack.c @@ -65,19 +65,28 @@ static void jack_finishDriver(AudioOutput * audioOutput) { JackData *jd = audioOutput->data; - jack_deactivate(jd->client); - jack_client_close(jd->client); + if (jd && jd->client) { + jack_deactivate(jd->client); + jack_client_close(jd->client); + } ERROR("disconnect_jack (pid=%d)\n", getpid ()); if ( strcmp(name, "mpd") ) free(name); if ( output_ports[0] ) free(output_ports[0]); if ( output_ports[1] ) free(output_ports[1]); - jack_ringbuffer_free(jd->ringbuffer[0]); - jack_ringbuffer_free(jd->ringbuffer[1]); - free(jd->samples1); - free(jd->samples2); - free(jd); + if (jd) { + if (jd->ringbuffer[0]) + jack_ringbuffer_free(jd->ringbuffer[0]); + if (jd->ringbuffer[1]) + jack_ringbuffer_free(jd->ringbuffer[1]); + if (jd->samples1) + free(jd->samples1); + if (jd->samples2) + free(jd->samples2); + free(jd); + audioOutput->data = NULL; + } } static int srate(jack_nframes_t rate, void *data) @@ -289,7 +298,7 @@ static int jack_openDevice(AudioOutput *audioOutput) jd = newJackData(); audioOutput->data = jd; - if ( !connect_jack(audioOutput) ) { + if (connect_jack(audioOutput) < 0) { jack_finishDriver(audioOutput); return -1; } -- cgit v1.2.3