All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: "Frédéric Dalleau" <frederic.dalleau@linux.intel.com>
Subject: [PATCH 1/2] Add watch for RFCOMM disconnect to HFP HF role
Date: Thu,  4 Aug 2011 15:31:13 +0200	[thread overview]
Message-ID: <1312464674-18828-1-git-send-email-frederic.dalleau@linux.intel.com> (raw)

---
 audio/gateway.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/audio/gateway.c b/audio/gateway.c
index 345f397..77aec59 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -192,9 +192,26 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 				(GIOFunc) sco_io_cb, dev);
 }
 
+static gboolean rfcomm_disconnect_cb(GIOChannel *chan, GIOCondition cond,
+			struct audio_device *dev)
+{
+	struct gateway *gw = dev->gateway;
+
+	if (cond & G_IO_NVAL)
+		return FALSE;
+
+	g_io_channel_shutdown(gw->rfcomm, TRUE, NULL);
+	g_io_channel_unref(gw->rfcomm);
+	gw->rfcomm = NULL;
+	change_state(dev, GATEWAY_STATE_DISCONNECTED);
+
+	return FALSE;
+}
+
 static void newconnection_reply(DBusPendingCall *call, void *data)
 {
 	struct audio_device *dev = data;
+	struct gateway *gw = dev->gateway;
 	DBusMessage *reply = dbus_pending_call_steal_reply(call);
 	DBusError derr;
 
@@ -206,6 +223,8 @@ static void newconnection_reply(DBusPendingCall *call, void *data)
 	dbus_error_init(&derr);
 	if (!dbus_set_error_from_message(&derr, reply)) {
 		DBG("Agent reply: file descriptor passed successfully");
+		g_io_add_watch(gw->rfcomm, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+					(GIOFunc) rfcomm_disconnect_cb, dev);
 		change_state(dev, GATEWAY_STATE_CONNECTED);
 		goto done;
 	}
-- 
1.7.1


             reply	other threads:[~2011-08-04 13:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 13:31 Frédéric Dalleau [this message]
2011-08-04 13:31 ` [PATCH 2/2] Minor style fix in audio/gateway.c Frédéric Dalleau
2011-08-05  9:20 ` [PATCH 1/2] Add watch for RFCOMM disconnect to HFP HF role 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=1312464674-18828-1-git-send-email-frederic.dalleau@linux.intel.com \
    --to=frederic.dalleau@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.