summaryrefslogtreecommitdiffstats
path: root/module.c
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@iot.bzh>2016-06-09 18:22:08 +0200
committerYannick Gicquel <yannick.gicquel@iot.bzh>2016-10-11 17:09:06 +0200
commit6c2aef81c4182695487fabbd19c5c0a84409b49f (patch)
tree00343bff2a76a3193ac3c586c97f63c26e37f6b4 /module.c
parent0d031cbfdcb94efa7daa596df5106666b12e9e2b (diff)
Initial commit
Change-Id: Ic974941bdd30309b4adb72b7a05959332750210b Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
Diffstat (limited to 'module.c')
-rw-r--r--module.c149
1 files changed, 149 insertions, 0 deletions
diff --git a/module.c b/module.c
new file mode 100644
index 0000000..beb2c73
--- /dev/null
+++ b/module.c
@@ -0,0 +1,149 @@
+/*
+ * module-agl-audio -- PulseAudio module for providing audio routing support
+ * (forked from "module-murphy-ivi" - https://github.com/otcshare )
+ * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2016, IoT.bzh
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 2.1, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
+ * MA 02110-1301 USA.
+ *
+ */
+
+/* Load the module with :
+$ pulseaudio --system --dl-search-path=/mypath
+$ pactl load-module mypamodule
+ (PS : /mypath must be world-readable, because PulseAudio drops
+ its own privileges after initial startup)
+*/
+
+ /* THIS IS PROVIDED BY "pulseaudio-module-devel" package */
+
+#include <pulsecore/pulsecore-config.h> /* required for "module.h" */
+#include <pulsecore/module.h>
+#include <pulsecore/modargs.h> /* for "pa_modargs" */
+
+#include "userdata.h" /* for "struct userdata" */
+#include "utils.h" /* for "struct pa_null_sink", "pa_utils_create_null_sink()"... */
+#include "loopback.h" /* for "struct pa_loopback/loopnode" */
+#include "zone.h" /* for "struct pa_zoneset" */
+#include "node.h" /* for "struct pa_nodeset" */
+#include "audiomgr.h" /* for "struct pa_audiomgr" */
+#include "routerif.h" /* for "struct pa_routerif" */
+#include "discover.h" /* for "struct pa_discover" */
+#include "tracker.h" /* for "struct pa_tracker" */
+#include "router.h" /* for "struct pa_router" */
+
+#ifndef DEFAULT_CONFIG_DIR
+#define DEFAULT_CONFIG_DIR "/etc/pulse"
+#endif
+
+#ifndef DEFAULT_CONFIG_FILE
+#define DEFAULT_CONFIG_FILE "pulseaudio-agl.cfg"
+#endif
+
+
+ /* VALID ARGUMENTS */
+
+static const char* const valid_modargs[] = {
+ "config_dir",
+ "config_file",
+ "null_sink_name",
+ "audiomgr_socktype",
+ "audiomgr_address",
+ "audiomgr_port",
+ NULL
+};
+
+
+ /* INITIALIZATION FUNCTION */
+
+int pa__init (pa_module *m)
+{
+ pa_log ("Initializing \"pulseaudio-agl\" module");
+
+ struct userdata *u = NULL;
+ pa_modargs *ma = NULL; /* will contain module arguments */
+ const char *cfgdir;
+ const char *cfgfile;
+ const char *nsnam; /* NULL sink name (default = "null.agl") */
+ const char *amsocktype; /* Optional external routing daemon: socket type ("unix"/"tcp") */
+ const char *amaddr; /* Optional external routing daemon: socket address (path/ip address) */
+ const char *amport; /* Optional external routing daemon: socket port ("tcp" type only) */
+
+ pa_assert (m);
+
+ /* treat module arguments */
+
+ ma = pa_modargs_new (m->argument, valid_modargs);
+
+ cfgdir = pa_modargs_get_value (ma, "config_dir", DEFAULT_CONFIG_DIR);
+ cfgfile = pa_modargs_get_value (ma, "config_file", DEFAULT_CONFIG_FILE);
+ nsnam = pa_modargs_get_value (ma, "null_sink_name", NULL);
+ amsocktype = pa_modargs_get_value (ma, "audiomgr_socktype", NULL);
+ amaddr = pa_modargs_get_value (ma, "audiomgr_address", NULL);
+ amport = pa_modargs_get_value (ma, "audiomgr_port", NULL);
+
+ pa_log ("cfgdir : %s", cfgdir);
+ pa_log ("cfgfile : %s", cfgfile);
+
+ pa_utils_init_stamp ();
+
+ /* initialize userdata */
+
+ u = pa_xnew0 (struct userdata, 1);
+ u->core = m->core;
+ u->module = m;
+ u->nsnam = pa_xstrdup (nsnam) ;
+ u->zoneset = pa_zoneset_init (u);
+ u->nodeset = pa_nodeset_init (u);
+ u->audiomgr = pa_audiomgr_init (u);
+ u->routerif = pa_routerif_init (u, amsocktype, amaddr, amport);
+ u->router = pa_router_init (u);
+ u->discover = pa_discover_init (u);
+ u->tracker = pa_tracker_init (u);
+
+ m->userdata = u;
+
+ /* really initialize the module's core logic */
+
+ pa_tracker_synchronize (u);
+
+ /* end */
+
+ pa_modargs_free(ma);
+
+ return 0;
+}
+
+
+ /* CLOSEUP FUNCTION */
+void pa__done (pa_module *m)
+{
+ pa_log ("Closing \"pulseaudio-agl\" module");
+
+ struct userdata *u;
+
+ pa_assert (m);
+
+ if (u = m->userdata) {
+ pa_tracker_done (u);
+ pa_discover_done (u);
+ pa_routerif_done (u);
+ pa_audiomgr_done (u);
+ pa_nodeset_done (u);
+ pa_zoneset_done (u);
+ pa_xfree (u->nsnam);
+ pa_xfree (u);
+ }
+}