From e2827b35575bab20a99a170805a0a59a32fb2c48 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 28 Aug 2007 09:54:21 +0000 Subject: Make SBC Audio Source count configurable and the default value 1 --- audio/a2dp.c | 12 ++++++------ audio/a2dp.h | 3 +-- audio/audio.conf | 6 ++---- audio/main.c | 19 ++++++++++++++++--- audio/manager.c | 16 ++++++++++++++-- audio/manager.h | 2 +- 6 files changed, 40 insertions(+), 18 deletions(-) diff --git a/audio/a2dp.c b/audio/a2dp.c index d3cedefc..fad9bd25 100644 --- a/audio/a2dp.c +++ b/audio/a2dp.c @@ -656,21 +656,21 @@ add: return sep; } -int a2dp_init(DBusConnection *conn, gboolean enable_sink, gboolean enable_source) +int a2dp_init(DBusConnection *conn, int sources, int sinks) { - if (!enable_sink && !enable_source) + int i; + + if (!sources && !sinks) return 0; connection = dbus_connection_ref(conn); avdtp_init(); - if (enable_sink) { - a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE); + for (i = 0; i < sources; i++) a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE); - } - if (enable_source) + for (i = 0; i < sinks; i++) a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK); return 0; diff --git a/audio/a2dp.h b/audio/a2dp.h index 0a838b62..4804c5f1 100644 --- a/audio/a2dp.h +++ b/audio/a2dp.h @@ -64,8 +64,7 @@ typedef void (*a2dp_stream_cb_t) (struct avdtp *session, struct device *dev, struct avdtp_stream *stream, void *user_data); -int a2dp_init(DBusConnection *conn, gboolean enable_sink, - gboolean enable_source); +int a2dp_init(DBusConnection *conn, int sources, int sinks); void a2dp_exit(void); unsigned int a2dp_source_request_stream(struct avdtp *session, diff --git a/audio/audio.conf b/audio/audio.conf index f88668e4..97fd90f4 100644 --- a/audio/audio.conf +++ b/audio/audio.conf @@ -21,7 +21,5 @@ SCORouting=PCM DisableHFP=true # Just an example of potential config options for the other interfaces -#[Sink] -#Codecs=SBC,MPEG12 -#SBCChannelMode=joint -#SBCBitpool=51 +#[A2DP] +#SourceCount=2 diff --git a/audio/main.c b/audio/main.c index ae43f170..8e27190c 100644 --- a/audio/main.c +++ b/audio/main.c @@ -43,6 +43,7 @@ static gboolean disable_hfp = TRUE; static gboolean sco_hci = FALSE; +static int source_count = 1; static GMainLoop *main_loop = NULL; @@ -123,9 +124,20 @@ static void read_config(const char *file) } else disable_hfp = no_hfp; - debug("Config options: DisableHFP=%s, SCORouting=%s", + str = g_key_file_get_string(keyfile, "A2DP", + "SourceCount", &err); + if (err) { + debug("%s: %s", file, err->message); + g_error_free(err); + err = NULL; + } else { + source_count = atoi(str); + g_free(str); + } + + debug("Config options: DisableHFP=%s, SCORouting=%s, SourceCount=%d", disable_hfp ? "true" : "false", - sco_hci ? "HCI" : "PCM"); + sco_hci ? "HCI" : "PCM", source_count); g_key_file_free(keyfile); } @@ -164,7 +176,8 @@ int main(int argc, char *argv[]) exit(1); } - if (audio_init(conn, &enabled, disable_hfp, sco_hci) < 0) { + if (audio_init(conn, &enabled, disable_hfp, sco_hci, + source_count) < 0) { error("Audio init failed!"); exit(1); } diff --git a/audio/manager.c b/audio/manager.c index 1228b2cc..54b95538 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -1567,8 +1567,10 @@ static void server_exit(void) } int audio_init(DBusConnection *conn, struct enabled_interfaces *enable, - gboolean no_hfp, gboolean sco_hci) + gboolean no_hfp, gboolean sco_hci, int source_count) { + int sinks, sources; + connection = dbus_connection_ref(conn); enabled = enable; @@ -1582,7 +1584,17 @@ int audio_init(DBusConnection *conn, struct enabled_interfaces *enable, if (headset_server_init(conn, no_hfp) < 0) goto failed; - if (a2dp_init(conn, enable->sink, enable->source) < 0) + if (enable->sink) + sources = source_count; + else + sources = 0; + + if (enable->source) + sinks = 1; + else + sinks = 0; + + if (a2dp_init(conn, sources, sinks) < 0) goto failed; if (!dbus_connection_register_interface(conn, AUDIO_MANAGER_PATH, diff --git a/audio/manager.h b/audio/manager.h index 42632d17..ceabe680 100644 --- a/audio/manager.h +++ b/audio/manager.h @@ -37,7 +37,7 @@ struct enabled_interfaces { typedef void (*create_dev_cb_t) (struct device *dev, void *user_data); int audio_init(DBusConnection *conn, struct enabled_interfaces *enabled, - gboolean no_hfp, gboolean sco_hci); + gboolean no_hfp, gboolean sco_hci, int source_count); void audio_exit(void); -- cgit