]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: close - deactivate async handler before snd_pcm_drop()
authorJaroslav Kysela <perex@perex.cz>
Fri, 6 Sep 2024 10:56:16 +0000 (12:56 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 6 Sep 2024 10:58:14 +0000 (12:58 +0200)
It reduces probablity to activate the async handler when snd_pcm_close() is called.

Link: https://github.com/alsa-project/alsa-lib/issues/394
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm.c

index f8581191964b49929417a9b1be612d013c9fe9ef..d51e8abdeda54264ab4a08f2bb7bc72f8214021a 100644 (file)
@@ -777,6 +777,10 @@ int snd_pcm_close(snd_pcm_t *pcm)
 {
        int res = 0, err;
        assert(pcm);
+       while (!list_empty(&pcm->async_handlers)) {
+               snd_async_handler_t *h = list_entry(pcm->async_handlers.next, snd_async_handler_t, hlist);
+               snd_async_del_handler(h);
+       }
        if (pcm->setup && !pcm->donot_close) {
                snd_pcm_drop(pcm);
                err = snd_pcm_hw_free(pcm);
@@ -785,10 +789,6 @@ int snd_pcm_close(snd_pcm_t *pcm)
        }
        if (pcm->mmap_channels)
                snd_pcm_munmap(pcm);
-       while (!list_empty(&pcm->async_handlers)) {
-               snd_async_handler_t *h = list_entry(pcm->async_handlers.next, snd_async_handler_t, hlist);
-               snd_async_del_handler(h);
-       }
        if (pcm->ops->close)
                err = pcm->ops->close(pcm->op_arg);
        else