From 730a4ceb9e7e986e2a327fa7e023c3dd2102a50d Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 20 Aug 2007 08:50:22 +0000 Subject: Improve handling of simultaneous connect attempts to different devices --- audio/unix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'audio/unix.c') diff --git a/audio/unix.c b/audio/unix.c index f8832c91..9bf1a9ca 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -198,6 +198,11 @@ static void a2dp_setup_complete(struct avdtp *session, struct device *dev, if (!stream) goto failed; + if (!a2dp_source_lock(dev, session)) { + error("Unable to lock A2DP source SEP"); + goto failed; + } + a2dp->stream = stream; if (!avdtp_stream_get_transport(stream, &fd, &cfg->pkt_len, &caps)) { @@ -273,8 +278,9 @@ static void a2dp_setup_complete(struct avdtp *session, struct device *dev, failed: error("stream setup failed"); + if (a2dp->stream) + a2dp_source_unlock(dev, session); unix_send_cfg(client->sock, NULL, -1); - a2dp_source_unlock(dev, session); avdtp_unref(a2dp->session); a2dp->session = NULL; a2dp->stream = NULL; @@ -307,17 +313,11 @@ proceed: if (!a2dp->session) a2dp->session = avdtp_get(&dev->src, &dev->dst); - if (!a2dp_source_lock(dev, a2dp->session)) { - error("Unable to lock A2DP source SEP"); - goto failed; - } - id = a2dp_source_request_stream(a2dp->session, dev, TRUE, a2dp_setup_complete, client); if (id == 0) { error("request_stream failed"); - a2dp_source_unlock(dev, a2dp->session); goto failed; } -- cgit