summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-08-15 22:57:49 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-08-15 22:57:49 +0000
commit1addff77624b54445c9b81779ddc78892a126a45 (patch)
tree322d0e61617a95fe908097c57e0b5ea0b834bfc2 /audio
parent7502ca3e7eb95a7b349b5b9235ed50d542949f59 (diff)
call avdtp_start from open_cfm instead of state callback
Diffstat (limited to 'audio')
-rw-r--r--audio/a2dp.c23
-rw-r--r--audio/a2dp.h3
-rw-r--r--audio/sink.c14
3 files changed, 31 insertions, 9 deletions
diff --git a/audio/a2dp.c b/audio/a2dp.c
index 7574dbbb..b8431bc6 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -50,6 +50,9 @@ static uint32_t source_record_id = 0;
static struct avdtp_local_sep *sink_sep = NULL;
static struct avdtp_local_sep *source_sep = NULL;
+static struct avdtp *start_session = NULL;
+static struct avdtp_stream *start_stream = NULL;
+
static gboolean setconf_ind(struct avdtp *session,
struct avdtp_local_sep *sep,
struct avdtp_stream *stream,
@@ -175,10 +178,22 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
static void open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
struct avdtp_stream *stream)
{
+ int err;
+
if (sep == sink_sep)
debug("SBC Sink: Open_Cfm");
else
debug("SBC Source: Open_Cfm");
+
+ if (session != start_session || stream != start_stream)
+ return;
+
+ start_session = NULL;
+ start_stream = NULL;
+
+ err = avdtp_start(session, stream);
+ if (err < 0)
+ error("Error on avdtp_start %s (%d)", strerror(-err), err);
}
static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,
@@ -669,3 +684,11 @@ gboolean a2dp_get_config(struct avdtp_stream *stream,
return TRUE;
}
+
+void a2dp_start_stream_when_opened(struct avdtp *session,
+ struct avdtp_stream *stream)
+{
+ start_session = session;
+ start_stream = stream;
+
+}
diff --git a/audio/a2dp.h b/audio/a2dp.h
index b2653594..23416988 100644
--- a/audio/a2dp.h
+++ b/audio/a2dp.h
@@ -66,3 +66,6 @@ gboolean a2dp_select_capabilities(struct avdtp_remote_sep *rsep, GSList **caps);
gboolean a2dp_get_config(struct avdtp_stream *stream,
struct ipc_data_cfg **cfg, int *fd);
+
+void a2dp_start_stream_when_opened(struct avdtp *session,
+ struct avdtp_stream *stream);
diff --git a/audio/sink.c b/audio/sink.c
index 50d45718..fe8b6393 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -107,6 +107,9 @@ void stream_state_changed(struct avdtp_stream *stream, avdtp_state_t old_state,
cmd_err);
goto failed;
}
+
+ if (sink->c && sink->c->pkt)
+ a2dp_start_stream_when_opened(sink->session, stream);
break;
case AVDTP_STATE_OPEN:
sink->suspending = FALSE;
@@ -120,16 +123,9 @@ void stream_state_changed(struct avdtp_stream *stream, avdtp_state_t old_state,
if (!sink->initiator)
break;
- if (sink->c && sink->c->pkt) {
- cmd_err = avdtp_start(sink->session, stream);
- if (cmd_err < 0) {
- error("Error on avdtp_start %s (%d)",
- strerror(-cmd_err), cmd_err);
- goto failed;
- }
- }
- else
+ if (!(sink->c && sink->c->pkt))
c = sink->c;
+
break;
case AVDTP_STATE_STREAMING:
c = sink->c;