Diff between cb395e52c28088cfcf56d2fa53aae74af0942179 and 7afd9bba99237644ba1b0898cb49bd35b693896f

Changed Files

File Additions Deletions Status
profiles/audio/avctp.c +7 -0 modified
profiles/audio/avctp.h +1 -0 modified
profiles/audio/avrcp.c +6 -1 modified

Full Patch

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index db03456..314dbfb 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -201,6 +201,7 @@ struct avctp {
 
 	uint8_t key_quirks[256];
 	struct key_pressed key;
+	bool initiator;
 };
 
 struct avctp_passthrough_handler {
@@ -1931,6 +1932,7 @@ struct avctp *avctp_connect(struct audio_device *device)
 	}
 
 	session->control = avctp_channel_create(session, io, NULL);
+	session->initiator = true;
 	g_io_channel_unref(io);
 
 	return session;
@@ -1983,3 +1985,8 @@ struct avctp *avctp_get(struct audio_device *device)
 {
 	return avctp_get_internal(device->btd_dev);
 }
+
+bool avctp_is_initiator(struct avctp *session)
+{
+	return session->initiator;
+}
diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h
index 0a414af..cd575cc 100644
--- a/profiles/audio/avctp.h
+++ b/profiles/audio/avctp.h
@@ -120,6 +120,7 @@ void avctp_unregister(struct btd_adapter *adapter);
 
 struct avctp *avctp_connect(struct audio_device *device);
 struct avctp *avctp_get(struct audio_device *device);
+bool avctp_is_initiator(struct avctp *session);
 int avctp_connect_browsing(struct avctp *session);
 void avctp_disconnect(struct avctp *session);
 
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 4acf396..4558407 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2863,7 +2863,12 @@ static struct avrcp *session_create(struct avrcp_server *server,
 
 	server->sessions = g_slist_append(server->sessions, session);
 
-	if (dev->sink && !dev->source)
+	/* If sink and source are not supported assume the controller must
+	 * be the initiator
+	 */
+	if (dev->sink == NULL && dev->source == NULL)
+		session->target = !avctp_is_initiator(session->conn);
+	else if (dev->sink && !dev->source)
 		session->target = TRUE;
 	else if (dev->source && !dev->sink)
 		session->target = FALSE;