]> code.delx.au - pulseaudio/blobdiff - src/modules/raop/module-raop-discover.c
bluetooth: Use a helper function for setting device_info_valid
[pulseaudio] / src / modules / raop / module-raop-discover.c
index eaeb77fc30e28b88b39b44efdfa9bdc37933ee21..fda5e29e85f43ebe7736a9f307d9c1f5b5839adb 100644 (file)
 #include <avahi-common/malloc.h>
 
 #include <pulse/xmalloc.h>
-#include <pulse/util.h>
 
-#include <pulsecore/sink.h>
-#include <pulsecore/source.h>
-#include <pulsecore/native-common.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
-#include <pulsecore/core-subscribe.h>
 #include <pulsecore/hashmap.h>
 #include <pulsecore/modargs.h>
 #include <pulsecore/namereg.h>
@@ -55,7 +50,7 @@
 PA_MODULE_AUTHOR("Colin Guthrie");
 PA_MODULE_DESCRIPTION("mDNS/DNS-SD Service Discovery of RAOP devices");
 PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
 
 #define SERVICE_TYPE_SINK "_raop._tcp"
 
@@ -161,7 +156,9 @@ static void resolver_cb(
             ++nicename;
             if (strlen(nicename) > 0) {
                 pa_log_debug("Found RAOP: %s", nicename);
-            }
+                nicename = pa_escape(nicename, "\"'");
+            } else
+                nicename = NULL;
         }
 
         for (l = txt; l; l = l->next) {
@@ -169,7 +166,7 @@ static void resolver_cb(
             pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0);
 
             pa_log_debug("Found key: '%s' with value: '%s'", key, value);
-            if (strcmp(key, "device") == 0) {
+            if (pa_streq(key, "device")) {
                 pa_xfree(device);
                 device = value;
                 value = NULL;
@@ -191,24 +188,18 @@ static void resolver_cb(
         }
         pa_xfree(dname);
 
-        /*
-         TODO: allow this syntax of server name in things....
-        args = pa_sprintf_malloc("server=[%s]:%u "
-                                 "sink_name=%s",
-                                 avahi_address_snprint(at, sizeof(at), a), port,
-                                 vname);*/
         if (nicename) {
-            args = pa_sprintf_malloc("server=%s "
+            args = pa_sprintf_malloc("server=[%s]:%u "
                                      "sink_name=%s "
-                                     "description=\"%s\"",
-                                     avahi_address_snprint(at, sizeof(at), a),
+                                     "sink_properties='device.description=\"%s\"'",
+                                     avahi_address_snprint(at, sizeof(at), a), port,
                                      vname,
                                      nicename);
-
+            pa_xfree(nicename);
         } else {
-            args = pa_sprintf_malloc("server=%s "
+            args = pa_sprintf_malloc("server=[%s]:%u "
                                      "sink_name=%s",
-                                     avahi_address_snprint(at, sizeof(at), a),
+                                     avahi_address_snprint(at, sizeof(at), a), port,
                                      vname);
         }
 
@@ -265,7 +256,7 @@ static void browser_cb(
         struct tunnel *t2;
 
         if ((t2 = pa_hashmap_get(u->tunnels, t))) {
-            pa_module_unload_by_index(u->core, t2->module_index, TRUE);
+            pa_module_unload_request_by_index(u->core, t2->module_index, true);
             pa_hashmap_remove(u->tunnels, t2);
             tunnel_free(t2);
         }
@@ -298,7 +289,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
                               browser_cb, u))) {
 
                     pa_log("avahi_service_browser_new() failed: %s", avahi_strerror(avahi_client_errno(c)));
-                    pa_module_unload_request(u->module, TRUE);
+                    pa_module_unload_request(u->module, true);
                 }
             }
 
@@ -312,7 +303,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
 
                 if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
                     pa_log("avahi_client_new() failed: %s", avahi_strerror(error));
-                    pa_module_unload_request(u->module, TRUE);
+                    pa_module_unload_request(u->module, true);
                 }
             }
 
@@ -386,11 +377,11 @@ void pa__done(pa_module*m) {
         struct tunnel *t;
 
         while ((t = pa_hashmap_steal_first(u->tunnels))) {
-            pa_module_unload_by_index(u->core, t->module_index, TRUE);
+            pa_module_unload_request_by_index(u->core, t->module_index, true);
             tunnel_free(t);
         }
 
-        pa_hashmap_free(u->tunnels, NULL, NULL);
+        pa_hashmap_free(u->tunnels);
     }
 
     pa_xfree(u);