From 93d7645d841d4e2c6a84c60b99a8392b8c511eb8 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 6 Sep 2024 12:56:16 +0200 Subject: [PATCH] pcm: close - deactivate async handler before snd_pcm_drop() 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 --- src/pcm/pcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index f8581191..d51e8abd 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -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