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".
This commit is contained in:
João Paulo Rechi Vita 2019-01-02 18:14:17 -08:00 committed by Tanu Kaskinen
parent a5f25af043
commit 334ae350b4

View file

@ -89,6 +89,7 @@ void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available)
pa_assert_se(core = c->card->core); pa_assert_se(core = c->card->core);
pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->card->index); pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->card->index);
if (c->card->linked)
pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED], c); pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED], c);
} }