From 1b7a35a18e800e83c475711e31d75b3c7d399598 Mon Sep 17 00:00:00 2001
From: Shiv Maliyappanahalli <smaliyap@codeaurora.org>
Date: Wed, 30 Jun 2021 14:32:13 -0700
Subject: [PATCH] pal: update the backendlist to include external ecref

Update the backendlist to include external ecref as
external ec ref has its own backend. This will ensure
that when parsing the devices, the list is big enough
to accomodate all PAL defined devices.

Change-Id: Id4862721036042e5d83f449a7cdaed9df1c3f4fb
---
 resource_manager/src/ResourceManager.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp
index b255cec2..b7d299af 100644
--- a/resource_manager/src/ResourceManager.cpp
+++ b/resource_manager/src/ResourceManager.cpp
@@ -187,6 +187,8 @@ std::vector<std::pair<int32_t, std::string>> ResourceManager::deviceLinkName {
     {PAL_DEVICE_IN_HANDSET_VA_MIC,        {std::string{ "" }}},
     {PAL_DEVICE_IN_BLUETOOTH_A2DP,        {std::string{ "" }}},
     {PAL_DEVICE_IN_HEADSET_VA_MIC,        {std::string{ "" }}},
+    {PAL_DEVICE_IN_EXT_EC_REF,            {std::string{ "none" }}},
+    {PAL_DEVICE_IN_MAX,                   {std::string{ "" }}},
 };
 
 std::vector<std::pair<int32_t, int32_t>> ResourceManager::devicePcmId {
@@ -226,6 +228,8 @@ std::vector<std::pair<int32_t, int32_t>> ResourceManager::devicePcmId {
     {PAL_DEVICE_IN_HANDSET_VA_MIC,        0},
     {PAL_DEVICE_IN_BLUETOOTH_A2DP,        0},
     {PAL_DEVICE_IN_HEADSET_VA_MIC,        0},
+    {PAL_DEVICE_IN_EXT_EC_REF,            0},
+    {PAL_DEVICE_IN_MAX,                   0},
 };
 
 // To be defined in detail
@@ -266,7 +270,9 @@ std::vector<std::pair<int32_t, std::string>> ResourceManager::sndDeviceNameLUT {
     {PAL_DEVICE_IN_HANDSET_VA_MIC,        {std::string{ "" }}},
     {PAL_DEVICE_IN_BLUETOOTH_A2DP,        {std::string{ "" }}},
     {PAL_DEVICE_IN_HEADSET_VA_MIC,        {std::string{ "" }}},
-    {PAL_DEVICE_IN_VI_FEEDBACK,           {std::string{ "" }}}
+    {PAL_DEVICE_IN_VI_FEEDBACK,           {std::string{ "" }}},
+    {PAL_DEVICE_IN_EXT_EC_REF,            {std::string{ "none" }}},
+    {PAL_DEVICE_IN_MAX,                   {std::string{ "" }}},
 };
 
 const std::map<std::string, uint32_t> usecaseIdLUT {
@@ -448,6 +454,8 @@ std::vector<std::pair<int32_t, std::string>> ResourceManager::listAllBackEndIds
     {PAL_DEVICE_IN_BLUETOOTH_A2DP,        {std::string{ "" }}},
     {PAL_DEVICE_IN_HEADSET_VA_MIC,        {std::string{ "none" }}},
     {PAL_DEVICE_IN_VI_FEEDBACK,           {std::string{ "" }}},
+    {PAL_DEVICE_IN_EXT_EC_REF,            {std::string{ "none" }}},
+    {PAL_DEVICE_IN_MAX,                   {std::string{ "" }}},
 };
 
 void agmServiceCrashHandler(uint64_t cookie __unused)
@@ -4782,7 +4790,7 @@ void ResourceManager::updateSndName(int32_t deviceId, std::string sndName)
 
 void ResourceManager::updateBackEndName(int32_t deviceId, std::string backEndName)
 {
-    if (isValidDevId(deviceId)) {
+    if (isValidDevId(deviceId) && deviceId < listAllBackEndIds.size()) {
         listAllBackEndIds[deviceId].second = backEndName;
     } else {
         PAL_ERR(LOG_TAG, "Invalid device id %d", deviceId);
-- 
GitLab