summaryrefslogtreecommitdiffstats
path: root/audio/control.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-08 14:44:54 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-10-08 14:44:54 +0200
commit3161f96838b8f79574ee93b0525942d7c732535e (patch)
tree37c932f0185a0ee8a69a585850c6e20ef0851230 /audio/control.c
parent586fd91a6c1a18e7e324fe39c20786be357c3576 (diff)
Create audio device objects on incoming connections if necessary
If we haven't done SDP yet the data structures will be uninitialized. This patch makes sure that the structures are properly initialized if we get an incoming connection before service discovery has been done.
Diffstat (limited to 'audio/control.c')
-rw-r--r--audio/control.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/audio/control.c b/audio/control.c
index 1dcab3c2..8b3b2d8a 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -666,6 +666,7 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
struct l2cap_options l2o;
struct avctp *session;
GIOCondition flags = G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+ struct audio_device *dev;
char address[18];
if (err < 0) {
@@ -685,6 +686,15 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
goto drop;
}
+ dev = manager_get_device(src, dst, NULL);
+ if (!dev) {
+ error("Unable to get audio device object for %s", address);
+ goto drop;
+ }
+
+ if (!dev->control)
+ dev->control = control_init(dev);
+
session->state = AVCTP_STATE_CONNECTING;
session->sock = g_io_channel_unix_get_fd(chan);
@@ -694,7 +704,6 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
err = errno;
error("getsockopt(L2CAP_OPTIONS): %s (%d)", strerror(err),
err);
- avctp_unref(session);
goto drop;
}
@@ -721,7 +730,8 @@ proceed:
return;
drop:
- close(session->sock);
+ g_io_channel_close(chan);
+ avctp_unref(session);
}
static GIOChannel *avctp_server_socket(const bdaddr_t *src, gboolean master)