diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-05-31 12:51:49 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-05-31 12:51:49 +0000 |
commit | 814aed96a2c0afa4218cc4384425934fd30faa68 (patch) | |
tree | 282ce6614f1d90febd43fa05fcf03847831a0ee7 /audio | |
parent | 06e91735ba34f0f445badc796eeeb8f52e881281 (diff) |
Add support for configuration file
Diffstat (limited to 'audio')
-rw-r--r-- | audio/Makefile.am | 4 | ||||
-rw-r--r-- | audio/audio.conf | 27 | ||||
-rw-r--r-- | audio/headset.c | 3 | ||||
-rw-r--r-- | audio/headset.h | 3 | ||||
-rw-r--r-- | audio/main.c | 57 |
5 files changed, 89 insertions, 5 deletions
diff --git a/audio/Makefile.am b/audio/Makefile.am index 63448a86..2285ed7f 100644 --- a/audio/Makefile.am +++ b/audio/Makefile.am @@ -3,7 +3,7 @@ if AUDIOSERVICE if CONFIGFILES confdir = $(sysconfdir)/bluetooth -conf_DATA = audio.service +conf_DATA = audio.service audio.conf endif servicedir = $(libdir)/bluetooth @@ -35,6 +35,6 @@ AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @ALSA_CFLAGS@ @SBC_CFLAGS INCLUDES = -I$(top_srcdir)/common -EXTRA_DIST = audio.service audio-api.txt asound.conf +EXTRA_DIST = audio.service audio.conf audio-api.txt asound.conf MAINTAINERCLEANFILES = Makefile.in diff --git a/audio/audio.conf b/audio/audio.conf new file mode 100644 index 00000000..f88668e4 --- /dev/null +++ b/audio/audio.conf @@ -0,0 +1,27 @@ +# Configuration file for the audio service + +# This section contains options which are not specific to any +# particular interface +[General] + +# If we want to disable support for specific services +# Defaults to supporting all implemented services +#Disable=Control,Source + +# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA) +# Defaults to HCI +SCORouting=PCM + +# Headset interface specific options (i.e. options which affect how the audio +# service interacts with remote headset devices) +[Headset] + +# Set to true to only support HSP +# Defaults to false +DisableHFP=true + +# Just an example of potential config options for the other interfaces +#[Sink] +#Codecs=SBC,MPEG12 +#SBCChannelMode=joint +#SBCBitpool=51 diff --git a/audio/headset.c b/audio/headset.c index d9e26459..45f989bc 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1702,7 +1702,8 @@ gboolean headset_is_connected(headset_t *headset) return FALSE; } -int headset_server_init(DBusConnection *conn, gboolean no_hfp) +int headset_server_init(DBusConnection *conn, gboolean no_hfp, + gboolean sco_hci) { uint8_t chan = DEFAULT_HS_AG_CHANNEL; sdp_buf_t buf; diff --git a/audio/headset.h b/audio/headset.h index c02f36a3..0325e755 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -42,7 +42,8 @@ void headset_update(headset_t *headset, sdp_record_t *record, uint16_t svc); gboolean headset_is_connected(headset_t *headset); -int headset_server_init(DBusConnection *conn, gboolean disable_hfp); +int headset_server_init(DBusConnection *conn, gboolean disable_hfp, + gboolean sco_hci); void headset_exit(void); 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); } |