node: add new NEED_CONFIGURE flag

Add a new node flag that is set when the node needs more configuration.
Don't try to Start nodes that have the NEED_CONFIGURE flag set.
Make audioadapter clear the NEED_CONFIGURE flag when it has the
PortConfig.

These changes now make it possible to run:

gst-launch-1.0 -v pipewiresrc path=51 stream-properties="props,node.group=1" ! audio/x-raw ! pipewiresink stream-properties="props,node.group=1"

The pipewiresink and pipewiresrc will be added to the same scheduling
group (1) and the devices they connect to will be slaved, even if they
are otherwise not linked.

Without the NEED_CONFIGURE flag, pipewiresink would be added to the
pipewiresrc group and would be started by the daemon before the
session manager has a chance to configure (and link) the node.

Fixes #4
This commit is contained in:
Wim Taymans 2020-08-10 16:51:16 +02:00
parent db93135ff7
commit 5e9091a285
4 changed files with 16 additions and 3 deletions

View file

@ -65,6 +65,8 @@ struct spa_node_info {
* PortConfig parameter */ * PortConfig parameter */
#define SPA_NODE_FLAG_OUT_PORT_CONFIG (1u<<4) /**< output ports can be reconfigured with #define SPA_NODE_FLAG_OUT_PORT_CONFIG (1u<<4) /**< output ports can be reconfigured with
* PortConfig parameter */ * PortConfig parameter */
#define SPA_NODE_FLAG_NEED_CONFIGURE (1u<<5) /**< node needs configuration before it can
* be started. */
uint64_t flags; uint64_t flags;
struct spa_dict *props; /**< extra node properties */ struct spa_dict *props; /**< extra node properties */
struct spa_param_info *params; /**< parameter information */ struct spa_param_info *params; /**< parameter information */

View file

@ -1058,8 +1058,13 @@ impl_init(const struct spa_handle_factory *factory,
this->convert = iface; this->convert = iface;
this->target = this->convert; this->target = this->convert;
this->info_all = SPA_NODE_CHANGE_MASK_PARAMS; this->info_all = SPA_NODE_CHANGE_MASK_FLAGS |
SPA_NODE_CHANGE_MASK_PARAMS;
this->info = SPA_NODE_INFO_INIT(); this->info = SPA_NODE_INFO_INIT();
this->info.flags = SPA_NODE_FLAG_RT |
SPA_NODE_FLAG_IN_PORT_CONFIG |
SPA_NODE_FLAG_OUT_PORT_CONFIG |
SPA_NODE_FLAG_NEED_CONFIGURE;
this->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ); this->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
this->params[1] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ); this->params[1] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ);
this->params[2] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_READWRITE); this->params[2] = SPA_PARAM_INFO(SPA_PARAM_Props, SPA_PARAM_INFO_READWRITE);

View file

@ -688,6 +688,9 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
res = spa_node_set_param(this->fmt[direction], SPA_PARAM_PortConfig, 0, param); res = spa_node_set_param(this->fmt[direction], SPA_PARAM_PortConfig, 0, param);
if (res < 0) if (res < 0)
return res; return res;
this->info.change_mask |= SPA_NODE_CHANGE_MASK_FLAGS;
this->info.flags &= ~SPA_NODE_FLAG_NEED_CONFIGURE;
} }
/* notify ports of new node */ /* notify ports of new node */
@ -702,6 +705,8 @@ static int reconfigure_mode(struct impl *this, enum spa_param_port_config_mode m
this); this);
this->have_fmt_listener[direction] = true; this->have_fmt_listener[direction] = true;
} }
emit_node_info(this, false);
return 0; return 0;
} }
@ -1213,7 +1218,8 @@ impl_init(const struct spa_handle_factory *factory,
this->info.max_output_ports = 128; this->info.max_output_ports = 128;
this->info.flags = SPA_NODE_FLAG_RT | this->info.flags = SPA_NODE_FLAG_RT |
SPA_NODE_FLAG_IN_PORT_CONFIG | SPA_NODE_FLAG_IN_PORT_CONFIG |
SPA_NODE_FLAG_OUT_PORT_CONFIG; SPA_NODE_FLAG_OUT_PORT_CONFIG |
SPA_NODE_FLAG_NEED_CONFIGURE;
this->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumPortConfig, SPA_PARAM_INFO_READ); this->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumPortConfig, SPA_PARAM_INFO_READ);
this->params[1] = SPA_PARAM_INFO(SPA_PARAM_PortConfig, SPA_PARAM_INFO_READWRITE); this->params[1] = SPA_PARAM_INFO(SPA_PARAM_PortConfig, SPA_PARAM_INFO_READWRITE);
this->params[2] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ); this->params[2] = SPA_PARAM_INFO(SPA_PARAM_PropInfo, SPA_PARAM_INFO_READ);

View file

@ -790,7 +790,7 @@ error:
static int ensure_state(struct pw_impl_node *node, bool running) static int ensure_state(struct pw_impl_node *node, bool running)
{ {
enum pw_node_state state = node->info.state; enum pw_node_state state = node->info.state;
if (node->active && running) if (node->active && !SPA_FLAG_IS_SET(node->spa_flags, SPA_NODE_FLAG_NEED_CONFIGURE) && running)
state = PW_NODE_STATE_RUNNING; state = PW_NODE_STATE_RUNNING;
else if (state > PW_NODE_STATE_IDLE) else if (state > PW_NODE_STATE_IDLE)
state = PW_NODE_STATE_IDLE; state = PW_NODE_STATE_IDLE;