summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-01-23 13:27:30 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-01-23 13:27:30 +0000
commit5b601136563565049e0dc726b67860bc636e03bd (patch)
treea94d2dae627d3beb78ab0f8c7b3e8e7ec324f367 /audio
parentf978653b315bc6d9d029dae1206085ba579fced4 (diff)
Add config options for each source.
Diffstat (limited to 'audio')
-rw-r--r--audio/a2dp.c91
-rw-r--r--audio/a2dp.h2
-rw-r--r--audio/audio.conf3
-rw-r--r--audio/avdtp.c2
-rw-r--r--audio/manager.c28
5 files changed, 90 insertions, 36 deletions
diff --git a/audio/a2dp.c b/audio/a2dp.c
index 01738118..fa5ff2bf 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -969,7 +969,7 @@ static int a2dp_source_record(sdp_buf_t *buf)
static int a2dp_sink_record(sdp_buf_t *buf)
{
- return 0;
+ return -1;
}
static struct a2dp_sep *a2dp_add_sep(DBusConnection *conn, uint8_t type,
@@ -1008,6 +1008,7 @@ static struct a2dp_sep *a2dp_add_sep(DBusConnection *conn, uint8_t type,
if (*record_id != 0)
goto add;
+ memset(&buf, 0, sizeof(buf));
if (create_record(&buf) < 0) {
error("Unable to allocate new service record");
avdtp_unregister_sep(sep->sep);
@@ -1030,25 +1031,95 @@ add:
return sep;
}
-int a2dp_init(DBusConnection *conn, int sources, int sinks)
+int a2dp_init(DBusConnection *conn, GKeyFile *config)
{
+ int sbc_srcs = 1, sbc_sinks = 0;
+ int mpeg12_srcs = 0, mpeg12_sinks = 0;
+ gboolean src = TRUE, sink = TRUE;
+ char *str;
+ GError *err = NULL;
int i;
- if (!sources && !sinks)
- return 0;
+ if (!config)
+ goto proceed;
+
+ str = g_key_file_get_string(config, "General", "Disable", &err);
+
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ if (strstr(str, "Sink"))
+ sink = FALSE;
+ if (strstr(str, "Source"))
+ src = FALSE;
+ g_free(str);
+ }
+ str = g_key_file_get_string(config, "A2DP", "SBCSources", &err);
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ sbc_srcs = atoi(str);
+ g_free(str);
+ }
+
+ str = g_key_file_get_string(config, "A2DP", "MPEG12Sources", &err);
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ mpeg12_srcs = atoi(str);
+ g_free(str);
+ }
+
+ str = g_key_file_get_string(config, "A2DP", "SBCSinks", &err);
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ sbc_sinks = atoi(str);
+ g_free(str);
+ }
+
+ str = g_key_file_get_string(config, "A2DP", "MPEG12Sinks", &err);
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else {
+ mpeg12_sinks = atoi(str);
+ g_free(str);
+ }
+
+proceed:
connection = dbus_connection_ref(conn);
avdtp_init();
- for (i = 0; i < sources; i++) {
- a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE, A2DP_CODEC_SBC);
- a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE, A2DP_CODEC_MPEG12);
+ if (src) {
+ for (i = 0; i < sbc_srcs; i++)
+ a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE,
+ A2DP_CODEC_SBC);
+
+ for (i = 0; i < mpeg12_srcs; i++)
+ a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE,
+ A2DP_CODEC_MPEG12);
}
- for (i = 0; i < sinks; i++) {
- a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK, A2DP_CODEC_SBC);
- a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK, A2DP_CODEC_MPEG12);
+ if (sink) {
+ for (i = 0; i < sbc_sinks; i++)
+ a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK,
+ A2DP_CODEC_SBC);
+
+ for (i = 0; i < mpeg12_sinks; i++)
+ a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK,
+ A2DP_CODEC_MPEG12);
}
return 0;
diff --git a/audio/a2dp.h b/audio/a2dp.h
index 84301bad..a83b523a 100644
--- a/audio/a2dp.h
+++ b/audio/a2dp.h
@@ -129,7 +129,7 @@ typedef void (*a2dp_stream_cb_t) (struct avdtp *session,
struct avdtp_error *err,
void *user_data);
-int a2dp_init(DBusConnection *conn, int sources, int sinks);
+int a2dp_init(DBusConnection *conn, GKeyFile *config);
void a2dp_exit(void);
unsigned int a2dp_source_config(struct avdtp *session, a2dp_config_cb_t cb,
diff --git a/audio/audio.conf b/audio/audio.conf
index ae9742b8..0d733105 100644
--- a/audio/audio.conf
+++ b/audio/audio.conf
@@ -34,4 +34,5 @@ ExtendedErrorResultCodes=false
# Just an example of potential config options for the other interfaces
#[A2DP]
-#SourceCount=2
+#SBCSources=1
+#MPEG12Sources=0
diff --git a/audio/avdtp.c b/audio/avdtp.c
index 97868a07..55addb0b 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -2717,6 +2717,8 @@ struct avdtp_local_sep *avdtp_register_sep(uint8_t type, uint8_t media_type,
sep->cfm = cfm;
sep->user_data = user_data;
+ debug("SEP %p registered: type:%d codec:%d seid:%d", sep,
+ sep->info.type, sep->codec, sep->info.seid);
local_seps = g_slist_append(local_seps, sep);
return sep;
diff --git a/audio/manager.c b/audio/manager.c
index 931af069..1c8970d1 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -1634,7 +1634,6 @@ static void server_exit(void)
int audio_init(DBusConnection *conn, GKeyFile *config)
{
- int sinks, sources;
char *str;
GError *err = NULL;
@@ -1693,29 +1692,10 @@ int audio_init(DBusConnection *conn, GKeyFile *config)
goto failed;
}
- if (enabled.sink) {
- if (config) {
- str = g_key_file_get_string(config, "A2DP",
- "SourceCount", &err);
- if (err) {
- debug("audio.conf: %s", err->message);
- g_error_free(err);
- err = NULL;
- } else {
- sources = atoi(str);
- g_free(str);
- }
- }
- } else
- sources = 0;
-
- if (enabled.source)
- sinks = 1;
- else
- sinks = 0;
-
- if (a2dp_init(conn, sources, sinks) < 0)
- goto failed;
+ if (enabled.source || enabled.sink) {
+ if (a2dp_init(conn, config) < 0)
+ goto failed;
+ }
if (enabled.control && avrcp_init(conn) < 0)
goto failed;