From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 2/4] android/A2DP: Use avdtp_add_disconnect_cb to cleanup on disconnect
Date: Thu, 19 Dec 2013 17:15:54 +0200 [thread overview]
Message-ID: <1387466156-14100-2-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1387466156-14100-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replaces the use of g_io_add_watch with avdtp_add_disconnect_cb so
connection tracking stay within AVDTP code.
---
android/a2dp.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/android/a2dp.c b/android/a2dp.c
index 107cbb8..2de2f66 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -57,7 +57,6 @@ struct a2dp_device {
bdaddr_t dst;
uint8_t state;
GIOChannel *io;
- guint watch;
struct avdtp *session;
};
@@ -74,9 +73,6 @@ static void a2dp_device_free(struct a2dp_device *dev)
if (dev->session)
avdtp_unref(dev->session);
- if (dev->watch > 0)
- g_source_remove(dev->watch);
-
if (dev->io)
g_io_channel_unref(dev->io);
@@ -120,13 +116,11 @@ static void bt_a2dp_notify_state(struct a2dp_device *dev, uint8_t state)
a2dp_device_free(dev);
}
-static gboolean watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
+static void disconnect_cb(void *user_data)
{
- struct a2dp_device *dev = data;
+ struct a2dp_device *dev = user_data;
bt_a2dp_notify_state(dev, HAL_A2DP_STATE_DISCONNECTED);
-
- return FALSE;
}
static void signaling_connect_cb(GIOChannel *chan, GError *err,
@@ -157,9 +151,7 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,
/* FIXME: Add proper version */
fd = g_io_channel_unix_get_fd(chan);
dev->session = avdtp_new(fd, imtu, omtu, 0x0100);
-
- dev->watch = g_io_add_watch(dev->io, G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- watch_cb, dev);
+ avdtp_add_disconnect_cb(dev->session, disconnect_cb, dev);
bt_a2dp_notify_state(dev, HAL_A2DP_STATE_CONNECTED);
}
--
1.8.3.1
next prev parent reply other threads:[~2013-12-19 15:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 15:15 [PATCH BlueZ 1/4] android/AVDTP: Add avdtp_add_disconnect_cb and avdtp_remove_disconnect_cb Luiz Augusto von Dentz
2013-12-19 15:15 ` Luiz Augusto von Dentz [this message]
2013-12-19 15:15 ` [PATCH BlueZ 3/4] android/AVDTP: Add avdtp_shutdown Luiz Augusto von Dentz
2013-12-19 15:15 ` [PATCH BlueZ 4/4] android/A2DP: Fix disconnecting after AVDTP session creation Luiz Augusto von Dentz
2013-12-20 7:28 ` [PATCH BlueZ 1/4] android/AVDTP: Add avdtp_add_disconnect_cb and avdtp_remove_disconnect_cb Johan Hedberg
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=1387466156-14100-2-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