From 38276d126c0b29bf85e5a6464188feda1349aaa5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 1 Oct 2020 13:12:19 +0200 Subject: [PATCH] acp: improve debug --- spa/plugins/alsa/acp-tool.c | 35 +++++------------------------- spa/plugins/alsa/acp/acp.c | 25 ++++++++++++++++++++- spa/plugins/alsa/acp/acp.h | 4 ++++ spa/plugins/alsa/alsa-acp-device.c | 9 +++++--- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/spa/plugins/alsa/acp-tool.c b/spa/plugins/alsa/acp-tool.c index 1e4bce717..bd310cb8f 100644 --- a/spa/plugins/alsa/acp-tool.c +++ b/spa/plugins/alsa/acp-tool.c @@ -42,29 +42,6 @@ struct data { bool quit; }; -static const char *str_available(enum acp_available status) -{ - switch (status) { - case ACP_AVAILABLE_UNKNOWN: - return "unknown"; - case ACP_AVAILABLE_NO: - return "no"; - case ACP_AVAILABLE_YES: - return "yes"; - } - return "error"; -} - -static const char *str_direction(enum acp_direction direction) -{ - switch (direction) { - case ACP_DIRECTION_CAPTURE: - return "capture"; - case ACP_DIRECTION_PLAYBACK: - return "playback"; - } - return "error"; -} static const char *str_port_type(enum acp_port_type type) { switch (type) { @@ -182,7 +159,7 @@ static void card_profile_available(void *data, uint32_t index, struct data *d = data; struct acp_card *card = d->card; struct acp_card_profile *p = card->profiles[index]; - fprintf(stderr, "*** profile %s available %s\n", p->name, str_available(available)); + fprintf(stderr, "*** profile %s available %s\n", p->name, acp_available_str(available)); } static void card_port_available(void *data, uint32_t index, @@ -191,7 +168,7 @@ static void card_port_available(void *data, uint32_t index, struct data *d = data; struct acp_card *card = d->card; struct acp_port *p = card->ports[index]; - fprintf(stderr, "*** port %s available %s\n", p->name, str_available(available)); + fprintf(stderr, "*** port %s available %s\n", p->name, acp_available_str(available)); } static void on_volume_changed(void *data, struct acp_device *dev) @@ -257,9 +234,9 @@ static void print_port(struct data *data, struct acp_port *p, int indent, int le fprintf(stderr, "%*s %c port %u: name:\"%s\" direction:%s prio:%d group:%s type:%s (available: %s)\n", indent, "", p->flags & ACP_PORT_ACTIVE ? '*' : ' ', p->index, - p->name, str_direction(p->direction), p->priority, + p->name, acp_direction_str(p->direction), p->priority, p->availability_group, str_port_type(p->type), - str_available(p->available)); + acp_available_str(p->available)); if (level > 0) { acp_debug_dict(&p->props, indent + 8); } @@ -284,7 +261,7 @@ static void print_device(struct data *data, struct acp_device *d, int indent, in fprintf(stderr, "%*s %c device %u: direction:%s name:\"%s\" prio:%d flags:%08x devices: ", indent, "", d->flags & ACP_DEVICE_ACTIVE ? '*' : ' ', d->index, - str_direction(d->direction), d->name, d->priority, d->flags); + acp_direction_str(d->direction), d->name, d->priority, d->flags); for (s = d->device_strings; *s; s++) fprintf(stderr, "\"%s\" ", *s); fprintf(stderr, "\n"); @@ -308,7 +285,7 @@ static void print_profile(struct data *data, struct acp_card_profile *p, int ind fprintf(stderr, "%*s %c profile %u: name:\"%s\" prio:%d (available: %s)\n", indent, "", p->flags & ACP_PROFILE_ACTIVE ? '*' : ' ', p->index, - p->name, p->priority, str_available(p->available)); + p->name, p->priority, acp_available_str(p->available)); if (level > 0) { fprintf(stderr, "%*sdescription:\"%s\"\n", indent+8, "", p->description); diff --git a/spa/plugins/alsa/acp/acp.c b/spa/plugins/alsa/acp/acp.c index 35a6dfc97..23f84f7ce 100644 --- a/spa/plugins/alsa/acp/acp.c +++ b/spa/plugins/alsa/acp/acp.c @@ -32,6 +32,30 @@ void *_acp_log_data; #define VOLUME_ACCURACY (PA_VOLUME_NORM/100) /* don't require volume adjustments to be perfectly correct. don't necessarily extend granularity in software unless the differences get greater than this level */ +const char *acp_available_str(enum acp_available status) +{ + switch (status) { + case ACP_AVAILABLE_UNKNOWN: + return "unknown"; + case ACP_AVAILABLE_NO: + return "no"; + case ACP_AVAILABLE_YES: + return "yes"; + } + return "error"; +} + +const char *acp_direction_str(enum acp_direction direction) +{ + switch (direction) { + case ACP_DIRECTION_CAPTURE: + return "capture"; + case ACP_DIRECTION_PLAYBACK: + return "playback"; + } + return "error"; +} + static void profile_free(void *data) { } @@ -421,7 +445,6 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) found_available_input_port = true; } else { has_output_port = true; - if (port->port.available != ACP_AVAILABLE_NO) found_available_output_port = true; } diff --git a/spa/plugins/alsa/acp/acp.h b/spa/plugins/alsa/acp/acp.h index ad10672da..1a0fcccd0 100644 --- a/spa/plugins/alsa/acp/acp.h +++ b/spa/plugins/alsa/acp/acp.h @@ -77,12 +77,16 @@ enum acp_direction { ACP_DIRECTION_CAPTURE = 2 }; +const char *acp_direction_str(enum acp_direction direction); + enum acp_available { ACP_AVAILABLE_UNKNOWN = 0, ACP_AVAILABLE_NO = 1, ACP_AVAILABLE_YES = 2 }; +const char *acp_available_str(enum acp_available status); + /** Port type. New types can be added in the future, so applications should * gracefully handle situations where a type identifier doesn't match any item * in this enumeration. */ diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index 2dd18e7ca..68007f283 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -662,7 +662,9 @@ static void card_profile_available(void *data, uint32_t index, struct impl *this = data; struct acp_card *card = this->card; struct acp_card_profile *p = card->profiles[index]; - spa_log_info(this->log, "card profile %s available %d", p->name, available); + + spa_log_info(this->log, "card profile %s available %s -> %s", p->name, + acp_available_str(old), acp_available_str(available)); this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS; this->params[IDX_EnumProfile].flags ^= SPA_PARAM_INFO_SERIAL; @@ -696,8 +698,9 @@ static void card_port_available(void *data, uint32_t index, struct impl *this = data; struct acp_card *card = this->card; struct acp_port *p = card->ports[index]; - spa_log_info(this->log, "card port %s available %d->%d", - p->name, old, available); + + spa_log_info(this->log, "card port %s available %s -> %s", p->name, + acp_available_str(old), acp_available_str(available)); this->info.change_mask |= SPA_DEVICE_CHANGE_MASK_PARAMS; this->params[IDX_EnumRoute].flags ^= SPA_PARAM_INFO_SERIAL;