From 334ae350b4cdd8af2d6d3b4034f58fa0b3ad7f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Wed, 2 Jan 2019 18:14:17 -0800 Subject: [PATCH] card: Only fire the profile available changed hook for linked cards pa_card_profile_set_available needs to check if the card is linked before firing PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED, so callbacks connected to it receive a fully initialized card object. This fixes a crash introduced by commit 30a551bbc "switch-on-port-available: Check if we need to change the active profile". --- src/pulsecore/card.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c index f1628938b..698959671 100644 --- a/src/pulsecore/card.c +++ b/src/pulsecore/card.c @@ -89,7 +89,8 @@ void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available) pa_assert_se(core = c->card->core); pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->card->index); - pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED], c); + if (c->card->linked) + pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED], c); } pa_card_new_data* pa_card_new_data_init(pa_card_new_data *data) {