Diff between 7ece89b0b6f1ef8b4d4ca132a5163c08a14c41e2 and 4cf79541763cb02e2a553ed16c88bf1d13595eb4

Changed Files

File Additions Deletions Status
profiles/audio/a2dp.c +12 -12 modified

Full Patch

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 35b9e9d..fc98bb2 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1405,12 +1405,22 @@ struct avdtp *a2dp_avdtp_get(struct btd_device *device)
 	if (server == NULL)
 		return NULL;
 
+	chan = queue_find(server->channels, match_by_device, device);
+	if (!chan) {
+		chan = channel_new(server, device, NULL);
+		if (!chan)
+			return NULL;
+	}
+
+	if (chan->session)
+		return avdtp_ref(chan->session);
+
 	/* Check if there is any SEP available */
 	for (entry = queue_get_entries(server->seps); entry;
 					entry = entry->next) {
-		struct a2dp_sep *sep = entry->data;
+		struct avdtp_local_sep *sep = entry->data;
 
-		if (avdtp_sep_get_state(sep->lsep) == AVDTP_STATE_IDLE)
+		if (avdtp_sep_get_state(sep) == AVDTP_STATE_IDLE)
 			goto found;
 	}
 
@@ -1419,16 +1429,6 @@ struct avdtp *a2dp_avdtp_get(struct btd_device *device)
 	return NULL;
 
 found:
-	chan = queue_find(server->channels, match_by_device, device);
-	if (!chan) {
-		chan = channel_new(server, device, NULL);
-		if (!chan)
-			return NULL;
-	}
-
-	if (chan->session)
-		return avdtp_ref(chan->session);
-
 	chan->session = avdtp_new(NULL, device, server->seps);
 	if (!chan->session) {
 		channel_remove(chan);