summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2009-07-02 19:04:10 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2009-07-02 19:04:10 -0300
commitb2c0dfb92fae9fda8a767785d23eca11c634967a (patch)
tree23e4aecfa613f3d3936fa31061c99743356804e3
parent79a7b2f441b82f59fe9f0bb1357ee1a1cc1e752f (diff)
downloadbluez-b2c0dfb92fae9fda8a767785d23eca11c634967a.tar.gz
Make headset connection attempt really cancelable.
The io channel should be stored in order to cancel connection attempt, but this also fixes the situation where the headset connects back while we are trying to connect to it.
-rw-r--r--audio/headset.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/audio/headset.c b/audio/headset.c
index 74435bf6a..48a66b9ab 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1298,11 +1298,8 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
goto failed;
}
- if (hs->tmp_rfcomm) {
- hs->rfcomm = hs->tmp_rfcomm;
- hs->tmp_rfcomm = NULL;
- } else
- hs->rfcomm = g_io_channel_ref(chan);
+ hs->rfcomm = hs->tmp_rfcomm;
+ hs->tmp_rfcomm = NULL;
ba2str(&dev->dst, hs_address);
@@ -1514,7 +1511,6 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
struct headset *hs = dev->headset;
char address[18];
GError *err = NULL;
- GIOChannel *io;
if (!manager_allow_headset_connection(dev))
return -ECONNREFUSED;
@@ -1527,16 +1523,16 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
debug("%s: Connecting to %s channel %d", dev->path, address,
hs->rfcomm_ch);
- io = bt_io_connect(BT_IO_RFCOMM, headset_connect_cb, dev,
- NULL, &err,
- BT_IO_OPT_SOURCE_BDADDR, &dev->src,
- BT_IO_OPT_DEST_BDADDR, &dev->dst,
- BT_IO_OPT_CHANNEL, hs->rfcomm_ch,
- BT_IO_OPT_INVALID);
+ hs->tmp_rfcomm = bt_io_connect(BT_IO_RFCOMM, headset_connect_cb, dev,
+ NULL, &err,
+ BT_IO_OPT_SOURCE_BDADDR, &dev->src,
+ BT_IO_OPT_DEST_BDADDR, &dev->dst,
+ BT_IO_OPT_CHANNEL, hs->rfcomm_ch,
+ BT_IO_OPT_INVALID);
hs->rfcomm_ch = -1;
- if (!io) {
+ if (!hs->tmp_rfcomm) {
error("%s", err->message);
g_error_free(err);
return -EIO;
@@ -1544,8 +1540,6 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
hs->hfp_active = hs->hfp_handle != 0 ? TRUE : FALSE;
- g_io_channel_unref(io);
-
headset_set_state(dev, HEADSET_STATE_CONNECT_IN_PROGRESS);
pending_connect_init(hs, HEADSET_STATE_CONNECTED);