audioadapter: improve error reporting

Improve the debug_params output.
Always either print the failed filter or that there was no filter.
Print the index of the enumerated failed param or a message when
there are no params.

See #2383
This commit is contained in:
Wim Taymans 2022-05-17 09:52:48 +02:00
parent 970b5906a8
commit 411b12f59e

View file

@ -286,14 +286,21 @@ static int debug_params(struct impl *this, struct spa_node *node,
uint8_t buffer[4096]; uint8_t buffer[4096];
uint32_t state; uint32_t state;
struct spa_pod *param; struct spa_pod *param;
int res; int res, count = 0;
spa_log_error(this->log, "params %s: %d:%d (%s) %s", spa_log_error(this->log, "params %s: %d:%d (%s) %s",
spa_debug_type_find_name(spa_type_param, id), spa_debug_type_find_name(spa_type_param, id),
direction, port_id, debug, spa_strerror(err)); direction, port_id, debug, err ? spa_strerror(err) : "no matching params");
if (err == -EBUSY) if (err == -EBUSY)
return 0; return 0;
if (filter) {
spa_log_error(this->log, "with this filter:");
spa_debug_pod(2, NULL, filter);
} else {
spa_log_error(this->log, "there was no filter");
}
state = 0; state = 0;
while (true) { while (true) {
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));
@ -306,12 +313,12 @@ static int debug_params(struct impl *this, struct spa_node *node,
spa_log_error(this->log, " error: %s", spa_strerror(res)); spa_log_error(this->log, " error: %s", spa_strerror(res));
break; break;
} }
spa_log_error(this->log, "unmatched %s %d:", debug, count);
spa_debug_pod(2, NULL, param); spa_debug_pod(2, NULL, param);
count++;
} }
if (count == 0)
spa_log_error(this->log, "failed filter:"); spa_log_error(this->log, "could not get any %s", debug);
if (filter)
spa_debug_pod(2, NULL, filter);
return 0; return 0;
} }