From: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
To: linux-bluetooth@vger.kernel.org
Cc: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Subject: [PATCH 2/3] android/handsfree: Send phone state to all connected devices
Date: Thu, 13 Nov 2014 16:52:51 +0100 [thread overview]
Message-ID: <1415893972-18656-3-git-send-email-lukasz.rymanowski@tieto.com> (raw)
In-Reply-To: <1415893972-18656-1-git-send-email-lukasz.rymanowski@tieto.com>
---
android/handsfree.c | 51 +++++++++++++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/android/handsfree.c b/android/handsfree.c
index 0001eb6..9bb8f43 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -2485,27 +2485,10 @@ static void phone_state_idle(struct hf_device *dev, int num_active,
}
}
-static void handle_phone_state_change(const void *buf, uint16_t len)
+static void phone_state_change(void *data, void *user_data)
{
- const struct hal_cmd_handsfree_phone_state_change *cmd = buf;
- struct hf_device *dev;
- uint8_t status;
-
- if (len != sizeof(*cmd) + cmd->number_len || (cmd->number_len != 0 &&
- cmd->number[cmd->number_len - 1] != '\0')) {
- error("Invalid phone state change command, terminating");
- raise(SIGTERM);
- return;
- }
-
- DBG("active=%u hold=%u state=%u", cmd->num_active, cmd->num_held,
- cmd->state);
-
- dev = find_default_device();
- if (!dev) {
- status = HAL_STATUS_FAILED;
- goto failed;
- }
+ struct hf_device *dev = data;
+ struct hal_cmd_handsfree_phone_state_change *cmd = user_data;
switch (cmd->state) {
case HAL_HANDSFREE_CALL_STATE_DIALING:
@@ -2526,14 +2509,38 @@ static void handle_phone_state_change(const void *buf, uint16_t len)
DBG("unhandled new state %u (current state %u)", cmd->state,
dev->setup_state);
- status = HAL_STATUS_FAILED;
- goto failed;
+ return;
}
dev->num_active = cmd->num_active;
dev->num_held = cmd->num_held;
dev->setup_state = cmd->state;
+}
+
+static void handle_phone_state_change(const void *buf, uint16_t len)
+{
+ const struct hal_cmd_handsfree_phone_state_change *cmd = buf;
+ uint8_t status;
+
+ if (len != sizeof(*cmd) + cmd->number_len || (cmd->number_len != 0 &&
+ cmd->number[cmd->number_len - 1] != '\0')) {
+ error("Invalid phone state change command, terminating");
+ raise(SIGTERM);
+ return;
+ }
+
+ DBG("active=%u hold=%u state=%u", cmd->num_active, cmd->num_held,
+ cmd->state);
+
+ if (queue_isempty(devices)) {
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
+ /* Cast cmd to void as queue api needs that */
+ queue_foreach(devices, phone_state_change, (void *) cmd);
+
status = HAL_STATUS_SUCCESS;
failed:
--
1.8.4
next prev parent reply other threads:[~2014-11-13 15:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 15:52 [PATCH 0/3] android/handsfree: Support multiply devices Lukasz Rymanowski
2014-11-13 15:52 ` [PATCH 1/3] android/handsfree: Send indicator notif to all connected devices Lukasz Rymanowski
2014-11-13 17:14 ` Szymon Janc
2014-11-13 17:24 ` Szymon Janc
2014-11-13 15:52 ` Lukasz Rymanowski [this message]
2014-11-13 15:52 ` [PATCH 3/3] android/handsfree: Remove find default device Lukasz Rymanowski
2014-11-13 15:58 ` Lukasz Rymanowski
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=1415893972-18656-3-git-send-email-lukasz.rymanowski@tieto.com \
--to=lukasz.rymanowski@tieto.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