summaryrefslogtreecommitdiff
path: root/android/a2dp.c
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2015-02-20 14:43:15 +0200
committerSzymon Janc <szymon.janc@tieto.com>2015-02-22 21:26:25 +0100
commit37c942ff2ba1fc4e42a95957c8f24c19e468d4f0 (patch)
tree92c2c12f6d0e2fc8108c61eec2aefd418fd3320a /android/a2dp.c
parent49450bf6f01f8f08ee585bda8f75ac7d7f40d0af (diff)
downloadbluez-37c942ff2ba1fc4e42a95957c8f24c19e468d4f0.tar.gz
android/avdtp: Refactor local SEP list handling
In order to deduplicate similar code in android/ and profiles/ we need to handle local SEP queue outside of avdtp.c. GSList is transformed to queue.
Diffstat (limited to 'android/a2dp.c')
-rw-r--r--android/a2dp.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/android/a2dp.c b/android/a2dp.c
index 10f552351..f21904208 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -38,6 +38,7 @@
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "profiles/audio/a2dp-codecs.h"
+#include "src/shared/queue.h"
#include "src/log.h"
#include "hal-msg.h"
#include "ipc-common.h"
@@ -65,6 +66,8 @@ static bool audio_retrying = false;
static struct ipc *hal_ipc = NULL;
static struct ipc *audio_ipc = NULL;
+static struct queue *lseps = NULL;
+
struct a2dp_preset {
void *data;
int8_t len;
@@ -115,7 +118,7 @@ static void unregister_endpoint(void *data)
struct a2dp_endpoint *endpoint = data;
if (endpoint->sep)
- avdtp_unregister_sep(endpoint->sep);
+ avdtp_unregister_sep(lseps, endpoint->sep);
if (endpoint->caps)
preset_free(endpoint->caps);
@@ -620,6 +623,7 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,
gpointer user_data)
{
struct a2dp_device *dev = user_data;
+ struct avdtp *session;
uint16_t imtu, omtu;
GError *gerr = NULL;
int fd;
@@ -643,10 +647,12 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,
fd = g_io_channel_unix_get_fd(chan);
/* FIXME: Add proper version */
- dev->session = avdtp_new(fd, imtu, omtu, 0x0100);
- if (!dev->session)
+ session = avdtp_new(fd, imtu, omtu, 0x0100, lseps);
+ if (!session)
goto failed;
+ dev->session = session;
+
avdtp_add_disconnect_cb(dev->session, disconnect_cb, dev);
/* Proceed to stream setup if initiator */
@@ -1327,7 +1333,7 @@ static uint8_t register_endpoint(const uint8_t *uuid, uint8_t codec,
endpoint = g_new0(struct a2dp_endpoint, 1);
endpoint->id = g_slist_length(endpoints) + 1;
endpoint->codec = codec;
- endpoint->sep = avdtp_register_sep(AVDTP_SEP_TYPE_SOURCE,
+ endpoint->sep = avdtp_register_sep(lseps, AVDTP_SEP_TYPE_SOURCE,
AVDTP_MEDIA_TYPE_AUDIO,
codec, FALSE, &sep_ind,
&sep_cfm, endpoint);
@@ -1624,6 +1630,8 @@ static void bt_audio_unregister(void)
ipc_cleanup(audio_ipc);
audio_ipc = NULL;
+
+ queue_destroy(lseps, NULL);
}
static bool bt_audio_register(ipc_disconnect_cb disconnect)
@@ -1691,6 +1699,8 @@ bool bt_a2dp_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
bacpy(&adapter_addr, addr);
+ lseps = queue_new();
+
server = bt_io_listen(connect_cb, NULL, NULL, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
BT_IO_OPT_PSM, AVDTP_PSM,