From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] Wait SCO socket to HUP before changing state
Date: Thu, 24 Mar 2011 14:09:53 +0200 [thread overview]
Message-ID: <1300968593-25442-2-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1300968593-25442-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
In situations where application wants to switch profiles e.g hfp to a2dp
it normally needs to wait SCO to be disconnected to resume a2dp due to
resource limitations on headset.
There seems to be an issue in the kernel side which prevent this to work
properly, apparently shutdown does not wait the link to be disconnected,
but it is under investigation.
---
audio/headset.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/audio/headset.c b/audio/headset.c
index bdaa8da..dff10d1 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1345,6 +1345,7 @@ static gboolean sco_cb(GIOChannel *chan, GIOCondition cond,
error("Audio connection got disconnected");
+ pending_connect_finalize(device);
headset_set_state(device, HEADSET_STATE_CONNECTED);
return FALSE;
@@ -2385,6 +2386,7 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
{
struct headset *hs = dev->headset;
unsigned int id;
+ int sock;
if (hs->state == HEADSET_STATE_DISCONNECTED ||
hs->state == HEADSET_STATE_CONNECTING)
@@ -2395,10 +2397,12 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
hs->dc_timer = 0;
}
- headset_set_state(dev, HEADSET_STATE_CONNECTED);
+ sock = g_io_channel_unix_get_fd(hs->sco);
+
+ /* shutdown but leave the socket open and wait for hup */
+ shutdown(sock, SHUT_RDWR);
id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data);
- g_idle_add((GSourceFunc) dummy_connect_complete, dev);
return id;
}
--
1.7.1
next prev parent reply other threads:[~2011-03-24 12:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 12:09 [PATCH] Fix error message when getting SCO connection handle Luiz Augusto von Dentz
2011-03-24 12:09 ` Luiz Augusto von Dentz [this message]
2011-03-25 9:11 ` 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=1300968593-25442-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