[pulseaudio-commits] src/modules

Colin Guthrie colin at kemper.freedesktop.org
Mon Sep 5 14:26:35 PDT 2011


 src/modules/raop/module-raop-discover.c |   14 ++++----------
 src/modules/raop/raop_client.c          |   17 +++++++++++++++--
 src/modules/rtp/rtsp_client.c           |    1 +
 3 files changed, 20 insertions(+), 12 deletions(-)

New commits:
commit d36a9df63ce6c3a9e86103e1617fad7765922315
Author: Colin Guthrie <colin at mageia.org>
Date:   Mon Sep 5 22:19:41 2011 +0100

    raop: Use the port supplied by avahi when connecting to RAOP devices.
    
    The Apple TV for example uses a non-default port, but we previously ignored
    this. We now correctly parse the server string but in so doing, we end up
    parsing the address twice. As we need a pure IP/hostname of the device itself
    to use in our requests, this is somewhat unavoidable.
    
    Sadly there are still other problems with Apple TVs, but this is still
    one step closer.
    
    Fixes part of #950

diff --git a/src/modules/raop/module-raop-discover.c b/src/modules/raop/module-raop-discover.c
index de1a2b1..1a7572c 100644
--- a/src/modules/raop/module-raop-discover.c
+++ b/src/modules/raop/module-raop-discover.c
@@ -186,24 +186,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 "
                                      "sink_properties=device.description=\"%s\"",
-                                     avahi_address_snprint(at, sizeof(at), a),
+                                     avahi_address_snprint(at, sizeof(at), a), port,
                                      vname,
                                      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);
         }
 
diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c
index 96912b2..bbbce5b 100644
--- a/src/modules/raop/raop_client.c
+++ b/src/modules/raop/raop_client.c
@@ -47,6 +47,7 @@
 #include <pulsecore/iochannel.h>
 #include <pulsecore/socket-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/parseaddr.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/memchunk.h>
 #include <pulsecore/random.h>
@@ -67,10 +68,13 @@
 #define VOLUME_MIN -144
 #define VOLUME_MAX 0
 
+#define RAOP_PORT 5000
+
 
 struct pa_raop_client {
     pa_core *core;
     char *host;
+    uint16_t port;
     char *sid;
     pa_rtsp_client *rtsp;
 
@@ -363,14 +367,23 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
 }
 
 pa_raop_client* pa_raop_client_new(pa_core *core, const char* host) {
+    pa_parsed_address a;
     pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
 
     pa_assert(core);
     pa_assert(host);
 
+    if (pa_parse_address(host, &a) < 0 || a.type == PA_PARSED_ADDRESS_UNIX)
+        return NULL;
+
     c->core = core;
     c->fd = -1;
-    c->host = pa_xstrdup(host);
+
+    c->host = pa_xstrdup(a.path_or_host);
+    if (a.port)
+        c->port = a.port;
+    else
+        c->port = RAOP_PORT;
 
     if (pa_raop_connect(c)) {
         pa_raop_client_free(c);
@@ -407,7 +420,7 @@ int pa_raop_connect(pa_raop_client* c) {
         return 0;
     }
 
-    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, 5000, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
+    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, c->port, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
     pa_random(c->aes_iv, sizeof(c->aes_iv));
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index ecf85b8..71692c2 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -324,6 +324,7 @@ int pa_rtsp_connect(pa_rtsp_client *c) {
     pa_xfree(c->session);
     c->session = NULL;
 
+    pa_log_debug("Attempting to connect to server '%s:%d'", c->hostname, c->port);
     if (!(c->sc = pa_socket_client_new_string(c->mainloop, TRUE, c->hostname, c->port))) {
         pa_log("failed to connect to server '%s:%d'", c->hostname, c->port);
         return -1;



More information about the pulseaudio-commits mailing list