summaryrefslogtreecommitdiffstats
path: root/audio/a2dp.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-08-20 08:50:22 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-08-20 08:50:22 +0000
commit730a4ceb9e7e986e2a327fa7e023c3dd2102a50d (patch)
treea19fc7a8d901abd7b8429673fec69d1d37dd7d56 /audio/a2dp.c
parent78a94059160d7478624cad315022255f7ebbbe80 (diff)
Improve handling of simultaneous connect attempts to different devices
Diffstat (limited to 'audio/a2dp.c')
-rw-r--r--audio/a2dp.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/audio/a2dp.c b/audio/a2dp.c
index ebf6b472..0e5f1473 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -884,6 +884,17 @@ unsigned int a2dp_source_request_stream(struct avdtp *session,
struct a2dp_stream_cb *cb_data;
static unsigned int cb_id = 0;
+ if (source.used_by != NULL && source.used_by != dev) {
+ error("a2dp_source_request_stream: SEP is locked");
+ return 0;
+ }
+
+ if (setup && setup->dev != dev) {
+ error("a2dp_source_request_stream: stream setup in progress "
+ "already for another device");
+ return 0;
+ }
+
cb_data = g_new(struct a2dp_stream_cb, 1);
cb_data->cb = cb;
cb_data->user_data = user_data;
@@ -906,8 +917,10 @@ unsigned int a2dp_source_request_stream(struct avdtp *session,
switch (avdtp_sep_get_state(source.sep)) {
case AVDTP_STATE_IDLE:
- if (avdtp_discover(session, discovery_complete, setup) < 0)
+ if (avdtp_discover(session, discovery_complete, setup) < 0) {
+ error("avdtp_discover failed");
goto failed;
+ }
break;
case AVDTP_STATE_OPEN:
if (!start) {
@@ -916,8 +929,10 @@ unsigned int a2dp_source_request_stream(struct avdtp *session,
}
if (source.starting)
break;
- if (avdtp_start(session, source.stream) < 0)
+ if (avdtp_start(session, source.stream) < 0) {
+ error("avdtp_start failed");
goto failed;
+ }
break;
case AVDTP_STATE_STREAMING:
if (!start || !source.suspending) {
@@ -931,6 +946,7 @@ unsigned int a2dp_source_request_stream(struct avdtp *session,
source.start_requested = TRUE;
break;
default:
+ error("SEP in bad state for requesting a new stream");
goto failed;
}
@@ -947,6 +963,8 @@ gboolean a2dp_source_lock(struct device *dev, struct avdtp *session)
if (source.used_by)
return FALSE;
+ debug("SBC Source locked");
+
source.used_by = dev;
return TRUE;
@@ -966,6 +984,8 @@ gboolean a2dp_source_unlock(struct device *dev, struct avdtp *session)
source.used_by = NULL;
+ debug("SBC Source unlocked");
+
if (!source.stream || state == AVDTP_STATE_IDLE)
return TRUE;