Diff between 51571e74374453305869148aab50d41f163bf9b4 and 1636fb014845743c0000c4030cbf75c55bd3983f

Changed Files

File Additions Deletions Status
audio/a2dp.c +16 -0 modified

Full Patch

diff --git a/audio/a2dp.c b/audio/a2dp.c
index 1f3bc99..741b134 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -1686,6 +1686,9 @@ void a2dp_remove_sep(struct a2dp_sep *sep)
 		}
 	}
 
+	if (sep->locked)
+		return;
+
 	a2dp_unregister_sep(sep);
 }
 
@@ -2286,7 +2289,9 @@ gboolean a2dp_sep_lock(struct a2dp_sep *sep, struct avdtp *session)
 
 gboolean a2dp_sep_unlock(struct a2dp_sep *sep, struct avdtp *session)
 {
+	struct a2dp_server *server = sep->server;
 	avdtp_state_t state;
+	GSList *l;
 
 	state = avdtp_sep_get_state(sep->lsep);
 
@@ -2294,6 +2299,17 @@ gboolean a2dp_sep_unlock(struct a2dp_sep *sep, struct avdtp *session)
 
 	DBG("SEP %p unlocked", sep->lsep);
 
+	if (sep->type == AVDTP_SEP_TYPE_SOURCE)
+		l = server->sources;
+	else
+		l = server->sinks;
+
+	/* Unregister sep if it was removed */
+	if (g_slist_find(l, sep) == NULL) {
+		a2dp_unregister_sep(sep);
+		return TRUE;
+	}
+
 	if (!sep->stream || state == AVDTP_STATE_IDLE)
 		return TRUE;