2 * module-agl-audio -- PulseAudio module for providing audio routing support
3 * (forked from "module-murphy-ivi" - https://github.com/otcshare )
4 * Copyright (c) 2012, Intel Corporation.
5 * Copyright (c) 2016, IoT.bzh
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU Lesser General Public License,
9 * version 2.1, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
23 /* Load the module with :
24 $ pulseaudio --system --dl-search-path=/mypath
25 $ pactl load-module mypamodule
26 (PS : /mypath must be world-readable, because PulseAudio drops
27 its own privileges after initial startup)
30 /* THIS IS PROVIDED BY "pulseaudio-module-devel" package */
32 #include <pulsecore/pulsecore-config.h> /* required for "module.h" */
33 #include <pulsecore/module.h>
34 #include <pulsecore/modargs.h> /* for "pa_modargs" */
36 #include "userdata.h" /* for "struct userdata" */
37 #include "utils.h" /* for "struct pa_null_sink", "pa_utils_create_null_sink()"... */
38 #include "loopback.h" /* for "struct pa_loopback/loopnode" */
39 #include "zone.h" /* for "struct pa_zoneset" */
40 #include "node.h" /* for "struct pa_nodeset" */
41 #include "audiomgr.h" /* for "struct pa_audiomgr" */
42 #include "routerif.h" /* for "struct pa_routerif" */
43 #include "discover.h" /* for "struct pa_discover" */
44 #include "tracker.h" /* for "struct pa_tracker" */
45 #include "router.h" /* for "struct pa_router" */
47 #ifndef DEFAULT_CONFIG_DIR
48 #define DEFAULT_CONFIG_DIR "/etc/pulse"
51 #ifndef DEFAULT_CONFIG_FILE
52 #define DEFAULT_CONFIG_FILE "pulseaudio-agl.cfg"
58 static const char* const valid_modargs[] = {
69 /* INITIALIZATION FUNCTION */
71 int pa__init (pa_module *m)
73 pa_log ("Initializing \"pulseaudio-agl\" module");
75 struct userdata *u = NULL;
76 pa_modargs *ma = NULL; /* will contain module arguments */
79 const char *nsnam; /* NULL sink name (default = "null.agl") */
80 const char *amsocktype; /* Optional external routing daemon: socket type ("unix"/"tcp") */
81 const char *amaddr; /* Optional external routing daemon: socket address (path/ip address) */
82 const char *amport; /* Optional external routing daemon: socket port ("tcp" type only) */
86 /* treat module arguments */
88 ma = pa_modargs_new (m->argument, valid_modargs);
90 cfgdir = pa_modargs_get_value (ma, "config_dir", DEFAULT_CONFIG_DIR);
91 cfgfile = pa_modargs_get_value (ma, "config_file", DEFAULT_CONFIG_FILE);
92 nsnam = pa_modargs_get_value (ma, "null_sink_name", NULL);
93 amsocktype = pa_modargs_get_value (ma, "audiomgr_socktype", NULL);
94 amaddr = pa_modargs_get_value (ma, "audiomgr_address", NULL);
95 amport = pa_modargs_get_value (ma, "audiomgr_port", NULL);
97 pa_log ("cfgdir : %s", cfgdir);
98 pa_log ("cfgfile : %s", cfgfile);
100 pa_utils_init_stamp ();
102 /* initialize userdata */
104 u = pa_xnew0 (struct userdata, 1);
107 u->nsnam = pa_xstrdup (nsnam) ;
108 u->zoneset = pa_zoneset_init (u);
109 u->nodeset = pa_nodeset_init (u);
110 u->audiomgr = pa_audiomgr_init (u);
111 u->routerif = pa_routerif_init (u, amsocktype, amaddr, amport);
112 u->router = pa_router_init (u);
113 u->discover = pa_discover_init (u);
114 u->tracker = pa_tracker_init (u);
118 /* really initialize the module's core logic */
120 pa_tracker_synchronize (u);
130 /* CLOSEUP FUNCTION */
131 void pa__done (pa_module *m)
133 pa_log ("Closing \"pulseaudio-agl\" module");
139 if (u = m->userdata) {
141 pa_discover_done (u);
142 pa_routerif_done (u);
143 pa_audiomgr_done (u);