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,
25 #include <pulsecore/pulsecore-config.h>
27 #include "murphy-config.h"
32 #include "scripting.h"
41 mir_rtgroup_accept_t accept;
42 mir_rtgroup_compare_t compare;
64 static zone_def zones[] = {
73 static rtgroup_def rtgroups[] = {
76 mir_router_phone_accept,
77 mir_router_phone_compare
82 mir_router_default_accept,
83 mir_router_default_compare
88 mir_router_phone_accept,
89 mir_router_phone_compare
95 static classmap_def classmap[] = {
96 {mir_phone , 0, mir_input , "phone" },
97 {mir_radio , 0, mir_output, "default"},
98 {mir_player , 0, mir_output, "default"},
99 {mir_navigator, 0, mir_output, "default"},
100 {mir_game , 0, mir_output, "default"},
101 {mir_browser , 0, mir_output, "default"},
102 {mir_phone , 0, mir_output, "phone" },
103 {mir_event , 0, mir_output, "default"},
104 {mir_node_type_unknown, 0, mir_direction_unknown, NULL}
107 static typemap_def rolemap[] = {
108 {"video" , mir_player },
109 {"music" , mir_player },
110 {"game" , mir_game },
111 {"event" , mir_event },
112 {"navigator", mir_navigator },
113 {"phone" , mir_phone },
114 {"carkit" , mir_phone },
115 {"animation", mir_browser },
116 {"test" , mir_player },
117 {"ringtone" , mir_alert },
118 {"alarm" , mir_alert },
119 {"camera" , mir_camera },
120 {"system" , mir_system },
121 {NULL, mir_node_type_unknown}
124 static typemap_def binmap[] = {
125 {"rhytmbox" , mir_player },
126 {"firefox" , mir_browser},
127 {"chrome" , mir_browser},
128 {"sound-juicer", mir_player },
129 {NULL, mir_node_type_unknown}
132 static prior_def priormap[] = {
140 {mir_node_type_unknown, 0}
143 static double speedvol;
144 static double supprvol = -20.0;
145 static int exception_classes[] = {mir_phone, mir_navigator};
146 static mir_volume_suppress_arg suppress = {
147 &supprvol, {DIM(exception_classes), exception_classes}
151 static bool use_default_configuration(struct userdata *);
154 static bool parse_config_file(struct userdata *, FILE *);
157 pa_mir_config *pa_mir_config_init(struct userdata *u)
159 pa_mir_config *config;
163 config = pa_xnew0(pa_mir_config, 1);
168 void pa_mir_config_done(struct userdata *u)
170 pa_mir_config *config;
172 if (u && (config = u->config)) {
179 bool pa_mir_config_parse_file(struct userdata *u, const char *path)
182 pa_mir_config *config;
187 pa_assert_se((module = u->module));
188 pa_assert_se((config = u->config));
193 pa_log_info("%s: configuration file is '%s'", module->name, path);
194 success = pa_scripting_dofile(u, path);
198 pa_log_info("%s: builtin default configuration applies", module->name);
199 success = use_default_configuration(u);
202 pa_nodeset_print_maps(u, buf, sizeof(buf));
208 static bool use_default_configuration(struct userdata *u)
218 for (z = zones; z->name; z++)
219 pa_zoneset_add_zone(u, z->name, z - zones);
221 for (r = rtgroups; r->name; r++)
222 mir_router_create_rtgroup(u, r->type, r->name, r->accept, r->compare);
224 for (c = classmap; c->rtgroup; c++) {
225 mir_router_assign_class_to_rtgroup(u, c->class, c->zone,
226 c->type, c->rtgroup);
229 for (t = rolemap; t->id; t++)
230 pa_nodeset_add_role(u, t->id, t->type, NULL);
232 for (t = binmap; t->id; t++)
233 pa_nodeset_add_binary(u, t->id, t->type, NULL, NULL);
235 for (p = priormap; p->class; p++)
236 mir_router_assign_class_priority(u, p->class, p->priority);
239 mir_volume_add_generic_limit(u, mir_volume_correction, &speedvol);
241 mir_volume_add_class_limit(u, mir_phone,mir_volume_suppress, &suppress);
242 mir_volume_add_class_limit(u, mir_navigator,mir_volume_suppress,&suppress);
251 * indent-tabs-mode: nil