[PATCHv1 12/47] android/hal-sco: Use bdaddr parameter in Get SCO fd command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

---
 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 b6d95a1..1daeaac 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) {
@@ -654,9 +657,6 @@ static int sco_open_output_stream(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;
@@ -688,6 +688,9 @@ static int sco_open_output_stream(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,
@@ -1047,7 +1050,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

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux