summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-08 15:14:58 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-10-08 15:14:58 +0200
commit0e106ae46ab6a835ebe187097f2f97c7789d4d34 (patch)
treeca1b7c3e5058268a92050306095b8468b8ad9750 /audio
parent3161f96838b8f79574ee93b0525942d7c732535e (diff)
Move dev->sink initialization as acceptor to correct place
We can't initialize dev->sink in the AVDTP server callback since at this point we don't know if the remote device will be acting in audio source or audio sink role. So, do the initialization when we get the SetConfiguration command since then we can check the type of the SEP that was selected.
Diffstat (limited to 'audio')
-rw-r--r--audio/avdtp.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/audio/avdtp.c b/audio/avdtp.c
index 63b9bdc4..98cbbab4 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -1041,6 +1041,8 @@ static gboolean avdtp_setconf_cmd(struct avdtp *session,
struct avdtp_local_sep *sep;
struct avdtp_stream *stream;
uint8_t err, category = 0x00;
+ struct audio_device *dev;
+ bdaddr_t src, dst;
if (size < sizeof(struct setconf_req)) {
error("Too short getcap request");
@@ -1058,6 +1060,23 @@ static gboolean avdtp_setconf_cmd(struct avdtp *session,
goto failed;
}
+ avdtp_get_peers(session, &src, &dst);
+ dev = manager_get_device(&src, &dst, NULL);
+ if (!dev) {
+ error("Unable to get a audio device object");
+ goto failed;
+ }
+
+ switch (sep->info.type) {
+ case AVDTP_SEP_TYPE_SOURCE:
+ if (!dev->sink)
+ dev->sink = sink_init(dev);
+ break;
+ case AVDTP_SEP_TYPE_SINK:
+ /* Do source_init() here when it's implemented */
+ break;
+ }
+
stream = g_new0(struct avdtp_stream, 1);
stream->session = session;
stream->lsep = sep;
@@ -2788,9 +2807,6 @@ static void avdtp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
goto drop;
}
- if (!dev->sink)
- dev->sink = sink_init(dev);
-
session->mtu = l2o.imtu;
session->sock = sk;