From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC BlueZ 1/2] A2DP: Mark start flag if resume happen while in configured state
Date: Tue, 19 Feb 2013 16:33:55 +0200 [thread overview]
Message-ID: <1361284436-4584-1-git-send-email-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If SEP is in configured state that means OPEN is about to happen so just
mark start flag and send START once OPEN completes.
---
profiles/audio/a2dp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index f1646ee..d9680a7 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -336,6 +336,20 @@ static struct a2dp_setup *find_setup_by_dev(struct audio_device *dev)
return NULL;
}
+static struct a2dp_setup *find_setup_by_stream(struct avdtp_stream *stream)
+{
+ GSList *l;
+
+ for (l = setups; l != NULL; l = l->next) {
+ struct a2dp_setup *setup = l->data;
+
+ if (setup->stream == stream)
+ return setup;
+ }
+
+ return NULL;
+}
+
static void stream_state_changed(struct avdtp_stream *stream,
avdtp_state_t old_state,
avdtp_state_t new_state,
@@ -344,6 +358,29 @@ static void stream_state_changed(struct avdtp_stream *stream,
{
struct a2dp_sep *sep = user_data;
+ if (new_state == AVDTP_STATE_OPEN) {
+ struct a2dp_setup *setup;
+ int err;
+
+ setup = find_setup_by_stream(stream);
+ if (!setup || !setup->start)
+ return;
+
+ setup->start = FALSE;
+
+ err = avdtp_start(setup->session, stream);
+ if (err < 0 && err != -EINPROGRESS) {
+ error("avdtp_start: %s (%d)", strerror(-err), -err);
+ finalize_setup_errno(setup, err, finalize_resume,
+ NULL);
+ return;
+ }
+
+ sep->starting = TRUE;
+
+ return;
+ }
+
if (new_state != AVDTP_STATE_IDLE)
return;
@@ -661,6 +698,12 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
finalize_config(setup);
+ if (!setup->start || !err)
+ return TRUE;
+
+ setup->start = FALSE;
+ finalize_resume(setup);
+
return TRUE;
}
@@ -689,6 +732,14 @@ static void open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
}
finalize_config(setup);
+
+ if (!setup->start || !err)
+ return;
+
+ setup->start = FALSE;
+ finalize_resume(setup);
+
+ return;
}
static gboolean suspend_timeout(struct a2dp_sep *sep)
@@ -1718,6 +1769,9 @@ unsigned int a2dp_resume(struct avdtp *session, struct a2dp_sep *sep,
case AVDTP_STATE_IDLE:
goto failed;
break;
+ case AVDTP_STATE_CONFIGURED:
+ setup->start = TRUE;
+ break;
case AVDTP_STATE_OPEN:
if (avdtp_start(session, sep->stream) < 0) {
error("avdtp_start failed");
--
1.8.1.2
next reply other threads:[~2013-02-19 14:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 14:33 Luiz Augusto von Dentz [this message]
2013-02-19 14:33 ` [RFC BlueZ 2/2] AVDTP: Fix passing uninitialized err to ind->open Luiz Augusto von Dentz
2013-02-19 15:06 ` [RFC BlueZ 1/2] A2DP: Mark start flag if resume happen while in configured state Mikel Astiz
2013-02-19 15:30 ` Luiz Augusto von Dentz
2013-02-20 13:37 ` Mikel Astiz
2013-02-22 12:00 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361284436-4584-1-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox