summaryrefslogtreecommitdiffstats
path: root/audio/control.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-03-05 17:43:54 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-03-05 17:43:54 +0000
commitaa4ce3509e6bf62a20e89d680e2792388f0afde1 (patch)
tree18aa2354290c96b7d1a1c8a941463334414163a9 /audio/control.c
parent37c2fa54a9eb3d086849acdf4a4d64157334b21a (diff)
Do master role switching by default and add ForceMaster config option
Diffstat (limited to 'audio/control.c')
-rw-r--r--audio/control.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/audio/control.c b/audio/control.c
index 6085f587..2c8f03ba 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -309,7 +309,7 @@ static int avrcp_tg_record(sdp_buf_t *buf)
return ret;
}
-static GIOChannel *avctp_server_socket(void)
+static GIOChannel *avctp_server_socket(gboolean master)
{
int sock, lm;
struct sockaddr_l2 addr;
@@ -322,6 +322,10 @@ static GIOChannel *avctp_server_socket(void)
}
lm = L2CAP_LM_SECURE;
+
+ if (master)
+ lm |= L2CAP_LM_MASTER;
+
if (setsockopt(sock, SOL_L2CAP, L2CAP_LM, &lm, sizeof(lm)) < 0) {
error("AVCTP server setsockopt: %s (%d)", strerror(errno), errno);
close(sock);
@@ -975,13 +979,25 @@ void avrcp_disconnect(struct device *dev)
control->session = NULL;
}
-int avrcp_init(DBusConnection *conn)
+int avrcp_init(DBusConnection *conn, GKeyFile *config)
{
sdp_buf_t buf;
+ gboolean tmp, master = TRUE;
+ GError *err = NULL;
if (avctp_server)
return 0;
+
+ tmp = g_key_file_get_boolean(config, "General", "ForceMaster",
+ &err);
+ if (err) {
+ debug("audio.conf: %s", err->message);
+ g_error_free(err);
+ err = NULL;
+ } else
+ master = tmp;
+
connection = dbus_connection_ref(conn);
if (avrcp_tg_record(&buf) < 0) {
@@ -1010,7 +1026,7 @@ int avrcp_init(DBusConnection *conn)
return -1;
}
- avctp_server = avctp_server_socket();
+ avctp_server = avctp_server_socket(master);
if (!avctp_server)
return -1;