audioconvert: refactor some code

We sync the filter graph in two places, make a function so that both
places do the same thing.

Make node_reset clear the setup flag so that we don't have to do that
twice.
This commit is contained in:
Wim Taymans 2025-12-09 21:01:11 +01:00 committed by Arun Raghavan
parent 2bf5cd9b56
commit 37be6f8b7b

View file

@ -1185,6 +1185,14 @@ static int do_sync_filter_graph(struct spa_loop *loop, bool async, uint32_t seq,
return 0;
}
static void sync_filter_graph(struct impl *impl)
{
if (impl->data_loop)
spa_loop_invoke(impl->data_loop, do_sync_filter_graph, 0, NULL, 0, true, impl);
else
do_sync_filter_graph(NULL, false, 0, NULL, 0, impl);
}
static void clean_filter_handles(struct impl *impl, bool force)
{
struct filter_graph *g, *t;
@ -1271,7 +1279,7 @@ static int load_filter_graph(struct impl *impl, const char *graph, int order)
if (impl->setup)
res = setup_filter_graphs(impl, false);
spa_loop_invoke(impl->data_loop, do_sync_filter_graph, 0, NULL, 0, true, impl);
sync_filter_graph(impl);
if (impl->in_filter_props == 0)
clean_filter_handles(impl, false);
@ -2388,10 +2396,7 @@ static int setup_convert(struct impl *this)
this->recalc = true;
emit_node_info(this, false);
if (this->data_loop)
spa_loop_invoke(this->data_loop, do_sync_filter_graph, 0, NULL, 0, true, this);
else
do_sync_filter_graph(NULL, false, 0, NULL, 0, this);
sync_filter_graph(this);
return 0;
}
@ -2409,6 +2414,7 @@ static void reset_node(struct impl *this)
resample_reset(&this->resample);
this->in_offset = 0;
this->out_offset = 0;
this->setup = false;
}
static int impl_node_send_command(void *object, const struct spa_command *command)
@ -2429,14 +2435,12 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
break;
case SPA_NODE_COMMAND_Suspend:
reset_node(this);
this->setup = false;
SPA_FALLTHROUGH;
case SPA_NODE_COMMAND_Pause:
this->started = false;
break;
case SPA_NODE_COMMAND_Flush:
reset_node(this);
this->setup = false;
break;
default:
return -ENOTSUP;