From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/2] android/A2DP: Add handling of incoming transport connection
Date: Tue, 14 Jan 2014 13:48:09 +0200 [thread overview]
Message-ID: <1389700090-3642-1-git-send-email-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds handling of incoming transport connection attempt.
---
android/a2dp.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 60 insertions(+), 4 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index 9f3164a..aab0940 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -477,6 +477,60 @@ static const struct ipc_handler cmd_handlers[] = {
{ bt_a2dp_disconnect, false, sizeof(struct hal_cmd_a2dp_disconnect) },
};
+static struct a2dp_setup *find_setup_by_device(struct a2dp_device *dev)
+{
+ GSList *l;
+
+ for (l = setups; l; l = g_slist_next(l)) {
+ struct a2dp_setup *setup = l->data;
+
+ if (setup->dev == dev)
+ return setup;
+ }
+
+ return NULL;
+}
+
+static void transport_connect_cb(GIOChannel *chan, GError *err,
+ gpointer user_data)
+{
+ struct a2dp_device *dev = user_data;
+ struct a2dp_setup *setup;
+ uint16_t imtu, omtu;
+ GError *gerr = NULL;
+ int fd;
+
+ if (err) {
+ error("%s", err->message);
+ return;
+ }
+
+ setup = find_setup_by_device(dev);
+ if (!setup) {
+ error("Unable to find stream setup");
+ return;
+ }
+
+ bt_io_get(chan, &gerr,
+ BT_IO_OPT_IMTU, &imtu,
+ BT_IO_OPT_OMTU, &omtu,
+ BT_IO_OPT_INVALID);
+ if (gerr) {
+ error("%s", gerr->message);
+ g_error_free(gerr);
+ return;
+ }
+
+ fd = g_io_channel_unix_get_fd(chan);
+
+ if (!avdtp_stream_set_transport(setup->stream, fd, imtu, omtu)) {
+ error("avdtp_stream_set_transport: failed");
+ return;
+ }
+
+ g_io_channel_set_close_on_unref(chan, FALSE);
+}
+
static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
{
struct a2dp_device *dev;
@@ -501,13 +555,15 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
return;
}
- l = g_slist_find_custom(devices, &dst, device_cmp);
- if (l)
- return;
-
ba2str(&dst, address);
DBG("Incoming connection from %s", address);
+ l = g_slist_find_custom(devices, &dst, device_cmp);
+ if (l) {
+ transport_connect_cb(chan, err, l->data);
+ return;
+ }
+
dev = a2dp_device_new(&dst);
signaling_connect_cb(chan, err, dev);
}
--
1.8.4.2
next reply other threads:[~2014-01-14 11:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-14 11:48 Luiz Augusto von Dentz [this message]
2014-01-14 11:48 ` [PATCH BlueZ 2/2] android/A2DP: Connect transport channel when initiator Luiz Augusto von Dentz
2014-01-15 12:55 ` [PATCH BlueZ 1/2] android/A2DP: Add handling of incoming transport connection Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389700090-3642-1-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox