@@ -118,6 +118,7 @@ struct a2dp_server {
uint32_t sink_record_id;
gboolean sink_enabled;
gboolean source_enabled;
+ uint64_t seid_pool;
GIOChannel *io;
struct queue *seps;
struct queue *channels;
@@ -2553,7 +2554,7 @@ static void a2dp_unregister_sep(struct a2dp_sep *sep)
sep->endpoint = NULL;
}
- avdtp_unregister_sep(server->seps, sep->lsep);
+ avdtp_unregister_sep(server->seps, &server->seid_pool, sep->lsep);
g_free(sep);
@@ -2615,7 +2616,7 @@ struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
sep = g_new0(struct a2dp_sep, 1);
- sep->lsep = avdtp_register_sep(server->seps, type,
+ sep->lsep = avdtp_register_sep(server->seps, &server->seid_pool, type,
AVDTP_MEDIA_TYPE_AUDIO, codec,
delay_reporting, &endpoint_ind,
&cfm, sep);
@@ -44,7 +44,6 @@
#define AVDTP_PSM 25
#define MAX_SEID 0x3E
-static uint64_t seids;
#ifndef MAX
# define MAX(x, y) ((x) > (y) ? (x) : (y))
@@ -3768,7 +3767,9 @@ int avdtp_delay_report(struct avdtp *session, struct avdtp_stream *stream,
&req, sizeof(req));
}
-struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
+struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps,
+ uint64_t *seid_pool,
+ uint8_t type,
uint8_t media_type,
uint8_t codec_type,
gboolean delay_reporting,
@@ -3777,7 +3778,7 @@ struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
void *user_data)
{
struct avdtp_local_sep *sep;
- uint8_t seid = util_get_uid(&seids, MAX_SEID);
+ uint8_t seid = util_get_uid(seid_pool, MAX_SEID);
if (!seid)
return NULL;
@@ -3794,18 +3795,21 @@ struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
sep->user_data = user_data;
sep->delay_reporting = delay_reporting;
- DBG("SEP %p registered: type:%d codec:%d seid:%d", sep,
- sep->info.type, sep->codec, sep->info.seid);
+ DBG("SEP %p registered: type:%d codec:%d seid_pool:%p seid:%d", sep,
+ sep->info.type, sep->codec, seid_pool,
+ sep->info.seid);
if (!queue_push_tail(lseps, sep)) {
g_free(sep);
+ util_clear_uid(seid_pool, seid);
return NULL;
}
return sep;
}
-int avdtp_unregister_sep(struct queue *lseps, struct avdtp_local_sep *sep)
+int avdtp_unregister_sep(struct queue *lseps, uint64_t *seid_pool,
+ struct avdtp_local_sep *sep)
{
if (!sep)
return -EINVAL;
@@ -3813,10 +3817,11 @@ int avdtp_unregister_sep(struct queue *lseps, struct avdtp_local_sep *sep)
if (sep->stream)
release_stream(sep->stream, sep->stream->session);
- DBG("SEP %p unregistered: type:%d codec:%d seid:%d", sep,
- sep->info.type, sep->codec, sep->info.seid);
+ DBG("SEP %p unregistered: type:%d codec:%d seid_pool:%p seid:%d", sep,
+ sep->info.type, sep->codec, seid_pool,
+ sep->info.seid);
- util_clear_uid(&seids, sep->info.seid);
+ util_clear_uid(seid_pool, sep->info.seid);
queue_remove(lseps, sep);
g_free(sep);
@@ -278,7 +278,9 @@ int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream);
int avdtp_delay_report(struct avdtp *session, struct avdtp_stream *stream,
uint16_t delay);
-struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
+struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps,
+ uint64_t *seid_pool,
+ uint8_t type,
uint8_t media_type,
uint8_t codec_type,
gboolean delay_reporting,
@@ -290,7 +292,8 @@ struct avdtp_local_sep *avdtp_register_sep(struct queue *lseps, uint8_t type,
struct avdtp_remote_sep *avdtp_find_remote_sep(struct avdtp *session,
struct avdtp_local_sep *lsep);
-int avdtp_unregister_sep(struct queue *lseps, struct avdtp_local_sep *sep);
+int avdtp_unregister_sep(struct queue *lseps, uint64_t *seid_pool,
+ struct avdtp_local_sep *sep);
avdtp_state_t avdtp_sep_get_state(struct avdtp_local_sep *sep);
uint8_t avdtp_sep_get_seid(struct avdtp_local_sep *sep);