diff --git a/src/alsa.c b/src/alsa.c index d9ae004..7b6752a 100644 --- a/src/alsa.c +++ b/src/alsa.c @@ -766,6 +766,27 @@ static void alsa_elem_change(struct alsa_elem *elem) { } } +static void card_destroy_callback(void *data) { + struct alsa_card *card = data; + + // close the windows associated with this card + destroy_card_window(card); + + // TODO: there is more to free + free(card->device); + free(card->serial); + free(card->name); + free(card); + + // go through the alsa_cards array and clear the entry for this card + for (int i = 0; i < alsa_cards->len; i++) { + struct alsa_card **card_ptr = + &g_array_index(alsa_cards, struct alsa_card *, i); + if (*card_ptr == card) + *card_ptr = NULL; + } +} + static gboolean alsa_card_callback( GIOChannel *source, GIOCondition condition, @@ -853,27 +874,6 @@ struct alsa_card *card_create(int card_num) { return card; } -static void card_destroy_callback(void *data) { - struct alsa_card *card = data; - - // close the windows associated with this card - destroy_card_window(card); - - // TODO: there is more to free - free(card->device); - free(card->serial); - free(card->name); - free(card); - - // go through the alsa_cards array and clear the entry for this card - for (int i = 0; i < alsa_cards->len; i++) { - struct alsa_card **card_ptr = - &g_array_index(alsa_cards, struct alsa_card *, i); - if (*card_ptr == card) - *card_ptr = NULL; - } -} - static void alsa_add_card_callback(struct alsa_card *card) { card->io_channel = g_io_channel_unix_new(card->pfd.fd); card->event_source_id = g_io_add_watch_full(