--- src/pulsecore/node.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/pulsecore/node.c b/src/pulsecore/node.c index c7cd11d..5202731 100644 --- a/src/pulsecore/node.c +++ b/src/pulsecore/node.c @@ -252,6 +252,14 @@ static void set_initial_routing_fallback(pa_node_set_initial_routing_hook_data * pa_assert(data->n_requested_connections == 1); other_node = data->requested_connections[0]; + if (!other_node->active) { + /* Let's keep the fallback policy simple, and not try to activate any + * inactive nodes. */ + pa_log_info("Can't connect %s to %s, %s is not active.", node->name, other_node->name, other_node->name); + data->ret = -PA_ERR_INVALID; + return; + } + if (node->type == PA_NODE_TYPE_SINK_INPUT) { if (other_node->direction != PA_DIRECTION_OUTPUT) { pa_log_info("Can't connect %s to %s, both are input nodes.", node->name, other_node->name); @@ -275,13 +283,8 @@ static void set_initial_routing_fallback(pa_node_set_initial_routing_hook_data * if (other_node->type == PA_NODE_TYPE_PORT) { port = other_node->owner; - sink = port->device; - if (!sink || sink->active_port != port) { - pa_log_info("Can't connect %s to %s, port %s is not active.", node->name, other_node->name, port->name); - data->ret = -PA_ERR_NOTSUPPORTED; - return; - } + pa_assert(sink); /* We have checked that other_node is active. */ r = pa_sink_input_set_initial_sink(sink_input, sink); if (r < 0) { @@ -323,27 +326,14 @@ static void set_initial_routing_fallback(pa_node_set_initial_routing_hook_data * } if (other_node->type == PA_NODE_TYPE_PORT || other_node->type == PA_NODE_TYPE_PORT_MONITOR) { - bool port_is_active = false; - port = other_node->owner; if (other_node->type == PA_NODE_TYPE_PORT) source = port->device; - if (source && source->active_port == port) - port_is_active = true; - else if (other_node->type == PA_NODE_TYPE_PORT_MONITOR) { - sink = port->device; - if (sink && sink->active_port == port) { - port_is_active = true; - source = sink->monitor_source; - } - } + else + source = ((pa_sink *) port->device)->monitor_source; - if (!port_is_active) { - pa_log_info("Can't connect %s to %s, port %s is not active.", node->name, other_node->name, port->name); - data->ret = -PA_ERR_NOTSUPPORTED; - return; - } + pa_assert(source); /* We have checked that other_node is active. */ r = pa_source_output_set_initial_source(source_output, source); if (r < 0) { -- 1.8.3.1