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
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;
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) {
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;
}
#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,
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) {