summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-08 11:21:17 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-10-08 11:21:17 +0200
commit58cd734fdc101b83c4da6b23195b292100f5285f (patch)
treefa751cd3995f7e6ae9f271380e1f470c03cd256a /audio
parent4a663d114edeab8ca7cc567ca9150cd0e45a47cb (diff)
Fail cleanly if we don't have knowledge of a connecting device
Without this fix we segfault if a device pairs and connects to us before we have completed service discovery to it. Underneath is a more fundamental problem of how we initialize our data structures and this still needs fixing.
Diffstat (limited to 'audio')
-rw-r--r--audio/control.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/audio/control.c b/audio/control.c
index 2b37fd3f..1dcab3c2 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -606,15 +606,18 @@ static void init_uinput(struct avctp *session)
debug("AVRCP: uinput initialized for %s", address);
}
-static void avctp_connect_session(struct avctp *session)
+static gboolean avctp_connect_session(struct avctp *session)
{
GIOChannel *io;
gboolean value;
- session->state = AVCTP_STATE_CONNECTED;
session->dev = manager_find_device(&session->dst, NULL, FALSE);
- if (!session->dev)
- return;
+ if (!session->dev) {
+ error("Connecting audio device not known (SDP not completed)");
+ return FALSE;
+ }
+
+ session->state = AVCTP_STATE_CONNECTED;
session->dev->control->session = session;
@@ -638,6 +641,8 @@ static void avctp_connect_session(struct avctp *session)
G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
(GIOFunc) session_cb, session);
g_io_channel_unref(io);
+
+ return TRUE;
}
static void auth_cb(DBusError *derr, void *user_data)
@@ -710,7 +715,8 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
return;
proceed:
- avctp_connect_session(session);
+ if (!avctp_connect_session(session))
+ goto drop;
return;