[pulseaudio-discuss] [PATCH 1/7] module-new: allow omitting the server argument

Pierre Ossman ossman at cendio.se
Mon May 23 14:57:53 UTC 2016


Omitting the server argument makes it try to find a server
automatically. Note that it can often find itself and cause a loop
so it's only useful in certain circumstances.

Signed-off-by: Pierre Ossman <ossman at cendio.se>
---
 src/modules/module-tunnel-sink-new.c   | 14 +++++++-------
 src/modules/module-tunnel-source-new.c | 14 +++++++-------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/modules/module-tunnel-sink-new.c
b/src/modules/module-tunnel-sink-new.c index 7f83543..c56654a 100644
--- a/src/modules/module-tunnel-sink-new.c
+++ b/src/modules/module-tunnel-sink-new.c
@@ -478,15 +478,14 @@ int pa__init(pa_module *m) {
     }
 
     remote_server = pa_modargs_get_value(ma, "server", NULL);
-    if (!remote_server) {
-        pa_log("No server given!");
-        goto fail;
-    }
+    if (!remote_server)
+        pa_log_warn("No server given. Will attempt to find one
automatically."); 
     u = pa_xnew0(struct userdata, 1);
     u->module = m;
     m->userdata = u;
-    u->remote_server = pa_xstrdup(remote_server);
+    if (remote_server)
+        u->remote_server = pa_xstrdup(remote_server);
     u->thread_mainloop = pa_mainloop_new();
     if (u->thread_mainloop == NULL) {
         pa_log("Failed to create mainloop");
@@ -503,8 +502,9 @@ int pa__init(pa_module *m) {
     pa_sink_new_data_init(&sink_data);
     sink_data.driver = __FILE__;
     sink_data.module = m;
+    sink_data.namereg_fail = false;
 
-    default_sink_name = pa_sprintf_malloc("tunnel-sink-new.%s",
remote_server);
+    default_sink_name = pa_sprintf_malloc("tunnel-sink-new.%s",
remote_server ? remote_server : "auto"); sink_name =
pa_modargs_get_value(ma, "sink_name", default_sink_name); 
     pa_sink_new_data_set_name(&sink_data, sink_name);
@@ -515,7 +515,7 @@ int pa__init(pa_module *m) {
     pa_proplist_setf(sink_data.proplist,
                      PA_PROP_DEVICE_DESCRIPTION,
                      _("Tunnel to %s/%s"),
-                     remote_server,
+                     pa_strempty(remote_server),
                      pa_strempty(u->remote_sink_name));
 
     if (pa_modargs_get_proplist(ma, "sink_properties",
sink_data.proplist, PA_UPDATE_REPLACE) < 0) { diff --git
a/src/modules/module-tunnel-source-new.c
b/src/modules/module-tunnel-source-new.c index 0f72dbf..d911fa9 100644
--- a/src/modules/module-tunnel-source-new.c +++
b/src/modules/module-tunnel-source-new.c @@ -477,15 +477,14 @@ int
pa__init(pa_module *m) { }
 
     remote_server = pa_modargs_get_value(ma, "server", NULL);
-    if (!remote_server) {
-        pa_log("No server given!");
-        goto fail;
-    }
+    if (!remote_server)
+        pa_log_warn("No server given. Will attempt to find one
automatically."); 
     u = pa_xnew0(struct userdata, 1);
     u->module = m;
     m->userdata = u;
-    u->remote_server = pa_xstrdup(remote_server);
+    if (remote_server)
+        u->remote_server = pa_xstrdup(remote_server);
     u->thread_mainloop = pa_mainloop_new();
     if (u->thread_mainloop == NULL) {
         pa_log("Failed to create mainloop");
@@ -502,8 +501,9 @@ int pa__init(pa_module *m) {
     pa_source_new_data_init(&source_data);
     source_data.driver = __FILE__;
     source_data.module = m;
+    source_data.namereg_fail = false;
 
-    default_source_name = pa_sprintf_malloc("tunnel-source-new.%s",
remote_server);
+    default_source_name = pa_sprintf_malloc("tunnel-source-new.%s",
remote_server ? remote_server : "auto"); source_name =
pa_modargs_get_value(ma, "source_name", default_source_name); 
     pa_source_new_data_set_name(&source_data, source_name);
@@ -514,7 +514,7 @@ int pa__init(pa_module *m) {
     pa_proplist_setf(source_data.proplist,
                      PA_PROP_DEVICE_DESCRIPTION,
                      _("Tunnel to %s/%s"),
-                     remote_server,
+                     pa_strempty(remote_server),
                      pa_strempty(u->remote_source_name));
 
     if (pa_modargs_get_proplist(ma, "source_properties",
source_data.proplist, PA_UPDATE_REPLACE) < 0) {
-- 
2.5.5




More information about the pulseaudio-discuss mailing list