filter-graph: error when there are no valid nodes

The nodes might have failed to load or there was an empty array or the
array did not contain objects.
This commit is contained in:
Wim Taymans 2026-05-07 13:30:41 +02:00
parent 142d3d7896
commit 925e071a26
2 changed files with 5 additions and 2 deletions

View file

@ -2092,6 +2092,10 @@ static int load_graph(struct graph *graph, const struct spa_dict *props)
if ((res = load_node(graph, &it[1])) < 0) if ((res = load_node(graph, &it[1])) < 0)
return res; return res;
} }
if (spa_list_is_empty(&graph->node_list)) {
spa_log_error(impl->log, "filter.graph has no nodes");
return -EINVAL;
}
if (plinks != NULL) { if (plinks != NULL) {
while (spa_json_enter_object(plinks, &it[1]) > 0) { while (spa_json_enter_object(plinks, &it[1]) > 0) {
if ((res = parse_link(graph, &it[1])) < 0) if ((res = parse_link(graph, &it[1])) < 0)
@ -2144,7 +2148,6 @@ static int load_graph(struct graph *graph, const struct spa_dict *props)
else else
graph->default_outputs = last->desc->n_output; graph->default_outputs = last->desc->n_output;
return 0; return 0;
} }

View file

@ -1191,7 +1191,7 @@ static const struct pw_stream_events out_stream_events = {
static int setup_streams(struct impl *impl) static int setup_streams(struct impl *impl)
{ {
int res; int res = 0;
uint32_t i, n_params, *offs; uint32_t i, n_params, *offs;
struct pw_array offsets; struct pw_array offsets;
const struct spa_pod **params = NULL; const struct spa_pod **params = NULL;