commit 55e472d4ca2bc78f5d638a5574fe898050b7a0d4 sin <sin@2f30.org> 2014-12-31 15:14:04 +0000 Correctly cleanup if an error occurs in the alsa backend
alsa.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/alsa.c b/alsa.c index cbc36aa..2d70b36 100644 --- a/alsa.c +++ b/alsa.c @@ -31,10 +31,16 @@ alsaopen(int bits, int rate, int channels) if ((r = snd_pcm_set_params(hdl, format, SND_PCM_ACCESS_RW_INTERLEAVED, channels, rate, 1, 500000)) < 0) { warnx("send_pcm_set_params: %s\n", snd_strerror(r)); - return -1; + goto err0; } + framesize = (bits + 7) / 8 * channels; return 0; + +err0: + snd_pcm_close(hdl); + hdl = NULL; + return -1; } static int