[RFCV2 02/28] android/handsfree: Connect SCO audio on demand

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

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

---
 android/handsfree.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/android/handsfree.c b/android/handsfree.c
index b530aa9..49e6a22 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -169,6 +169,8 @@ static GIOChannel *hsp_server = NULL;
 
 static GIOChannel *sco_server = NULL;
 
+static void bt_sco_connect(const void *buf, uint16_t len);
+
 static void device_set_state(uint8_t state)
 {
 	struct hal_ev_handsfree_conn_state ev;
@@ -892,6 +894,9 @@ static void connect_sco_cb(GIOChannel *chan, GError *err, gpointer user_data)
 							sco_watch_cb, NULL);
 
 	device_set_audio_state(HAL_EV_HANDSFREE_AUDIO_STATE_CONNECTED);
+
+	if (ipc_is_connected(sco_ipc))
+		bt_sco_connect(NULL, 0);
 }
 
 static bool connect_sco(void)
@@ -2577,8 +2582,12 @@ static void bt_sco_connect(const void *buf, uint16_t len)
 
 	DBG("");
 
-	if (!device.sco)
-		goto failed;
+	if (!device.sco) {
+		DBG("SCO is not established, connecting...");
+		if (!connect_audio())
+			goto failed;
+		return;
+	}
 
 	err = NULL;
 	if (!bt_io_get(device.sco, &err, BT_IO_OPT_MTU, &rsp.mtu,
-- 
1.8.3.2

--
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