From ed4f9cbaa7bc95238c76d8ab52ea08b8adf7290a Mon Sep 17 00:00:00 2001 From: "Geoffrey D. Bennett" Date: Fri, 21 Feb 2025 00:21:12 +1030 Subject: [PATCH] Call card_destroy_callback() when an ALSA element is removed --- src/alsa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/alsa.c b/src/alsa.c index 7b6752a..ed94afa 100644 --- a/src/alsa.c +++ b/src/alsa.c @@ -811,12 +811,18 @@ static gboolean alsa_card_callback( printf("card_callback_error %d\n", err); exit(1); } + if (snd_ctl_event_get_type(event) != SND_CTL_EVENT_ELEM) return 1; int numid = snd_ctl_event_elem_get_numid(event); unsigned int mask = snd_ctl_event_elem_get_mask(event); + if (mask == SND_CTL_EVENT_MASK_REMOVE) { + card_destroy_callback(card); + return 0; + } + if (!(mask & (SND_CTL_EVENT_MASK_VALUE | SND_CTL_EVENT_MASK_INFO))) return 1;