pal: skip UPD device switch if handset BE differs from speaker
During voice call device switch between handset and speaker, if
UPD doesn't share BE with speaker device, then UPD shouldn't be
switched to speaker.
Add check of handset and speaker BE to decide if UPD needs to
switch device.
Change-Id: Idc31f3f3f02f340936c5a299ac62eaa54104aa1f
diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp
index 470ce0a..5cc45d5 100644
--- a/resource_manager/src/ResourceManager.cpp
+++ b/resource_manager/src/ResourceManager.cpp
@@ -7172,6 +7172,15 @@
case PAL_DEVICE_OUT_HANDSET:
case PAL_DEVICE_OUT_SPEAKER:
ret = true;
+ /*
+ * if upd shares BE with handset, while handset doesn't
+ * share BE with speaker, then during device switch
+ * between handset and speaker, upd should still stay
+ * on handset
+ */
+ if (listAllBackEndIds[PAL_DEVICE_OUT_HANDSET].second !=
+ listAllBackEndIds[PAL_DEVICE_OUT_SPEAKER].second)
+ ret = false;
break;
default:
ret = false;
@@ -7292,6 +7301,8 @@
{
int ret = 0;
static struct pal_device dAttr; //struct reference is passed in StreamDevConnect.
+ struct pal_device curDevAttr = {};
+ std::shared_ptr<Device> hs_dev = nullptr;
uint32_t devId;
Stream *s;
struct pal_stream_attributes sAttr;
@@ -7349,6 +7360,15 @@
goto exit_on_error;
}
+ hs_dev = Device::getObject(PAL_DEVICE_OUT_HANDSET);
+ if (hs_dev)
+ hs_dev->getDeviceAttributes(&curDevAttr);
+
+ if (!doDevAttrDiffer(&dAttr, &curDevAttr)) {
+ PAL_DBG(LOG_TAG, "No need to update device attr for UPD");
+ return ret;
+ }
+
/*
* We restore the device configuration appropriately if UPD is the only stream
* skipping the switch to the new device and will be the only active stream