filter-chain: improve json parsing error reporting

Warn when an invalid key is parsed instead of silently ignoring it.
This commit is contained in:
Wim Taymans 2024-03-25 14:19:45 +01:00
parent ac6011dfa5
commit dfe18ca996
1 changed files with 24 additions and 9 deletions

View File

@ -1953,8 +1953,11 @@ static int parse_link(struct graph *graph, struct spa_json *json)
return -EINVAL;
}
}
else if (spa_json_next(json, &val) < 0)
break;
else {
pw_log_error("unexpected link key '%s'", key);
if (spa_json_next(json, &val) < 0)
break;
}
}
def_out_node = spa_list_first(&graph->node_list, struct node, link);
def_in_node = spa_list_last(&graph->node_list, struct node, link);
@ -2064,8 +2067,11 @@ static int parse_volume(struct graph *graph, struct spa_json *json, bool capture
return -EINVAL;
}
}
else if (spa_json_next(json, &val) < 0)
break;
else {
pw_log_error("unexpected volume key '%s'", key);
if (spa_json_next(json, &val) < 0)
break;
}
}
if (capture)
def_control = spa_list_first(&graph->node_list, struct node, link);
@ -2160,12 +2166,18 @@ static int load_node(struct graph *graph, struct spa_json *json)
have_config = true;
if (spa_json_next(json, &val) < 0)
break;
} else if (spa_json_next(json, &val) < 0)
break;
} else {
pw_log_warn("unexpected node key '%s'", key);
if (spa_json_next(json, &val) < 0)
break;
}
}
if (spa_streq(type, "builtin"))
snprintf(plugin, sizeof(plugin), "%s", "builtin");
else if (spa_streq(type, "")) {
pw_log_error("missing plugin type");
return -EINVAL;
}
pw_log_info("loading type:%s plugin:%s label:%s", type, plugin, label);
@ -2754,8 +2766,11 @@ static int load_graph(struct graph *graph, struct pw_properties *props)
return -EINVAL;
}
ppvolumes = &pvolumes;
} else if (spa_json_next(&it[1], &val) < 0)
break;
} else {
pw_log_warn("unexpected graph key '%s'", key);
if (spa_json_next(&it[1], &val) < 0)
break;
}
}
if (pnodes == NULL) {
pw_log_error("filter.graph is missing a nodes array");