diff options
author | Eric Wong <normalperson@yhbt.net> | 2007-01-14 02:08:24 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2007-01-14 02:08:24 +0000 |
commit | e1ee4505debf118f8f16c322decf1457061ae979 (patch) | |
tree | b7da68827ee921db6951cb43964c1603f57baa5e /src/audioOutputs | |
parent | eb2a02dc2bd0c23a887b762d660820f66740443c (diff) | |
download | mpd-e1ee4505debf118f8f16c322decf1457061ae979.tar.gz mpd-e1ee4505debf118f8f16c322decf1457061ae979.tar.xz mpd-e1ee4505debf118f8f16c322decf1457061ae979.zip |
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
Diffstat (limited to 'src/audioOutputs')
-rw-r--r-- | src/audioOutputs/audioOutput_jack.c | 25 |
1 files changed, 17 insertions, 8 deletions
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; } |