card: Log initial profile selection

Add logs to pa_card_choose_initial_profile and pa_card_set_profile to
have detailed logging of the profile initialization logic.
This commit is contained in:
João Paulo Rechi Vita 2018-06-20 18:36:59 -07:00 committed by Arun Raghavan
parent 784853004c
commit a720938855

View file

@ -83,7 +83,7 @@ void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available)
c->available = available;
pa_log_debug("Setting card %s profile %s to availability status %s", c->card->name, c->name,
available == PA_AVAILABLE_YES ? "yes" : available == PA_AVAILABLE_NO ? "no" : "unknown");
pa_available_to_string(available));
/* Post subscriptions to the card which owns us */
pa_assert_se(core = c->card->core);
@ -199,7 +199,9 @@ void pa_card_choose_initial_profile(pa_card *card) {
* or if all profiles are unavailable, pick the profile with the highest
* priority regardless of its availability. */
pa_log_debug("Looking for initial profile for card %s", card->name);
PA_HASHMAP_FOREACH(profile, card->profiles, state) {
pa_log_debug("%s availability %s", profile->name, pa_available_to_string(profile->available));
if (profile->available == PA_AVAILABLE_NO)
continue;
@ -217,6 +219,7 @@ void pa_card_choose_initial_profile(pa_card *card) {
card->active_profile = best;
card->save_profile = false;
pa_log_info("%s: active_profile: %s", card->name, card->active_profile->name);
/* Let policy modules override the default. */
pa_hook_fire(&card->core->hooks[PA_CORE_HOOK_CARD_CHOOSE_INITIAL_PROFILE], card);
@ -331,6 +334,7 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
if (c->linked && (r = c->set_profile(c, profile)) < 0)
return r;
pa_log_debug("%s: active_profile: %s -> %s", c->name, c->active_profile->name, profile->name);
c->active_profile = profile;
c->save_profile = save;
@ -338,7 +342,6 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
update_port_preferred_profile(c);
if (c->linked) {
pa_log_info("Changed profile of card %u \"%s\" to %s", c->index, c->name, profile->name);
pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
}