summaryrefslogtreecommitdiff
path: root/android/avdtp.c
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2015-02-16 15:02:26 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2015-02-19 15:21:08 +0200
commitc4686d50860e18abff8bdaaa77d20d1b783801ae (patch)
tree200edd43877a8264748882f1191a971999587775 /android/avdtp.c
parentdbcd2d44466b35860bb335bd5c8789e7b2a858bb (diff)
downloadbluez-c4686d50860e18abff8bdaaa77d20d1b783801ae.tar.gz
android/avdtp: Fix SEID generation
Fixes SEID generation for avdtp. Currently SEIDs were assigned assuming that SEID are registered and unregistered in the same order like: seid = g_slist_length(seps) + 1 which makes it possible to reuse similar SEIDs. Note that helper function allows maximum id of sizeof(int) * 8 which is smaller then MAX_SEID but more then enough for local SEPs.
Diffstat (limited to 'android/avdtp.c')
-rw-r--r--android/avdtp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/android/avdtp.c b/android/avdtp.c
index 853fdf375..ce75615d3 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -41,10 +41,12 @@
#include "lib/bluetooth.h"
#include "src/log.h"
+#include "src/shared/util.h"
#include "avdtp.h"
#include "../profiles/audio/a2dp-codecs.h"
#define MAX_SEID 0x3E
+static unsigned int seids;
#ifndef MAX
# define MAX(x, y) ((x) > (y) ? (x) : (y))
@@ -3357,7 +3359,7 @@ struct avdtp_local_sep *avdtp_register_sep(uint8_t type, uint8_t media_type,
sep = g_new0(struct avdtp_local_sep, 1);
sep->state = AVDTP_STATE_IDLE;
- sep->info.seid = g_slist_length(lseps) + 1;
+ sep->info.seid = util_get_uid(&seids, MAX_SEID);
sep->info.type = type;
sep->info.media_type = media_type;
sep->codec = codec_type;
@@ -3393,6 +3395,7 @@ int avdtp_unregister_sep(struct avdtp_local_sep *sep)
DBG("SEP %p unregistered: type:%d codec:%d seid:%d", sep,
sep->info.type, sep->codec, sep->info.seid);
+ util_clear_uid(&seids, sep->info.seid);
g_free(sep);
return 0;