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"
53 #include "constrain.h"
54 #include "multiplex.h"
62 #ifndef DEFAULT_CONFIG_FILE
63 #define DEFAULT_CONFIG_FILE "murphy-ivi.conf"
67 PA_MODULE_AUTHOR("Janos Kovacs");
68 PA_MODULE_DESCRIPTION("Murphy and GenIVI compliant audio policy module");
69 PA_MODULE_VERSION(PACKAGE_VERSION);
70 PA_MODULE_LOAD_ONCE(TRUE);
72 "config_dir=<configuration directory>"
73 "config_file=<policy configuration file> "
75 "dbus_bus_type=<system|session> "
76 "dbus_if_name=<policy dbus interface> "
77 "dbus_murphy_path=<policy daemon's path> "
78 "dbus_murphy_name=<policy daemon's name> "
79 "dbus_audiomgr_path=<GenIVI audio manager's path> "
80 "dbus_audiomgr_name=<GenIVI audio manager's name> "
82 "audiomgr_socktype=<tcp|unix> "
83 "audiomgr_address=<audiomgr socket address> "
84 "audiomgr_port=<audiomgr tcp port> "
86 "null_sink_name=<name of the null sink> "
89 static const char* const valid_modargs[] = {
109 int pa__init(pa_module *m) {
110 struct userdata *u = NULL;
111 pa_modargs *ma = NULL;
115 const char *dbustype;
122 const char *socktype;
132 if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
133 pa_log("Failed to parse module arguments.");
137 cfgdir = pa_modargs_get_value(ma, "config_dir", NULL);
138 cfgfile = pa_modargs_get_value(ma, "config_file", DEFAULT_CONFIG_FILE);
140 dbustype = pa_modargs_get_value(ma, "dbus_bus_type", NULL);
141 ifnam = pa_modargs_get_value(ma, "dbus_if_name", NULL);
142 mrppath = pa_modargs_get_value(ma, "dbus_murphy_path", NULL);
143 mrpnam = pa_modargs_get_value(ma, "dbus_murphy_name", NULL);
144 ampath = pa_modargs_get_value(ma, "dbus_audiomgr_path", NULL);
145 amnam = pa_modargs_get_value(ma, "dbus_audiomgr_name", NULL);
147 socktype = pa_modargs_get_value(ma, "audiomgr_socktype", NULL);
148 amaddr = pa_modargs_get_value(ma, "audiomgr_address", NULL);
149 amport = pa_modargs_get_value(ma, "audiomgr_port", NULL);
151 nsnam = pa_modargs_get_value(ma, "null_sink_name", NULL);
153 u = pa_xnew0(struct userdata, 1);
156 u->nullsink = pa_utils_create_null_sink(u, nsnam);
157 u->nodeset = pa_nodeset_init(u);
158 u->audiomgr = pa_audiomgr_init(u);
160 u->routerif = pa_routerif_init(u, dbustype, ifnam, mrppath, mrpnam,
163 u->routerif = pa_routerif_init(u, socktype, amaddr, amport);
165 u->discover = pa_discover_init(u);
166 u->tracker = pa_tracker_init(u);
167 u->router = pa_router_init(u);
168 u->constrain = pa_constrain_init(u);
169 u->multiplex = pa_multiplex_init();
170 u->loopback = pa_loopback_init();
171 u->volume = pa_mir_volume_init(u);
172 u->config = pa_mir_config_init(u);
174 if (u->nullsink == NULL || u->routerif == NULL ||
175 u->audiomgr == NULL || u->discover == NULL)
180 //cfgpath = pa_utils_file_path(cfgfile, buf, sizeof(buf));
182 pa_mir_config_parse_file(u, cfgpath);
184 pa_tracker_synchronize(u);
186 mir_router_print_rtgroups(u, buf, sizeof(buf));
187 pa_log_debug("%s", buf);
203 void pa__done(pa_module *m) {
208 if ((u = m->userdata)) {
212 pa_constrain_done(u);
216 pa_mir_volume_done(u);
217 pa_mir_config_done(u);
219 pa_utils_destroy_null_sink(u);
221 pa_loopback_done(u->loopback, u->core);
222 pa_multiplex_done(u->multiplex, u->core);
233 * indent-tabs-mode: nil