[pulseaudio-discuss] [PATCH 03/30] Pass the requested connections to pa_node_put()

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Thu Jan 16 07:02:29 PST 2014


Routers should be able to fully control the initial routing of
streams, while taking into account the routing requests from the
client or module-stream-restore etc. For this to be possible, the
routers need access to what the client or module-stream-restore
requested. Routers do the initial routing in pa_node_put(), so
this patch passes the initial routing requests to pa_node_put()
from where it can be forwarded to the router (to be done in a later
patch).
---
 src/pulsecore/device-port.c   | 4 ++--
 src/pulsecore/node.c          | 3 ++-
 src/pulsecore/node.h          | 2 +-
 src/pulsecore/sink-input.c    | 6 +++++-
 src/pulsecore/sink.c          | 2 +-
 src/pulsecore/source-output.c | 6 +++++-
 src/pulsecore/source.c        | 2 +-
 7 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index cf62ec3..6d340c7 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -153,7 +153,7 @@ pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, si
     }
 
     p->node->owner = p;
-    pa_node_put(p->node);
+    pa_node_put(p->node, NULL, 0);
 
     if (p->direction == PA_DIRECTION_OUTPUT) {
         char *description;
@@ -177,7 +177,7 @@ pa_device_port *pa_device_port_new(pa_core *c, pa_device_port_new_data *data, si
         }
 
         p->monitor_node->owner = p;
-        pa_node_put(p->monitor_node);
+        pa_node_put(p->monitor_node, NULL, 0);
     }
 
     return p;
diff --git a/src/pulsecore/node.c b/src/pulsecore/node.c
index 8cc6dc3..941e376 100644
--- a/src/pulsecore/node.c
+++ b/src/pulsecore/node.c
@@ -152,10 +152,11 @@ void pa_node_free(pa_node *node) {
     pa_xfree(node);
 }
 
-void pa_node_put(pa_node *node) {
+void pa_node_put(pa_node *node, pa_node **requested_connections, unsigned n_requested_connections) {
     pa_assert(node);
     pa_assert(node->state == PA_NODE_STATE_INIT);
     pa_assert(node->owner);
+    pa_assert(requested_connections || n_requested_connections == 0);
 
     pa_assert_se(pa_idxset_put(node->core->nodes, node, &node->index) >= 0);
     node->state = PA_NODE_STATE_LINKED;
diff --git a/src/pulsecore/node.h b/src/pulsecore/node.h
index d593b54..7a8502d 100644
--- a/src/pulsecore/node.h
+++ b/src/pulsecore/node.h
@@ -88,7 +88,7 @@ void pa_node_new_data_done(pa_node_new_data *data);
 pa_node *pa_node_new(pa_core *core, pa_node_new_data *data);
 void pa_node_free(pa_node *node);
 
-void pa_node_put(pa_node *node);
+void pa_node_put(pa_node *node, pa_node **requested_connections, unsigned n_requested_connections);
 void pa_node_unlink(pa_node *node);
 
 #endif
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index d045402..e88477b 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -294,6 +294,7 @@ int pa_sink_input_new(
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
     pa_channel_map original_cm;
     int r;
+    pa_node *sink_node = NULL;
     char *pt;
     char *memblockq_name;
     pa_sample_spec ss;
@@ -345,6 +346,9 @@ int pa_sink_input_new(
         goto fail;
     }
 
+    if (data->sink)
+        sink_node = pa_sink_get_node(data->sink);
+
     /* If something didn't pick a format for us, pick the top-most format since
      * we assume this is sorted in priority order */
     if (!data->format && data->nego_formats && !pa_idxset_isempty(data->nego_formats))
@@ -386,7 +390,7 @@ int pa_sink_input_new(
     i->node->owner = i;
 
     /* This may update i->sink and i->format. */
-    pa_node_put(i->node);
+    pa_node_put(i->node, &sink_node, sink_node ? 1 : 0);
 
     if (!i->sink) {
         pa_sink *sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 65b7050..0cf8a88 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -683,7 +683,7 @@ void pa_sink_put(pa_sink* s) {
     pa_source_put(s->monitor_source);
 
     if (s->node)
-        pa_node_put(s->node);
+        pa_node_put(s->node, NULL, 0);
 
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
     pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_PUT], s);
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index c050292..8eaf591 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -230,6 +230,7 @@ int pa_source_output_new(
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
     pa_channel_map original_cm;
     int r;
+    pa_node *source_node;
     char *pt;
     pa_sample_spec ss;
     pa_channel_map map;
@@ -278,6 +279,9 @@ int pa_source_output_new(
         goto fail;
     }
 
+    if (data->source)
+        source_node = pa_source_get_node(data->source);
+
     /* If something didn't pick a format for us, pick the top-most format since
      * we assume this is sorted in priority order */
     if (!data->format && data->nego_formats && !pa_idxset_isempty(data->nego_formats))
@@ -319,7 +323,7 @@ int pa_source_output_new(
     o->node->owner = o;
 
     /* This may update o->source and o->format. */
-    pa_node_put(o->node);
+    pa_node_put(o->node, &source_node, source_node ? 1 : 0);
 
     if (!o->source) {
         pa_source *source;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 0ee05b9..ab0018d 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -637,7 +637,7 @@ void pa_source_put(pa_source *s) {
         pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0);
 
     if (s->node)
-        pa_node_put(s->node);
+        pa_node_put(s->node, NULL, 0);
 
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_NEW, s->index);
     pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_PUT], s);
-- 
1.8.3.1



More information about the pulseaudio-discuss mailing list