alsa: Close writer in post_select() on errors/eof.
authorAndre Noll <maan@systemlinux.org>
Thu, 31 Dec 2009 15:13:53 +0000 (16:13 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 31 Dec 2009 15:13:53 +0000 (16:13 +0100)
alsa_write.c

index f8c192b..c7b09f3 100644 (file)
@@ -315,6 +315,19 @@ static int alsa_write_post_select(__a_unused struct sched *s,
        return -E_ALSA_WRITE;
 }
 
+static void alsa_close(struct writer_node *wn)
+{
+       struct private_alsa_write_data *pad = wn->private_data;
+       PARA_INFO_LOG("closing writer node %p\n", wn);
+
+       if (pad->handle) {
+               snd_pcm_drain(pad->handle);
+               snd_pcm_close(pad->handle);
+               snd_config_update_free_global();
+       }
+       free(pad);
+}
+
 static void alsa_write_post_select_btr(__a_unused struct sched *s,
                struct task *t)
 {
@@ -372,24 +385,12 @@ again:
        ret = -E_ALSA_WRITE;
 err:
        assert(ret < 0);
+       alsa_close(wn);
        btr_del_node(wn->btrn);
        wn->btrn = NULL;
        t->error = ret;
 }
 
-static void alsa_close(struct writer_node *wn)
-{
-       struct private_alsa_write_data *pad = wn->private_data;
-       PARA_INFO_LOG("closing writer node %p\n", wn);
-
-       if (pad->handle) {
-               snd_pcm_drain(pad->handle);
-               snd_pcm_close(pad->handle);
-               snd_config_update_free_global();
-       }
-       free(pad);
-}
-
 __malloc static void *alsa_parse_config(const char *options)
 {
        int ret;