From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 7/7] android/hal-sco: Use bdaddr parameter in Get SCO fd command
Date: Wed, 5 Nov 2014 10:41:22 +0200 [thread overview]
Message-ID: <1415176882-12397-7-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <1415176882-12397-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-sco.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/android/hal-sco.c b/android/hal-sco.c
index 442e2d0..6c4e975 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -281,20 +281,23 @@ failed:
return SCO_STATUS_FAILED;
}
-static int ipc_get_sco_fd(void)
+static int ipc_get_sco_fd(bt_bdaddr_t *bd_addr)
{
int ret = SCO_STATUS_SUCCESS;
pthread_mutex_lock(&sco_mutex);
if (sco_fd < 0) {
+ struct sco_cmd_get_fd cmd;
struct sco_rsp_get_fd rsp;
size_t rsp_len = sizeof(rsp);
DBG("Getting SCO fd");
- ret = sco_ipc_cmd(SCO_SERVICE_ID, SCO_OP_GET_FD, 0, NULL,
- &rsp_len, &rsp, &sco_fd);
+ memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
+
+ ret = sco_ipc_cmd(SCO_SERVICE_ID, SCO_OP_GET_FD, sizeof(cmd),
+ &cmd, &rsp_len, &rsp, &sco_fd);
/* Sometimes mtu returned is wrong */
sco_mtu = /* rsp.mtu */ 48;
@@ -453,7 +456,7 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
DBG("write to fd %d bytes %zu", sco_fd, bytes);
- if (ipc_get_sco_fd() != SCO_STATUS_SUCCESS)
+ if (ipc_get_sco_fd(&out->bd_addr) != SCO_STATUS_SUCCESS)
return -1;
if (!out->downmix_buf) {
@@ -645,9 +648,6 @@ static int sco_open_output_stream_real(struct audio_hw_device *dev,
return -EIO;
}
- if (ipc_get_sco_fd() != SCO_STATUS_SUCCESS)
- DBG("SCO is not connected yet; get fd on write()");
-
out = calloc(1, sizeof(struct sco_stream_out));
if (!out)
return -ENOMEM;
@@ -679,6 +679,9 @@ static int sco_open_output_stream_real(struct audio_hw_device *dev,
}
#endif
+ if (ipc_get_sco_fd(&out->bd_addr) != SCO_STATUS_SUCCESS)
+ DBG("SCO is not connected yet; get fd on write()");
+
if (config) {
DBG("config: rate %u chan mask %x format %d offload %p",
config->sample_rate, config->channel_mask,
@@ -1063,7 +1066,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
DBG("Read from fd %d bytes %zu", sco_fd, bytes);
- if (ipc_get_sco_fd() != SCO_STATUS_SUCCESS)
+ if (ipc_get_sco_fd(&in->bd_addr) != SCO_STATUS_SUCCESS)
return -1;
if (!in->resampler && in->cfg.rate != AUDIO_STREAM_SCO_RATE) {
--
1.9.1
next prev parent reply other threads:[~2014-11-05 8:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 8:41 [PATCH 1/7] android/hal-sco: Add support for new Android API Andrei Emeltchenko
2014-11-05 8:41 ` [PATCH 2/7] android/hal-sco: Remove deprecated API usage Andrei Emeltchenko
2014-11-05 8:41 ` [PATCH 3/7] android/hal-sco: Implement dummy SCO HAL functions Andrei Emeltchenko
2014-11-05 8:41 ` [PATCH 4/7] android/hal-sco: Save bd_addr for output stream of Audio SCO HAL Andrei Emeltchenko
2014-11-05 8:41 ` [PATCH 5/7] android/hal-sco: Save bd_addr for input " Andrei Emeltchenko
2014-11-05 8:41 ` [PATCH 6/7] android/hal-sco: Add remote address parameter in Get SCO fd command Andrei Emeltchenko
2014-11-05 8:41 ` Andrei Emeltchenko [this message]
2014-11-05 11:26 ` [PATCH 1/7] android/hal-sco: Add support for new Android API Szymon Janc
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=1415176882-12397-7-git-send-email-Andrei.Emeltchenko.news@gmail.com \
--to=andrei.emeltchenko.news@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