Arun Raghavan pushed to branch master at PulseAudio / pulseaudio
Commits: a94ae3f2 by João Paulo Rechi Vita at 2018-10-11T13:08:41Z card: Create pa_available_to_string Add a new function to the card API that returns the string representation of a pa_available_t variable. - - - - - d983cde5 by João Paulo Rechi Vita at 2018-10-11T13:08:41Z cli-text: Use pa_available_to_string Replace the local available_to_string with calling pa_available_to_string from card.h. - - - - - 78485300 by João Paulo Rechi Vita at 2018-10-11T13:08:41Z device-port: Use pa_available_to_string Replace using the ternary operator with pa_available_to_string to print value of a pa_available_t. - - - - - a7209388 by João Paulo Rechi Vita at 2018-10-11T13:08:41Z 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. - - - - - 4 changed files: - src/pulsecore/card.c - src/pulsecore/card.h - src/pulsecore/cli-text.c - src/pulsecore/device-port.c Changes: ===================================== src/pulsecore/card.c ===================================== @@ -36,6 +36,19 @@ #include "card.h" +const char *pa_available_to_string(pa_available_t available) { + switch (available) { + case PA_AVAILABLE_UNKNOWN: + return "unknown"; + case PA_AVAILABLE_NO: + return "no"; + case PA_AVAILABLE_YES: + return "yes"; + default: + pa_assert_not_reached(); + } +} + pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra) { pa_card_profile *c; @@ -70,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); @@ -186,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; @@ -204,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); @@ -318,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; @@ -325,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); } ===================================== src/pulsecore/card.h ===================================== @@ -113,6 +113,8 @@ typedef struct { pa_direction_t direction; } pa_card_preferred_port_changed_hook_data; +const char *pa_available_to_string(pa_available_t available); + pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra); void pa_card_profile_free(pa_card_profile *c); ===================================== src/pulsecore/cli-text.c ===================================== @@ -27,6 +27,7 @@ #include <pulsecore/module.h> #include <pulsecore/client.h> +#include <pulsecore/card.h> #include <pulsecore/sink.h> #include <pulsecore/source.h> #include <pulsecore/sink-input.h> @@ -101,19 +102,6 @@ char *pa_client_list_to_string(pa_core *c) { return pa_strbuf_to_string_free(s); } -static const char *available_to_string(pa_available_t a) { - switch (a) { - case PA_AVAILABLE_UNKNOWN: - return "unknown"; - case PA_AVAILABLE_NO: - return "no"; - case PA_AVAILABLE_YES: - return "yes"; - default: - return "invalid"; /* Should never happen! */ - } -} - static void append_port_list(pa_strbuf *s, pa_hashmap *ports) { pa_device_port *p; void *state; @@ -128,7 +116,7 @@ static void append_port_list(pa_strbuf *s, pa_hashmap *ports) { char *t = pa_proplist_to_string_sep(p->proplist, "\n\t\t\t\t"); pa_strbuf_printf(s, "\t\t%s: %s (priority %u, latency offset %" PRId64 " usec, available: %s)\n", p->name, p->description, p->priority, p->latency_offset, - available_to_string(p->available)); + pa_available_to_string(p->available)); pa_strbuf_printf(s, "\t\t\tproperties:\n\t\t\t\t%s\n", t); pa_xfree(t); } @@ -171,7 +159,7 @@ char *pa_card_list_to_string(pa_core *c) { pa_strbuf_puts(s, "\tprofiles:\n"); PA_HASHMAP_FOREACH(profile, card->profiles, state) pa_strbuf_printf(s, "\t\t%s: %s (priority %u, available: %s)\n", profile->name, profile->description, - profile->priority, available_to_string(profile->available)); + profile->priority, pa_available_to_string(profile->available)); pa_strbuf_printf( s, ===================================== src/pulsecore/device-port.c ===================================== @@ -84,8 +84,7 @@ void pa_device_port_set_available(pa_device_port *p, pa_available_t status) { /* pa_assert(status != PA_AVAILABLE_UNKNOWN); */ p->available = status; - pa_log_debug("Setting port %s to status %s", p->name, status == PA_AVAILABLE_YES ? "yes" : - status == PA_AVAILABLE_NO ? "no" : "unknown"); + pa_log_debug("Setting port %s to status %s", p->name, pa_available_to_string(status)); /* Post subscriptions to the card which owns us */ /* XXX: We need to check p->card, because this function may be called View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/compare/cae15753d4d4f7df0ae473aed884b4a6ec400cf5...a720938855575ff78111c788f9cfef100a1a01a4 -- View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/compare/cae15753d4d4f7df0ae473aed884b4a6ec400cf5...a720938855575ff78111c788f9cfef100a1a01a4 You're receiving this email because of your account on gitlab.freedesktop.org.
_______________________________________________ pulseaudio-commits mailing list pulseaudio-commits@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/pulseaudio-commits