Merge "pal: move sco out device to the beginning of device disconnect list"
diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp
index 0e4444c..eac4624 100644
--- a/resource_manager/src/ResourceManager.cpp
+++ b/resource_manager/src/ResourceManager.cpp
@@ -9205,7 +9205,8 @@
(sAttr.type == PAL_STREAM_PCM_OFFLOAD) ||
(sAttr.type == PAL_STREAM_SPATIAL_AUDIO) ||
(sAttr.type == PAL_STREAM_DEEP_BUFFER) ||
- (sAttr.type == PAL_STREAM_COMPRESSED))) {
+ (sAttr.type == PAL_STREAM_COMPRESSED) ||
+ (sAttr.type == PAL_STREAM_GENERIC))) {
str->getAssociatedDevices(associatedDevices);
for (int i = 0; i < associatedDevices.size(); i++) {
if (!isDeviceActive_l(associatedDevices[i], str) ||
@@ -9256,6 +9257,22 @@
SortAndUnique(rxDevices);
SortAndUnique(txDevices);
+
+ /*
+ * If there a switch in SCO configurations and at the time of BT_SCO=on,
+ * there are streams active with old SCO configs as well as on another
+ * device. In this case, we need to disconnect streams over SCO first and
+ * move them to new SCO configs, before we move streams on other devices
+ * to SCO. This is ensured by moving SCO to the beginning of the disconnect
+ * device list.
+ */
+ {
+ dAttr.id = PAL_DEVICE_OUT_BLUETOOTH_SCO;
+ dev = Device::getInstance(&dAttr, rm);
+ auto it = std::find(rxDevices.begin(),rxDevices.end(),dev);
+ if ((it != rxDevices.end()) && (it != rxDevices.begin()))
+ std::iter_swap(it, rxDevices.begin());
+ }
mActiveStreamMutex.unlock();
for (auto& device : rxDevices) {
@@ -9452,7 +9469,8 @@
(streamType == PAL_STREAM_PCM_OFFLOAD) ||
(streamType == PAL_STREAM_DEEP_BUFFER) ||
(streamType == PAL_STREAM_SPATIAL_AUDIO) ||
- (streamType == PAL_STREAM_COMPRESSED)) {
+ (streamType == PAL_STREAM_COMPRESSED) ||
+ (streamType == PAL_STREAM_GENERIC)) {
(*sIter)->suspendedDevIds.clear();
(*sIter)->suspendedDevIds.push_back(a2dp_dattr.id);
PAL_DBG(LOG_TAG, "a2dp resumed, mark sco streams as to route them later");