summaryrefslogtreecommitdiff
authorColin Guthrie <colin@mageia.org>2011-09-05 21:19:41 (GMT)
committer Colin Guthrie <colin@mageia.org>2011-09-05 21:23:17 (GMT)
commitd36a9df63ce6c3a9e86103e1617fad7765922315 (patch) (side-by-side diff)
treed994f6224dad929398d50d01560690203aed1b37
parent8e298848be3a1b2a83b808441adf317da2cecd47 (diff)
downloadpulseaudio-d36a9df63ce6c3a9e86103e1617fad7765922315.zip
pulseaudio-d36a9df63ce6c3a9e86103e1617fad7765922315.tar.gz
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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/modules/raop/module-raop-discover.c14
-rw-r--r--src/modules/raop/raop_client.c17
-rw-r--r--src/modules/rtp/rtsp_client.c1
3 files changed, 20 insertions, 12 deletions
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;