core: rework how nodes are added to a driver

Add a function to recalculate all nodes associated with a driver by
iterating the graph for each driver node. We used to do this in an
incremental way, which is easy to join graph but expensive to
split.

A full scan simplifies some things and we can't avoid it when we
need to calculate latencies later. It will also simplifies assigning
master and slave roles to drivers when the graphs are joined/split.

When we link/unlink or add/remove nodes, recalc the graph.
This commit is contained in:
Wim Taymans 2019-04-10 16:19:10 +02:00
parent ae3e5787af
commit 32f039e2e5
4 changed files with 127 additions and 109 deletions

View file

@ -45,6 +45,9 @@ extern "C" {
#define spa_debug pw_log_trace
#endif
#define DEFAULT_QUANTUM 1024u
#define MIN_QUANTUM 64u
#define MAX_PARAMS 32
struct pw_command;
@ -185,6 +188,7 @@ struct pw_core {
struct spa_list link_list; /**< list of links */
struct spa_list control_list[2]; /**< list of controls, indexed by direction */
struct spa_list export_list; /**< list of export types */
struct spa_list driver_list; /**< list of driver nodes */
struct spa_hook_list listener_list;
@ -370,13 +374,17 @@ struct pw_node {
int remote:1; /**< if the node is implemented remotely */
int master:1; /**< a master node is one of the driver nodes that
* is selected to drive the graph */
int visited:1; /**< for sorting */
uint32_t port_user_data_size; /**< extra size for port user data */
struct spa_list core_driver_link;
struct pw_node *driver_node;
struct spa_list driver_list;
struct spa_list driver_link;
struct spa_list sort_link; /**< link used to sort nodes */
struct spa_node *node; /**< SPA node implementation */
struct spa_hook listener;
@ -744,6 +752,8 @@ pw_core_find_port(struct pw_core *core,
const struct pw_export_type *pw_core_find_export_type(struct pw_core *core, uint32_t type);
int pw_core_recalc_graph(struct pw_core *core);
/** Create a new port \memberof pw_port
* \return a newly allocated port */
struct pw_port *