link: move all graph nodes

This commit is contained in:
Wim Taymans 2018-04-30 11:44:20 +02:00
parent b8a37381da
commit 7c4baf88ea
2 changed files with 27 additions and 8 deletions

View file

@ -1160,6 +1160,16 @@ static const struct pw_node_events output_node_events = {
.async_complete = output_node_async_complete, .async_complete = output_node_async_complete,
}; };
static inline void
move_graph(struct spa_graph *dst, struct spa_graph *src)
{
struct spa_graph_node *n, *t;
spa_list_for_each_safe(n, t, &src->nodes, link) {
spa_graph_node_remove(n);
spa_graph_node_add(dst, n);
}
}
static int static int
do_join_graphs(struct spa_loop *loop, do_join_graphs(struct spa_loop *loop,
bool async, uint32_t seq, const void *data, size_t size, void *user_data) bool async, uint32_t seq, const void *data, size_t size, void *user_data)
@ -1178,16 +1188,22 @@ do_join_graphs(struct spa_loop *loop,
in_root, out_root, in_graph, out_graph); in_root, out_root, in_graph, out_graph);
if (in_graph != out_graph) { if (in_graph != out_graph) {
if (SPA_FLAG_CHECK(in_graph->flags, SPA_GRAPH_FLAG_DRIVER)) { struct spa_graph *src, *dst;
pw_log_debug("link %p: out_root to in_graph", this); bool out_driver;
spa_graph_node_remove(out_root);
spa_graph_node_add(in_graph, out_root); out_driver = SPA_FLAG_CHECK(out_graph->flags, SPA_GRAPH_FLAG_DRIVER);
if (out_driver) {
pw_log_debug("link %p: in_graph to out_graph", this);
src = in_graph;
dst = out_graph;
} }
else { else {
pw_log_debug("link %p: in_root to out_graph", this); pw_log_debug("link %p: out_graph to in_graph", this);
spa_graph_node_remove(in_root); src = out_graph;
spa_graph_node_add(out_graph, in_root); dst = in_graph;
} }
move_graph(dst, src);
} }
this->rt.link.signal = spa_graph_link_signal_node; this->rt.link.signal = spa_graph_link_signal_node;
this->rt.link.signal_data = in_root; this->rt.link.signal_data = in_root;

View file

@ -251,9 +251,12 @@ struct pw_node {
bool enabled; /**< if the node is enabled */ bool enabled; /**< if the node is enabled */
bool active; /**< if the node is active */ bool active; /**< if the node is active */
bool live; /**< if the node is live */ bool live; /**< if the node is live */
bool driver; /**< if the node drives the graph */ bool driver; /**< if the node can drive the graph */
bool exported; /**< if the node is exported */ bool exported; /**< if the node is exported */
bool remote; /**< if the node is implemented remotely */ bool remote; /**< if the node is implemented remotely */
bool master; /**< a master node is one of the driver nodes that
* is selected to drive the graph */
struct spa_clock *clock; /**< handle to SPA clock if any */ struct spa_clock *clock; /**< handle to SPA clock if any */
struct spa_node *node; /**< SPA node implementation */ struct spa_node *node; /**< SPA node implementation */