summaryrefslogtreecommitdiffstats
path: root/audio/main.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-05-31 12:51:49 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-05-31 12:51:49 +0000
commit814aed96a2c0afa4218cc4384425934fd30faa68 (patch)
tree282ce6614f1d90febd43fa05fcf03847831a0ee7 /audio/main.c
parent06e91735ba34f0f445badc796eeeb8f52e881281 (diff)
Add support for configuration file
Diffstat (limited to 'audio/main.c')
-rw-r--r--audio/main.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/audio/main.c b/audio/main.c
index b0eb30c8..796af3b5 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -40,6 +40,10 @@
#include "manager.h"
#include "headset.h"
+/* Configuration settings */
+static gboolean disable_hfp = FALSE;
+static gboolean sco_hci = TRUE;
+
static GMainLoop *main_loop = NULL;
static void sig_term(int sig)
@@ -47,6 +51,55 @@ static void sig_term(int sig)
g_main_loop_quit(main_loop);
}
+void read_config(const char *file)
+{
+ GKeyFile *keyfile;
+ GError *err = NULL;
+ gboolean no_hfp;
+ char *sco_routing;
+
+ keyfile = g_key_file_new();
+
+ if (!g_key_file_load_from_file(keyfile, file, 0, &err)) {
+ error("Parsing %s failed: %s", file, err->message);
+ g_error_free(err);
+ g_key_file_free(keyfile);
+ return;
+ }
+
+ sco_routing = g_key_file_get_string(keyfile, "General",
+ "SCORouting", &err);
+ if (err) {
+ debug("%s: %s", file, err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ if (strcmp(sco_routing, "PCM") == 0)
+ sco_hci = FALSE;
+ else if (strcmp(sco_routing, "HCI") == 0)
+ sco_hci = TRUE;
+ else
+ error("Invalid Headset Routing value: %s",
+ sco_routing);
+ g_free(sco_routing);
+ }
+
+ no_hfp = g_key_file_get_boolean(keyfile, "Headset",
+ "DisableHFP", &err);
+ if (err) {
+ debug("%s: %s", file, err->message);
+ g_error_free(err);
+ err = NULL;
+ } else
+ disable_hfp = no_hfp;
+
+ debug("Config options: DisableHFP=%s, SCORouting=%s",
+ disable_hfp ? "true" : "false",
+ sco_hci ? "HCI" : "PCM");
+
+ g_key_file_free(keyfile);
+}
+
int main(int argc, char *argv[])
{
DBusConnection *conn;
@@ -66,6 +119,8 @@ int main(int argc, char *argv[])
enable_debug();
+ read_config(CONFIGDIR "/audio.conf");
+
main_loop = g_main_loop_new(NULL, FALSE);
conn = dbus_bus_system_setup_with_main_loop(NULL, NULL, NULL);
@@ -84,7 +139,7 @@ int main(int argc, char *argv[])
exit(1);
}
- if (headset_server_init(conn, TRUE) < 0) {
+ if (headset_server_init(conn, disable_hfp, sco_hci) < 0) {
error("Headset initialization failed!");
exit(1);
}