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"
67 #ifndef DEFAULT_CONFIG_DIR
68 #define DEFAULT_CONFIG_DIR "/etc/pulse"
71 #ifndef DEFAULT_CONFIG_FILE
72 #define DEFAULT_CONFIG_FILE "murphy-ivi.lua"
77 #define WITH_RESOURCES
81 PA_MODULE_AUTHOR("Janos Kovacs");
82 PA_MODULE_DESCRIPTION("Murphy and GenIVI compliant audio policy module");
83 PA_MODULE_VERSION(PACKAGE_VERSION);
84 PA_MODULE_LOAD_ONCE(TRUE);
86 "config_dir=<configuration directory>"
87 "config_file=<policy configuration file> "
88 "fade_out=<stream fade-out time in msec> "
89 "fade_in=<stream fade-in time in msec> "
91 "murphy_domain_controller=<address of Murphy's domain controller service> "
94 "murphy_resources=<address of Murphy's native resource service> "
97 "dbus_bus_type=<system|session> "
98 "dbus_if_name=<policy dbus interface> "
99 "dbus_murphy_path=<policy daemon's path> "
100 "dbus_murphy_name=<policy daemon's name> "
101 "dbus_audiomgr_path=<GenIVI audio manager's path> "
102 "dbus_audiomgr_name=<GenIVI audio manager's name> "
104 "audiomgr_socktype=<tcp|unix> "
105 "audiomgr_address=<audiomgr socket address> "
106 "audiomgr_port=<audiomgr tcp port> "
108 "null_sink_name=<name of the null sink> "
111 static const char* const valid_modargs[] = {
117 "murphy_domain_controller",
119 #ifdef WITH_RESOURCES
127 "dbus_audiomgr_path",
128 "dbus_audiomgr_name",
139 int pa__init(pa_module *m) {
140 struct userdata *u = NULL;
141 pa_modargs *ma = NULL;
149 #ifdef WITH_RESOURCES
153 const char *dbustype;
160 const char *socktype;
171 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
172 pa_log("Failed to parse module arguments.");
176 cfgdir = pa_modargs_get_value(ma, "config_dir", DEFAULT_CONFIG_DIR);
177 cfgfile = pa_modargs_get_value(ma, "config_file", DEFAULT_CONFIG_FILE);
178 fadeout = pa_modargs_get_value(ma, "fade_out", NULL);
179 fadein = pa_modargs_get_value(ma, "fade_in", NULL);
181 ctladdr = pa_modargs_get_value(ma, "murphy_domain_controller", NULL);
183 #ifdef WITH_RESOURCES
184 resaddr = pa_modargs_get_value(ma, "murphy_resources", NULL);
187 dbustype = pa_modargs_get_value(ma, "dbus_bus_type", NULL);
188 ifnam = pa_modargs_get_value(ma, "dbus_if_name", NULL);
189 mrppath = pa_modargs_get_value(ma, "dbus_murphy_path", NULL);
190 mrpnam = pa_modargs_get_value(ma, "dbus_murphy_name", NULL);
191 ampath = pa_modargs_get_value(ma, "dbus_audiomgr_path", NULL);
192 amnam = pa_modargs_get_value(ma, "dbus_audiomgr_name", NULL);
194 socktype = pa_modargs_get_value(ma, "audiomgr_socktype", NULL);
195 amaddr = pa_modargs_get_value(ma, "audiomgr_address", NULL);
196 amport = pa_modargs_get_value(ma, "audiomgr_port", NULL);
198 nsnam = pa_modargs_get_value(ma, "null_sink_name", NULL);
200 u = pa_xnew0(struct userdata, 1);
203 u->nullsink = pa_utils_create_null_sink(u, nsnam);
204 u->zoneset = pa_zoneset_init(u);
205 u->nodeset = pa_nodeset_init(u);
206 u->audiomgr = pa_audiomgr_init(u);
208 u->routerif = pa_routerif_init(u, dbustype, ifnam, mrppath, mrpnam,
211 u->routerif = pa_routerif_init(u, socktype, amaddr, amport);
213 u->discover = pa_discover_init(u);
214 u->tracker = pa_tracker_init(u);
215 u->router = pa_router_init(u);
216 u->constrain = pa_constrain_init(u);
217 u->multiplex = pa_multiplex_init();
218 u->loopback = pa_loopback_init();
219 u->fader = pa_fader_init(fadeout, fadein);
220 u->volume = pa_mir_volume_init(u);
221 u->scripting = pa_scripting_init(u);
222 u->config = pa_mir_config_init(u);
223 u->extapi = pa_extapi_init(u);
224 u->murphyif = pa_murphyif_init(u, ctladdr, resaddr);
226 u->state.sink = PA_IDXSET_INVALID;
227 u->state.source = PA_IDXSET_INVALID;
229 if (u->nullsink == NULL || u->routerif == NULL ||
230 u->audiomgr == NULL || u->discover == NULL ||
236 /* register ext api callback */
237 u->protocol = pa_native_protocol_get(m->core);
238 pa_native_protocol_install_ext(u->protocol, m, extension_cb);
240 cfgpath = pa_utils_file_path(cfgdir, cfgfile, buf, sizeof(buf));
242 pa_mir_config_parse_file(u, cfgpath);
244 pa_tracker_synchronize(u);
246 mir_router_print_rtgroups(u, buf, sizeof(buf));
247 pa_log_debug("%s", buf);
263 void pa__done(pa_module *m) {
268 if ((u = m->userdata)) {
272 pa_constrain_done(u);
277 pa_mir_volume_done(u);
278 pa_mir_config_done(u);
281 pa_scripting_done(u);
282 pa_utils_destroy_null_sink(u);
284 pa_loopback_done(u->loopback, u->core);
285 pa_multiplex_done(u->multiplex, u->core);
290 pa_native_protocol_remove_ext(u->protocol, m);
291 pa_native_protocol_unref(u->protocol);
303 * indent-tabs-mode: nil