summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--config.c121
-rw-r--r--config.h65
-rw-r--r--module.c8
-rw-r--r--router.c24
-rw-r--r--router.h14
6 files changed, 228 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7156d4f..4f1ce33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,7 @@ SET(plugin_install_dir ${CMAKE_INSTALL_LIBDIR}/pulse-6.0/modules)
############################################################
-ADD_LIBRARY(agl-audio-plugin MODULE module.c audiomgr.c classify.c discover.c loopback.c node.c router.c socketif.c switch.c tracker.c utils.c zone.c)
+ADD_LIBRARY(agl-audio-plugin MODULE module.c audiomgr.c classify.c config.c discover.c loopback.c node.c router.c socketif.c switch.c tracker.c utils.c zone.c)
INCLUDE_DIRECTORIES(${include_dirs})
TARGET_LINK_LIBRARIES(agl-audio-plugin ${link_libraries})
SET_TARGET_PROPERTIES(agl-audio-plugin PROPERTIES PREFIX ""
diff --git a/config.c b/config.c
new file mode 100644
index 0000000..4c4ed7d
--- /dev/null
+++ b/config.c
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ *
+ */
+#include "config.h"
+
+const char *pa_config_file_get_path (const char *dir, const char *file, char *buf, size_t len)
+{
+ pa_assert (file);
+ pa_assert (buf);
+ pa_assert (len > 0);
+
+ snprintf (buf, len, "%s/%s", dir, file);
+
+ return buf;
+}
+
+bool pa_config_parse_file (struct userdata *u, const char *path)
+{
+ bool success;
+
+ pa_assert (u);
+
+ if (!path)
+ return false;
+ else {
+ pa_log_info ("parsing configuration file '%s'", path);
+ success = pa_config_dofile (u, path);
+ }
+
+ if (!success) {
+ pa_log_info ("applying builtin default configuration");
+ //success = use_default_configuration (u);
+ }
+
+ return success;
+}
+
+bool pa_config_dofile (struct userdata *u, const char *path)
+{
+ /* TODO */
+ return false;
+}
+
+
+ /* DEFAULT CONFIGURATION PART */
+
+static zone_def zones[] = {
+ { "driver" },
+ { "passenger1" },
+ { "passenger2" },
+ { "passenger3" },
+ { "passenger4" },
+ { NULL }
+};
+
+
+static rtgroup_def rtgroups[] = {
+ { agl_input,
+ "phone",
+ agl_router_phone_accept,
+ agl_router_phone_compare
+ },
+
+ { 0, NULL, NULL, NULL }
+};
+
+static classmap_def classmap[] = {
+ { agl_phone, 0, agl_output, "phone" },
+ { agl_player, 0, agl_output, "default" },
+ { agl_radio, 0, agl_output, "default" },
+ { agl_navigator,0, agl_output, "default" },
+ { agl_event, 0, agl_output, "default" },
+ { agl_node_type_unknown, 0, agl_direction_unknown, NULL }
+};
+
+static typemap_def typemap[] = {
+ { "phone", agl_phone },
+ { "music", agl_player },
+ { "radio", agl_radio },
+ { "navi", agl_navigator },
+ { "event", agl_event },
+ { NULL, agl_node_type_unknown }
+};
+
+static prior_def priormap[] = {
+ { agl_event, 5 },
+ { agl_phone, 4 },
+ { agl_navigator, 2 },
+ { agl_radio, 1 },
+ { agl_player, 1 },
+ { agl_node_type_unknown, 0}
+};
+
+bool use_default_configuration (struct userdata *u)
+{
+ zone_def *z;
+ rtgroup_def *r;
+ classmap_def *c;
+ typemap_def *t;
+ prior_def *p;
+
+ return true;
+}
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..738f254
--- /dev/null
+++ b/config.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ *
+ */
+#ifndef paaglconfig
+#define paaglconfig
+
+#include "userdata.h"
+#include "router.h"
+
+ /* ZONES ("driver", "passenger1"...) */
+typedef struct {
+ const char *name;
+} zone_def;
+
+ /* ROUTING GROUPS ("default" card, "phone" card...) */
+typedef struct {
+ agl_direction type; /* agl_input/agl_output */
+ const char *name;
+ agl_rtgroup_accept_t accept;
+ agl_rtgroup_compare_t compare;
+} rtgroup_def;
+
+ /* CLASS MAP (agl_phone="phone" card routing group...) */
+typedef struct {
+ agl_node_type class; /* agl_device/agl_stream */
+ uint32_t zone;
+ agl_direction type; /* agl_input/agl_output */
+ const char *rtgroup;
+} classmap_def;
+
+ /* TYPE MAP ("event"=agl_event, "music"=agl_player...) */
+typedef struct {
+ const char *id;
+ agl_node_type type;
+} typemap_def;
+
+ /* PRIORITY MAP (agl_event=5, agl_phone=4, [...] agl_player=1...) */
+typedef struct {
+ agl_node_type class;
+ int priority;
+} prior_def;
+
+const char *pa_config_file_get_path (const char *, const char *, char *, size_t);
+bool pa_config_parse_file (struct userdata *, const char *);
+bool pa_config_dofile (struct userdata *, const char *);
+
+#endif
diff --git a/module.c b/module.c
index beb2c73..d047b26 100644
--- a/module.c
+++ b/module.c
@@ -34,6 +34,7 @@ $ pactl load-module mypamodule
#include <pulsecore/modargs.h> /* for "pa_modargs" */
#include "userdata.h" /* for "struct userdata" */
+#include "config.h" /* for "pa_config_...()" */
#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" */
@@ -80,6 +81,8 @@ int pa__init (pa_module *m)
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) */
+ const char *cfgpath;
+ char buf[4096];
pa_assert (m);
@@ -115,6 +118,11 @@ int pa__init (pa_module *m)
m->userdata = u;
+ /* apply the config file */
+
+ cfgpath = pa_config_file_get_path (cfgdir, cfgfile, buf, sizeof(buf));
+ pa_config_parse_file (u, cfgpath);
+
/* really initialize the module's core logic */
pa_tracker_synchronize (u);
diff --git a/router.c b/router.c
index 2478ab2..c1e7d2a 100644
--- a/router.c
+++ b/router.c
@@ -84,6 +84,30 @@ void pa_router_done (struct userdata *u)
}
}
+bool agl_router_default_accept (struct userdata *u, agl_rtgroup *rtg, agl_node *node)
+{
+ /* TODO */
+ return true;
+}
+
+bool agl_router_phone_accept (struct userdata *u, agl_rtgroup *rtg, agl_node *node)
+{
+ /* TODO */
+ return true;
+}
+
+int agl_router_default_compare (struct userdata *u, agl_rtgroup *rtg, agl_node *n1, agl_node *n2)
+{
+ /* TODO */
+ return 1;
+}
+
+int agl_router_phone_compare (struct userdata *u, agl_rtgroup *rtg, agl_node *n1, agl_node *n2)
+{
+ /* TODO */
+ return 1;
+}
+
void agl_router_register_node (struct userdata *u, agl_node *node)
{
pa_assert (u);
diff --git a/router.h b/router.h
index 93b29d8..a1d2f7f 100644
--- a/router.h
+++ b/router.h
@@ -28,15 +28,14 @@
#define AGL_ZONE_MAX 8 /* max 8 zones, demo is using 5 */ /* DEFINED IN MURPHY */
-/*typedef bool (*agl_rtgroup_accept_t)(struct userdata *, agl_rtgroup *, agl_node *);*/
-/*typedef int (*agl_rtgroup_compare_t)(struct userdata *, agl_rtgroup *, agl_node *, agl_node *);*/
+typedef bool (*agl_rtgroup_accept_t)(struct userdata *, agl_rtgroup *, agl_node *);
+typedef int (*agl_rtgroup_compare_t)(struct userdata *, agl_rtgroup *, agl_node *, agl_node *);
struct agl_rtgroup {
char *name; /**< name of the rtgroup */
agl_dlist entries; /**< listhead of ordered rtentries */
- /*agl_rtgroup_accept_t accept;*/ /**< function pointer, whether to accept a node or not */
- /*agl_rtgroup_compare_t compare;*/ /**< function pointer, comparision for ordering */
- /*scripting_rtgroup *scripting;*/ /**< data for scripting, if any */
+ agl_rtgroup_accept_t accept; /**< function pointer, whether to accept a node or not */
+ agl_rtgroup_compare_t compare; /**< function pointer, comparision for ordering */
};
typedef struct {
@@ -71,6 +70,11 @@ struct agl_connection {
pa_router *pa_router_init (struct userdata *);
void pa_router_done (struct userdata *);
+bool agl_router_default_accept (struct userdata *, agl_rtgroup *, agl_node *);
+bool agl_router_phone_accept (struct userdata *, agl_rtgroup *, agl_node *);
+int agl_router_default_compare (struct userdata *, agl_rtgroup *, agl_node *, agl_node *);
+int agl_router_phone_compare (struct userdata *, agl_rtgroup *, agl_node *, agl_node *);
+
void agl_router_register_node (struct userdata *, agl_node *);
void agl_router_unregister_node (struct userdata *, agl_node *);
agl_node *agl_router_make_prerouting (struct userdata *, agl_node *);