module-zeroconf-discovery: Add parameter for switching to new tunnel modules

Submitted by Yauhen Kharuzhy on May 8, 2019, 6:12 p.m.

Details

Message ID 20190508181207.28944-1-jekhor@gmail.com
State New
Headers show
Series "module-zeroconf-discovery: Add parameter for switching to new tunnel modules" ( rev: 1 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Yauhen Kharuzhy May 8, 2019, 6:12 p.m.
Add boolean parameter 'use_new_tunnel' to add ability to use
module-tunnel-{sink,source}-new instead of old
module-tunnel-{sink,source} modules. This parameter is false by default
for maintain behaviour compatible.

The new tunnel module don't send 'early requests' flag to server and
allow to tune latency, by using adjust latency mode and by propagating of
tlength buffer attribute from stream to server. This can be useful
during of setting up networking audio via Wi-Fi.
---
 src/modules/module-zeroconf-discover.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c
index 612e2ed49..271beae32 100644
--- a/src/modules/module-zeroconf-discover.c
+++ b/src/modules/module-zeroconf-discover.c
@@ -46,11 +46,15 @@  PA_MODULE_AUTHOR("Lennart Poettering");
 PA_MODULE_DESCRIPTION("mDNS/DNS-SD Service Discovery");
 PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(true);
+PA_MODULE_USAGE(
+        "use_new_tunnel=<use module-tunnel-{sink,source}-new for tunnels?>"
+        );
 
 #define SERVICE_TYPE_SINK "_pulse-sink._tcp"
 #define SERVICE_TYPE_SOURCE "_non-monitor._sub._pulse-source._tcp"
 
 static const char* const valid_modargs[] = {
+    "use_new_tunnel",
     NULL
 };
 
@@ -67,6 +71,7 @@  struct userdata {
     AvahiPoll *avahi_poll;
     AvahiClient *client;
     AvahiServiceBrowser *source_browser, *sink_browser;
+    bool use_new_tunnel;
 
     pa_hashmap *tunnels;
 };
@@ -219,7 +224,8 @@  static void resolver_cb(
             (a->data.ipv6.address[1] & 0xc0) == 0x80)
             if_suffix = pa_sprintf_malloc("%%%d", interface);
 
-        module_name = pa_sprintf_malloc("module-tunnel-%s", t);
+        module_name = pa_sprintf_malloc("module-tunnel-%s%s", t,
+                                        u->use_new_tunnel ? "-new" : "");
         args = pa_sprintf_malloc("server=[%s%s]:%u "
                                  "%s=%s "
                                  "format=%s "
@@ -384,6 +390,7 @@  int pa__init(pa_module*m) {
 
     struct userdata *u;
     pa_modargs *ma = NULL;
+    bool use_new_tunnel = false;
     int error;
 
     if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@@ -396,6 +403,12 @@  int pa__init(pa_module*m) {
     u->module = m;
     u->sink_browser = u->source_browser = NULL;
 
+    if (pa_modargs_get_value_boolean(ma, "use_new_tunnel", &use_new_tunnel) < 0) {
+        pa_log("Failed to parse use_new_tunnel= argument.");
+        goto fail;
+    }
+    u->use_new_tunnel = use_new_tunnel;
+
     u->tunnels = pa_hashmap_new(tunnel_hash, tunnel_compare);
 
     u->avahi_poll = pa_avahi_poll_new(m->core->mainloop);