[PATCH 15/15] experimental-router: Create edges for new streams

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After this commit pa_sink_input_set_initial_sink() and
pa_source_output_set_initial_source() are only called through
pa_core_create_edge(), which completes the transition of moving the
initial routing of streams to the new node infrastructure.
---
 src/modules/module-experimental-router.c | 67 ++++++++++++--------------------
 1 file changed, 25 insertions(+), 42 deletions(-)

diff --git a/src/modules/module-experimental-router.c b/src/modules/module-experimental-router.c
index 594593d..67b3153 100644
--- a/src/modules/module-experimental-router.c
+++ b/src/modules/module-experimental-router.c
@@ -41,8 +41,9 @@ struct userdata {
 static pa_hook_result_t node_set_initial_routing_cb(void *hook_data, void *call_data, void *userdata) {
     pa_core *core = hook_data;
     pa_node_set_initial_routing_hook_data *data = call_data;
-    pa_node *node;
-    int r;
+    pa_node *routee;
+    pa_node *input;
+    pa_node *output;
 
     pa_assert(core);
     pa_assert(data);
@@ -52,62 +53,44 @@ static pa_hook_result_t node_set_initial_routing_cb(void *hook_data, void *call_
          * to override that. */
         return PA_HOOK_OK;
 
-    node = data->node;
+    routee = data->node;
 
-    if (node->type != PA_NODE_TYPE_SINK_INPUT && node->type != PA_NODE_TYPE_SOURCE_OUTPUT)
+    if (routee->type != PA_NODE_TYPE_SINK_INPUT && routee->type != PA_NODE_TYPE_SOURCE_OUTPUT)
         /* We don't set data->ret_valid, because we don't care about nodes that
          * aren't sink inputs or source outputs. If there is another router
          * module, it's free to apply its policy, and otherwise pa_node_put()
          * should apply its fallback policy. */
         return PA_HOOK_OK;
 
-    if (node->type == PA_NODE_TYPE_SINK_INPUT) {
-        pa_sink_input *sink_input = node->owner;
+    if (routee->type == PA_NODE_TYPE_SINK_INPUT) {
         pa_sink *default_sink;
 
-        pa_assert(sink_input->state == PA_SINK_INPUT_INIT);
-
-        if (sink_input->sink)
-            goto finish;
-
         default_sink = pa_namereg_get_default_sink(core);
-
-        if (default_sink)
-            r = pa_sink_input_set_initial_sink(sink_input, default_sink);
-        else
-            r = -PA_ERR_NOENTITY;
+        if (default_sink) {
+            input = routee;
+            output = pa_sink_get_node(default_sink);
+        } else {
+            pa_log_info("No default sink available.");
+            data->ret = -PA_ERR_NOENTITY;
+            data->ret_valid = true;
+            return PA_HOOK_OK;
+        }
     } else {
-        pa_source_output *source_output = node->owner;
         pa_source *default_source;
 
-        pa_assert(source_output->state == PA_SOURCE_OUTPUT_INIT);
-
-        if (source_output->source)
-            goto finish;
-
         default_source = pa_namereg_get_default_source(core);
-
-        if (default_source)
-            r = pa_source_output_set_initial_source(source_output, default_source);
-        else
-            r = -PA_ERR_NOENTITY;
+        if (default_source) {
+            input = pa_source_get_node(default_source);
+            output = routee;
+        } else {
+            pa_log_info("No default source available.");
+            data->ret = -PA_ERR_NOENTITY;
+            data->ret_valid = true;
+            return PA_HOOK_OK;
+        }
     }
 
-    if (r < 0)
-        goto fail;
-
-finish:
-    pa_log_debug("Successfully routed node %s.", node->name);
-
-    data->ret = 0;
-    data->ret_valid = true;
-
-    return PA_HOOK_OK;
-
-fail:
-    pa_log_debug("Failed to route node %s.", node->name);
-
-    data->ret = r;
+    data->ret = pa_core_create_edge(routee->core, input, output, NULL);
     data->ret_valid = true;
 
     return PA_HOOK_OK;
-- 
1.8.3.1



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux