From: Andre Noll Date: Sun, 5 Sep 2021 16:57:28 +0000 (+0200) Subject: alsa_write: Simplify alsa_post_select(). X-Git-Tag: v0.7.0~22^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=f1fe6d2729f2b0e7b48557d9cc5ddb4412a6bf22;hp=207c1184a2c8af338d6be70e8cb7ede10a5b6a08 alsa_write: Simplify alsa_post_select(). Clean up the private alsa data structure in alsa_close() and teach this function to DTRT even if pad->handle is NULL because alsa_init() failed. --- diff --git a/alsa_write.c b/alsa_write.c index bc06fc31..9822da67 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -240,6 +240,8 @@ static void alsa_close(struct writer_node *wn) if (!pad) return; + if (!pad->handle) + goto free_pad; /* * It's OK to have a blocking operation here because we already made * sure that the PCM output buffer is (nearly) empty. @@ -248,6 +250,7 @@ static void alsa_close(struct writer_node *wn) snd_pcm_drain(pad->handle); snd_pcm_close(pad->handle); snd_config_update_free_global(); +free_pad: free(pad); } @@ -304,11 +307,8 @@ again: PARA_INFO_LOG("%u channel(s), %uHz\n", pad->channels, pad->sample_rate); ret = alsa_init(wn); - if (ret < 0) { - free(wn->private_data); - wn->private_data = NULL; + if (ret < 0) goto err; - } wn->min_iqs = pad->bytes_per_frame; goto again; }