[pulseaudio-commits] r2519 - in /branches/coling/airtunes/src: Makefile.am modules/module-raop-discover.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Wed Jun 11 15:44:09 PDT 2008
Author: coling
Date: Thu Jun 12 00:44:09 2008
New Revision: 2519
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2519&root=pulseaudio&view=rev
Log:
Automatic discovery of airtunes devices via Bonjour/Avahi.
This also does some minor reordering in the Makefile.am
Refs #69
Added:
branches/coling/airtunes/src/modules/module-raop-discover.c
- copied, changed from r2495, branches/coling/airtunes/src/modules/module-zeroconf-discover.c
Modified:
branches/coling/airtunes/src/Makefile.am
Modified: branches/coling/airtunes/src/Makefile.am
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/Makefile.am?rev=2519&root=pulseaudio&r1=2518&r2=2519&view=diff
==============================================================================
--- branches/coling/airtunes/src/Makefile.am (original)
+++ branches/coling/airtunes/src/Makefile.am Thu Jun 12 00:44:09 2008
@@ -1082,7 +1082,8 @@
if HAVE_AVAHI
modlibexec_LTLIBRARIES += \
module-zeroconf-publish.la \
- module-zeroconf-discover.la
+ module-zeroconf-discover.la \
+ module-raop-discover.la
endif
if HAVE_LIRC
@@ -1152,7 +1153,6 @@
modules/module-esound-compat-spawnfd-symdef.h \
modules/module-esound-compat-spawnpid-symdef.h \
modules/module-match-symdef.h \
- modules/module-raop-sink-symdef.h \
modules/module-tunnel-sink-symdef.h \
modules/module-tunnel-source-symdef.h \
modules/module-null-sink-symdef.h \
@@ -1182,6 +1182,8 @@
modules/module-suspend-on-idle-symdef.h \
modules/module-hal-detect-symdef.h \
modules/module-bt-proximity-symdef.h \
+ modules/module-raop-sink-symdef.h \
+ modules/module-raop-discover-symdef.h \
modules/gconf/module-gconf-symdef.h
EXTRA_DIST += $(SYMDEF_FILES)
@@ -1313,10 +1315,6 @@
module_match_la_LDFLAGS = -module -avoid-version
module_match_la_LIBADD = $(AM_LIBADD) libpulsecore.la
-module_raop_sink_la_SOURCES = modules/module-raop-sink.c
-module_raop_sink_la_LDFLAGS = -module -avoid-version
-module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la
-
module_tunnel_sink_la_SOURCES = modules/module-tunnel.c
module_tunnel_sink_la_CFLAGS = -DTUNNEL_SINK=1 $(AM_CFLAGS)
module_tunnel_sink_la_LDFLAGS = -module -avoid-version
@@ -1494,6 +1492,17 @@
bt_proximity_helper_LDADD = $(AM_LDADD) $(BLUEZ_LIBS)
bt_proximity_helper_CFLAGS = $(AM_CFLAGS) $(BLUEZ_CFLAGS)
bt_proximity_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+
+# Apple Airtunes/RAOP
+module_raop_sink_la_SOURCES = modules/module-raop-sink.c
+module_raop_sink_la_LDFLAGS = -module -avoid-version
+module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la
+
+module_raop_discover_la_SOURCES = modules/module-raop-discover.c
+module_raop_discover_la_LDFLAGS = -module -avoid-version
+module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore.la
+module_raop_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
+
###################################
# Some minor stuff #
Copied: branches/coling/airtunes/src/modules/module-raop-discover.c (from r2495, branches/coling/airtunes/src/modules/module-zeroconf-discover.c)
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/modules/module-raop-discover.c?p2=branches/coling/airtunes/src/modules/module-raop-discover.c&p1=branches/coling/airtunes/src/modules/module-zeroconf-discover.c&r1=2495&r2=2519&rev=2519&root=pulseaudio&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/module-zeroconf-discover.c (original)
+++ branches/coling/airtunes/src/modules/module-raop-discover.c Thu Jun 12 00:44:09 2008
@@ -3,7 +3,7 @@
/***
This file is part of PulseAudio.
- Copyright 2004-2006 Lennart Poettering
+ Copyright 2008 Colin Guthrie
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -51,15 +51,14 @@
#include <pulsecore/namereg.h>
#include <pulsecore/avahi-wrap.h>
-#include "module-zeroconf-discover-symdef.h"
-
-PA_MODULE_AUTHOR("Lennart Poettering");
-PA_MODULE_DESCRIPTION("mDNS/DNS-SD Service Discovery");
+#include "module-raop-discover-symdef.h"
+
+PA_MODULE_AUTHOR("Colin Guthrie");
+PA_MODULE_DESCRIPTION("mDNS/DNS-SD Service Discovery of Airtunes");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(TRUE);
-#define SERVICE_TYPE_SINK "_pulse-sink._tcp"
-#define SERVICE_TYPE_SOURCE "_non-monitor._sub._pulse-source._tcp"
+#define SERVICE_TYPE_SINK "_raop._tcp"
static const char* const valid_modargs[] = {
NULL
@@ -77,7 +76,7 @@
pa_module *module;
AvahiPoll *avahi_poll;
AvahiClient *client;
- AvahiServiceBrowser *source_browser, *sink_browser;
+ AvahiServiceBrowser *sink_browser;
pa_hashmap *tunnels;
};
@@ -154,63 +153,29 @@
if (event != AVAHI_RESOLVER_FOUND)
pa_log("Resolving of '%s' failed: %s", name, avahi_strerror(avahi_client_errno(u->client)));
else {
- char *device = NULL, *dname, *module_name, *args;
- const char *t;
- char at[AVAHI_ADDRESS_STR_MAX], cmt[PA_CHANNEL_MAP_SNPRINT_MAX];
- pa_sample_spec ss;
- pa_channel_map cm;
+ char *device = NULL, *dname, *args;
+ char at[AVAHI_ADDRESS_STR_MAX];
AvahiStringList *l;
- pa_bool_t channel_map_set = FALSE;
pa_module *m;
-
- ss = u->core->default_sample_spec;
- pa_assert_se(pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_AUX));
- pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_DEFAULT);
for (l = txt; l; l = l->next) {
char *key, *value;
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) {
pa_xfree(device);
device = value;
value = NULL;
- } else if (strcmp(key, "rate") == 0)
- ss.rate = atoi(value);
- else if (strcmp(key, "channels") == 0)
- ss.channels = atoi(value);
- else if (strcmp(key, "format") == 0)
- ss.format = pa_parse_sample_format(value);
- else if (strcmp(key, "channel_map") == 0) {
- pa_channel_map_parse(&cm, value);
- channel_map_set = TRUE;
}
-
avahi_free(key);
avahi_free(value);
}
- if (!channel_map_set && cm.channels != ss.channels) {
- pa_assert_se(pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_AUX));
- pa_channel_map_init_auto(&cm, ss.channels, PA_CHANNEL_MAP_DEFAULT);
- }
-
- if (!pa_sample_spec_valid(&ss)) {
- pa_log("Service '%s' contains an invalid sample specification.", name);
- avahi_free(device);
- goto finish;
- }
-
- if (!pa_channel_map_valid(&cm) || cm.channels != ss.channels) {
- pa_log("Service '%s' contains an invalid channel map.", name);
- avahi_free(device);
- goto finish;
- }
-
if (device)
- dname = pa_sprintf_malloc("tunnel.%s.%s", host_name, device);
+ dname = pa_sprintf_malloc("airtunes.%s.%s", host_name, device);
else
- dname = pa_sprintf_malloc("tunnel.%s", host_name);
+ dname = pa_sprintf_malloc("airtunes.%s", host_name);
if (!pa_namereg_is_valid_name(dname)) {
pa_log("Cannot construct valid device name from credentials of service '%s'.", dname);
@@ -219,33 +184,25 @@
goto finish;
}
- t = strstr(type, "sink") ? "sink" : "source";
-
- module_name = pa_sprintf_malloc("module-tunnel-%s", t);
+ /*
+ TODO: allow this syntax of server name in things....
args = pa_sprintf_malloc("server=[%s]:%u "
- "%s=%s "
- "format=%s "
- "channels=%u "
- "rate=%u "
- "%s_name=%s "
- "channel_map=%s",
+ "sink_name=%s",
avahi_address_snprint(at, sizeof(at), a), port,
- t, device,
- pa_sample_format_to_string(ss.format),
- ss.channels,
- ss.rate,
- t, dname,
- pa_channel_map_snprint(cmt, sizeof(cmt), &cm));
-
- pa_log_debug("Loading module-tunnel-%s with arguments '%s'", module_name, args);
-
- if ((m = pa_module_load(u->core, module_name, args))) {
+ dname);*/
+ args = pa_sprintf_malloc("server=%s "
+ "sink_name=%s",
+ avahi_address_snprint(at, sizeof(at), a),
+ dname);
+
+ pa_log_debug("Loading module-raop-sink with arguments '%s'", args);
+
+ if ((m = pa_module_load(u->core, "module-raop-sink", args))) {
tnl->module_index = m->index;
pa_hashmap_put(u->tunnels, tnl, tnl);
tnl = NULL;
}
- pa_xfree(module_name);
pa_xfree(dname);
pa_xfree(args);
avahi_free(device);
@@ -328,21 +285,6 @@
}
}
- if (!u->source_browser) {
-
- if (!(u->source_browser = avahi_service_browser_new(
- c,
- AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
- SERVICE_TYPE_SOURCE,
- NULL,
- 0,
- browser_cb, u))) {
-
- pa_log("avahi_service_browser_new() failed: %s", avahi_strerror(avahi_client_errno(c)));
- pa_module_unload_request(u->module);
- }
- }
-
break;
case AVAHI_CLIENT_FAILURE:
@@ -366,11 +308,6 @@
u->sink_browser = NULL;
}
- if (u->source_browser) {
- avahi_service_browser_free(u->source_browser);
- u->source_browser = NULL;
- }
-
break;
default: ;
@@ -391,7 +328,7 @@
m->userdata = u = pa_xnew(struct userdata, 1);
u->core = m->core;
u->module = m;
- u->sink_browser = u->source_browser = NULL;
+ u->sink_browser = NULL;
u->tunnels = pa_hashmap_new(tunnel_hash, tunnel_compare);
More information about the pulseaudio-commits
mailing list