2 * module-murphy-ivi -- PulseAudio module for providing audio routing support
3 * Copyright (c) 2012, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 2.1, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 #include <pulsecore/pulsecore-config.h>
35 #include <pulse/timeval.h>
36 #include <pulse/xmalloc.h>
38 #include <pulsecore/macro.h>
39 #include <pulsecore/module.h>
40 #include <pulsecore/idxset.h>
41 #include <pulsecore/client.h>
42 #include <pulsecore/core-util.h>
43 #include <pulsecore/core-error.h>
44 #include <pulsecore/modargs.h>
45 #include <pulsecore/log.h>
47 #include "module-murphy-ivi-symdef.h"
54 #include "constrain.h"
55 #include "multiplex.h"
61 #include "murphy-config.h"
63 #include "scripting.h"
69 #ifndef DEFAULT_CONFIG_DIR
70 #define DEFAULT_CONFIG_DIR "/etc/pulse"
73 #ifndef DEFAULT_CONFIG_FILE
74 #define DEFAULT_CONFIG_FILE "murphy-ivi.lua"
79 #define WITH_RESOURCES
83 PA_MODULE_AUTHOR("Janos Kovacs");
84 PA_MODULE_DESCRIPTION("Murphy and GenIVI compliant audio policy module");
85 PA_MODULE_VERSION(PACKAGE_VERSION);
86 PA_MODULE_LOAD_ONCE(true);
88 "config_dir=<configuration directory>"
89 "config_file=<policy configuration file> "
90 "fade_out=<stream fade-out time in msec> "
91 "fade_in=<stream fade-in time in msec> "
92 "enable_multiplex=<boolean for disabling combine creation> "
94 "murphy_domain_controller=<address of Murphy's domain controller service> "
97 "murphy_resources=<address of Murphy's native resource service> "
100 "dbus_bus_type=<system|session> "
101 "dbus_if_name=<policy dbus interface> "
102 "dbus_murphy_path=<policy daemon's path> "
103 "dbus_murphy_name=<policy daemon's name> "
104 "dbus_audiomgr_path=<GenIVI audio manager's path> "
105 "dbus_audiomgr_name=<GenIVI audio manager's name> "
107 "audiomgr_socktype=<tcp|unix> "
108 "audiomgr_address=<audiomgr socket address> "
109 "audiomgr_port=<audiomgr tcp port> "
111 "null_sink_name=<name of the null sink> "
114 static const char* const valid_modargs[] = {
121 "murphy_domain_controller",
123 #ifdef WITH_RESOURCES
131 "dbus_audiomgr_path",
132 "dbus_audiomgr_name",
143 int pa__init(pa_module *m) {
144 struct userdata *u = NULL;
145 pa_modargs *ma = NULL;
153 #ifdef WITH_RESOURCES
157 const char *dbustype;
161 const char *socktype;
168 bool enable_multiplex = true;
173 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
174 pa_log("Failed to parse module arguments.");
178 cfgdir = pa_modargs_get_value(ma, "config_dir", DEFAULT_CONFIG_DIR);
179 cfgfile = pa_modargs_get_value(ma, "config_file", DEFAULT_CONFIG_FILE);
180 fadeout = pa_modargs_get_value(ma, "fade_out", NULL);
181 fadein = pa_modargs_get_value(ma, "fade_in", NULL);
183 if (pa_modargs_get_value_boolean(ma, "enable_multiplex", &enable_multiplex) < 0)
184 enable_multiplex = true;
187 ctladdr = pa_modargs_get_value(ma, "murphy_domain_controller", NULL);
189 #ifdef WITH_RESOURCES
190 resaddr = pa_modargs_get_value(ma, "murphy_resources", NULL);
193 dbustype = pa_modargs_get_value(ma, "dbus_bus_type", NULL);
194 ampath = pa_modargs_get_value(ma, "dbus_audiomgr_path", NULL);
195 amnam = pa_modargs_get_value(ma, "dbus_audiomgr_name", NULL);
197 socktype = pa_modargs_get_value(ma, "audiomgr_socktype", NULL);
198 amaddr = pa_modargs_get_value(ma, "audiomgr_address", NULL);
199 amport = pa_modargs_get_value(ma, "audiomgr_port", NULL);
201 nsnam = pa_modargs_get_value(ma, "null_sink_name", NULL);
203 u = pa_xnew0(struct userdata, 1);
206 u->nullsink = pa_utils_create_null_sink(u, nsnam);
207 u->zoneset = pa_zoneset_init(u);
208 u->nodeset = pa_nodeset_init(u);
209 u->audiomgr = pa_audiomgr_init(u);
211 u->routerif = pa_routerif_init(u, dbustype, ampath, amnam);
213 u->routerif = pa_routerif_init(u, socktype, amaddr, amport);
215 u->discover = pa_discover_init(u);
216 u->tracker = pa_tracker_init(u);
217 u->router = pa_router_init(u);
218 u->constrain = pa_constrain_init(u);
219 u->multiplex = pa_multiplex_init();
220 u->loopback = pa_loopback_init();
221 u->fader = pa_fader_init(fadeout, fadein);
222 u->volume = pa_mir_volume_init(u);
223 u->scripting = pa_scripting_init(u);
224 u->config = pa_mir_config_init(u);
225 u->extapi = pa_extapi_init(u);
226 u->murphyif = pa_murphyif_init(u, ctladdr, resaddr);
227 u->resource = pa_resource_init(u);
229 u->state.sink = PA_IDXSET_INVALID;
230 u->state.source = PA_IDXSET_INVALID;
232 u->enable_multiplex = enable_multiplex;
234 if (u->nullsink == NULL || u->routerif == NULL ||
235 u->audiomgr == NULL || u->discover == NULL ||
241 /* register ext api callback */
242 u->protocol = pa_native_protocol_get(m->core);
243 pa_native_protocol_install_ext(u->protocol, m, extension_cb);
245 cfgpath = pa_utils_file_path(cfgdir, cfgfile, buf, sizeof(buf));
247 pa_mir_config_parse_file(u, cfgpath);
249 pa_tracker_synchronize(u);
251 mir_router_print_rtgroups(u, buf, sizeof(buf));
252 pa_log_debug("%s", buf);
268 void pa__done(pa_module *m) {
273 if ((u = m->userdata)) {
278 pa_constrain_done(u);
283 pa_mir_volume_done(u);
284 pa_mir_config_done(u);
287 pa_scripting_done(u);
288 pa_utils_destroy_null_sink(u);
290 pa_loopback_done(u->loopback, u->core);
291 pa_multiplex_done(u->multiplex, u->core);
296 pa_native_protocol_remove_ext(u->protocol, m);
297 pa_native_protocol_unref(u->protocol);
309 * indent-tabs-mode: nil