link: activate before start

Activate the link before we start the nodes to make sure we are
linked when the nodes start to push things.
This commit is contained in:
Wim Taymans 2017-10-18 10:05:06 +02:00
parent 530caf35db
commit f19edc16ab

View file

@ -671,6 +671,15 @@ static int do_allocation(struct pw_link *this, uint32_t in_state, uint32_t out_s
return res; return res;
} }
static int
do_activate_link(struct spa_loop *loop,
bool async, uint32_t seq, size_t size, const void *data, void *user_data)
{
struct pw_link *this = user_data;
spa_graph_port_link(&this->rt.out_port, &this->rt.in_port);
return SPA_RESULT_OK;
}
static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state) static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state)
{ {
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
@ -686,6 +695,9 @@ static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state)
input = this->input; input = this->input;
output = this->output; output = this->output;
pw_loop_invoke(output->node->data_loop,
do_activate_link, SPA_ID_INVALID, 0, NULL, false, this);
if (in_state == PW_PORT_STATE_PAUSED) { if (in_state == PW_PORT_STATE_PAUSED) {
if ((res = pw_node_set_state(input->node, PW_NODE_STATE_RUNNING)) < 0) { if ((res = pw_node_set_state(input->node, PW_NODE_STATE_RUNNING)) < 0) {
asprintf(&error, "error starting input node: %d", res); asprintf(&error, "error starting input node: %d", res);
@ -715,15 +727,6 @@ static int do_start(struct pw_link *this, uint32_t in_state, uint32_t out_state)
return res; return res;
} }
static int
do_activate_link(struct spa_loop *loop,
bool async, uint32_t seq, size_t size, const void *data, void *user_data)
{
struct pw_link *this = user_data;
spa_graph_port_link(&this->rt.out_port, &this->rt.in_port);
return SPA_RESULT_OK;
}
static int check_states(struct pw_link *this, void *user_data, int res) static int check_states(struct pw_link *this, void *user_data, int res)
{ {
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
@ -754,8 +757,6 @@ static int check_states(struct pw_link *this, void *user_data, int res)
} }
if (in_state == PW_PORT_STATE_STREAMING && out_state == PW_PORT_STATE_STREAMING) { if (in_state == PW_PORT_STATE_STREAMING && out_state == PW_PORT_STATE_STREAMING) {
pw_loop_invoke(output->node->data_loop,
do_activate_link, SPA_ID_INVALID, 0, NULL, false, this);
pw_link_update_state(this, PW_LINK_STATE_RUNNING, NULL); pw_link_update_state(this, PW_LINK_STATE_RUNNING, NULL);
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }