commit 55e472d4ca2bc78f5d638a5574fe898050b7a0d4
parent 57bc72dd3e8d5310cd56057b40a2c8adb54b5300
Author: sin <sin@2f30.org>
Date: Wed, 31 Dec 2014 15:14:04 +0000
Correctly cleanup if an error occurs in the alsa backend
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git 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