diff --git a/audio/a2dp.c b/audio/a2dp.c
index 1f3bc99..741b134 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
}
}
+ if (sep->locked)
+ return;
+
a2dp_unregister_sep(sep);
}
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);
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;