summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-02-25 15:48:39 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2009-02-25 15:48:39 +0200
commit6bebcccff34094932b9c46e60b9478474a52bbc4 (patch)
tree70ebaafccb9bcf5549888f2ee2b5183771c3d700
parentc69555a4642e3d74a192c45500a0424bf0fa6ccc (diff)
Rework avctp_confirm_cb logic
-rw-r--r--audio/control.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/audio/control.c b/audio/control.c
index 40578373..58b4dc01 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -689,7 +689,6 @@ static void avctp_confirm_cb(GIOChannel *chan, gpointer data)
struct audio_device *dev;
char address[18];
bdaddr_t src, dst;
- int perr;
GError *err = NULL;
bt_io_get(chan, BT_IO_L2CAP, &err,
@@ -736,24 +735,19 @@ static void avctp_confirm_cb(GIOChannel *chan, gpointer data)
session->state = AVCTP_STATE_CONNECTING;
session->io = g_io_channel_ref(chan);
- if (avdtp_is_connected(&src, &dst))
- goto proceed;
-
- perr = btd_request_authorization(&src, &dst, AVRCP_TARGET_UUID,
- auth_cb, dev->control);
- if (perr < 0)
- goto drop;
-
- return;
-
-proceed:
- if (!bt_io_accept(chan, avctp_connect_cb, dev->control, NULL, NULL))
+ if (avdtp_is_connected(&src, &dst)) {
+ if (!bt_io_accept(chan, avctp_connect_cb, dev->control,
+ NULL, NULL))
+ goto drop;
+ } else if (btd_request_authorization(&src, &dst,
+ AVRCP_TARGET_UUID, auth_cb, dev->control) < 0)
goto drop;
return;
drop:
- g_io_channel_shutdown(chan, TRUE, NULL);
+ if (!session->io)
+ g_io_channel_shutdown(chan, TRUE, NULL);
avctp_unref(session);
}