Merge "pal: handling for SCO when DEVICE_NONE routing comes while dev is disconnected"
diff --git a/stream/src/Stream.cpp b/stream/src/Stream.cpp
index 17f8314..c252a35 100644
--- a/stream/src/Stream.cpp
+++ b/stream/src/Stream.cpp
@@ -1383,6 +1383,7 @@
int32_t connectCount = 0, disconnectCount = 0;
bool isNewDeviceA2dp = false;
bool isCurDeviceA2dp = false;
+ bool isCurDeviceSco = false;
bool isCurrentDeviceProxyOut = false;
bool isCurrentDeviceDpOut = false;
bool matchFound = false;
@@ -1435,6 +1436,11 @@
curBtDevId = curDevId;
}
+ if (curDevId == PAL_DEVICE_OUT_BLUETOOTH_SCO) {
+ isCurDeviceSco = true;
+ curBtDevId = curDevId;
+ }
+
if (curDevId == PAL_DEVICE_OUT_PROXY)
isCurrentDeviceProxyOut = true;
@@ -1507,11 +1513,19 @@
* But the audioflinger continues to write data until standby time
* (3sec). As BT is turned off, the write gets blocked.
* Avoid this by routing audio to speaker until standby.
+ *
+ * If a stream is active on SCO and playback has ended, APM will send
+ * routing=0. Stream will be closed in PAL after standby time. If SCO
+ * device gets disconnected, this stream will not receive new routing
+ * and stream will remain with SCO for the time being. If SCO device
+ * gets connected again with different config in the meantime and
+ * capture stream tries to start ABR path, it will lead to error due to
+ * config mismatch. Added OUT_SCO device handling to resolve this.
*/
// This assumes that PAL_DEVICE_NONE comes as single device
if ((newDevices[i].id == PAL_DEVICE_NONE) &&
- (((isCurDeviceA2dp == true) && (!rm->isDeviceReady(curBtDevId))) ||
- (isCurrentDeviceProxyOut) || (isCurrentDeviceDpOut))) {
+ ((isCurrentDeviceProxyOut) || (isCurrentDeviceDpOut) ||
+ ((isCurDeviceA2dp || isCurDeviceSco) && (!rm->isDeviceReady(curBtDevId))))) {
newDevices[i].id = PAL_DEVICE_OUT_SPEAKER;
if (rm->getDeviceConfig(&newDevices[i], mStreamAttr)) {