mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-09 08:21:08 -04:00
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:
parent
2bf5cd9b56
commit
37be6f8b7b
1 changed files with 11 additions and 7 deletions
|
|
@ -1185,6 +1185,14 @@ static int do_sync_filter_graph(struct spa_loop *loop, bool async, uint32_t seq,
|
||||||
return 0;
|
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)
|
static void clean_filter_handles(struct impl *impl, bool force)
|
||||||
{
|
{
|
||||||
struct filter_graph *g, *t;
|
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)
|
if (impl->setup)
|
||||||
res = setup_filter_graphs(impl, false);
|
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)
|
if (impl->in_filter_props == 0)
|
||||||
clean_filter_handles(impl, false);
|
clean_filter_handles(impl, false);
|
||||||
|
|
@ -2388,10 +2396,7 @@ static int setup_convert(struct impl *this)
|
||||||
this->recalc = true;
|
this->recalc = true;
|
||||||
|
|
||||||
emit_node_info(this, false);
|
emit_node_info(this, false);
|
||||||
if (this->data_loop)
|
sync_filter_graph(this);
|
||||||
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);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2409,6 +2414,7 @@ static void reset_node(struct impl *this)
|
||||||
resample_reset(&this->resample);
|
resample_reset(&this->resample);
|
||||||
this->in_offset = 0;
|
this->in_offset = 0;
|
||||||
this->out_offset = 0;
|
this->out_offset = 0;
|
||||||
|
this->setup = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl_node_send_command(void *object, const struct spa_command *command)
|
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;
|
break;
|
||||||
case SPA_NODE_COMMAND_Suspend:
|
case SPA_NODE_COMMAND_Suspend:
|
||||||
reset_node(this);
|
reset_node(this);
|
||||||
this->setup = false;
|
|
||||||
SPA_FALLTHROUGH;
|
SPA_FALLTHROUGH;
|
||||||
case SPA_NODE_COMMAND_Pause:
|
case SPA_NODE_COMMAND_Pause:
|
||||||
this->started = false;
|
this->started = false;
|
||||||
break;
|
break;
|
||||||
case SPA_NODE_COMMAND_Flush:
|
case SPA_NODE_COMMAND_Flush:
|
||||||
reset_node(this);
|
reset_node(this);
|
||||||
this->setup = false;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue