Merge "pal: Protect session open with graph lock"
diff --git a/device/src/Bluetooth.cpp b/device/src/Bluetooth.cpp
index cb67a90..f002ef4 100644
--- a/device/src/Bluetooth.cpp
+++ b/device/src/Bluetooth.cpp
@@ -1227,6 +1227,7 @@
if ((fbDev->deviceStartStopCount > 0) &&
(--fbDev->deviceStartStopCount == 0)) {
fbDev->isConfigured = false;
+ fbDev->isAbrEnabled = false;
}
if (fbDev->deviceCount > 0)
fbDev->deviceCount--;
@@ -1241,6 +1242,7 @@
if ((fbDev->deviceStartStopCount > 0) &&
(--fbDev->deviceStartStopCount == 0)) {
fbDev->isConfigured = false;
+ fbDev->isAbrEnabled = false;
}
if (fbDev->deviceCount > 0)
fbDev->deviceCount--;
diff --git a/resource_manager/inc/ResourceManager.h b/resource_manager/inc/ResourceManager.h
index 77b75ae..a16e844 100644
--- a/resource_manager/inc/ResourceManager.h
+++ b/resource_manager/inc/ResourceManager.h
@@ -944,6 +944,8 @@
void unlockGraph() { mGraphMutex.unlock(); };
void lockActiveStream() { mActiveStreamMutex.lock(); };
void unlockActiveStream() { mActiveStreamMutex.unlock(); };
+ void lockResourceManagerMutex() {mResourceManagerMutex.lock();};
+ void unlockResourceManagerMutex() {mResourceManagerMutex.unlock();};
void getSharedBEActiveStreamDevs(std::vector <std::tuple<Stream *, uint32_t>> &activeStreamDevs,
int dev_id);
bool compareSharedBEStreamDevAttr(std::vector <std::tuple<Stream *, uint32_t>> &sharedBEStreamDev,
diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp
index 8f65183..133e387 100644
--- a/resource_manager/src/ResourceManager.cpp
+++ b/resource_manager/src/ResourceManager.cpp
@@ -1405,8 +1405,9 @@
bool snd_card_found = false;
char *snd_card_name = NULL;
-
+ FILE *file = NULL;
char mixer_xml_file[XML_PATH_MAX_LENGTH] = {0};
+ char mixer_xml_file_wo_variant[XML_PATH_MAX_LENGTH] = {0};
char file_name_extn[XML_PATH_EXTN_MAX_SIZE] = {0};
char file_name_extn_wo_variant[XML_PATH_EXTN_MAX_SIZE] = {0};
@@ -1489,7 +1490,9 @@
"%s/%s", vendor_config_path, RMNGR_XMLFILE_BASE_STRING_NAME);
strlcat(mixer_xml_file, XML_FILE_DELIMITER, XML_PATH_MAX_LENGTH);
+ strlcat(mixer_xml_file_wo_variant, mixer_xml_file, XML_PATH_MAX_LENGTH);
strlcat(mixer_xml_file, file_name_extn, XML_PATH_MAX_LENGTH);
+ strlcat(mixer_xml_file_wo_variant, file_name_extn_wo_variant, XML_PATH_MAX_LENGTH);
strlcat(rmngr_xml_file, XML_FILE_DELIMITER, XML_PATH_MAX_LENGTH);
strlcpy(rmngr_xml_file_wo_variant, rmngr_xml_file, XML_PATH_MAX_LENGTH);
strlcat(rmngr_xml_file, file_name_extn, XML_PATH_MAX_LENGTH);
@@ -1498,14 +1501,20 @@
strlcat(mixer_xml_file, XML_FILE_EXT, XML_PATH_MAX_LENGTH);
strlcat(rmngr_xml_file, XML_FILE_EXT, XML_PATH_MAX_LENGTH);
strlcat(rmngr_xml_file_wo_variant, XML_FILE_EXT, XML_PATH_MAX_LENGTH);
+ strlcat(mixer_xml_file_wo_variant, XML_FILE_EXT, XML_PATH_MAX_LENGTH);
audio_route = audio_route_init(snd_hw_card, mixer_xml_file);
PAL_INFO(LOG_TAG, "audio route %pK, mixer path %s", audio_route, mixer_xml_file);
if (!audio_route) {
- PAL_ERR(LOG_TAG, "audio route init failed");
- mixer_close(audio_virt_mixer);
- mixer_close(audio_hw_mixer);
- status = -EINVAL;
+ PAL_ERR(LOG_TAG, "audio route init failed trying with mixer without variant name");
+ audio_route = audio_route_init(snd_hw_card, mixer_xml_file_wo_variant);
+ PAL_INFO(LOG_TAG, "audio route %pK, mixer path %s", audio_route, mixer_xml_file_wo_variant);
+ if (!audio_route) {
+ PAL_ERR(LOG_TAG, "audio route init failed ");
+ mixer_close(audio_virt_mixer);
+ mixer_close(audio_hw_mixer);
+ status = -EINVAL;
+ }
}
// audio_route init success
exit:
@@ -9048,8 +9057,10 @@
param_bt_a2dp.dev_id = PAL_DEVICE_OUT_BLUETOOTH_A2DP;
param_bt_a2dp.a2dp_suspended = true;
PAL_DBG(LOG_TAG, "Applying cached a2dp_suspended true param");
+ mResourceManagerMutex.unlock();
status = dev->setDeviceParameter(PAL_PARAM_ID_BT_A2DP_SUSPENDED,
¶m_bt_a2dp);
+ mResourceManagerMutex.lock();
} else {
a2dp_suspended = false;
}
diff --git a/session/src/Session.cpp b/session/src/Session.cpp
index 3213362..7235640 100644
--- a/session/src/Session.cpp
+++ b/session/src/Session.cpp
@@ -692,7 +692,8 @@
}
if ((PAL_DEVICE_OUT_SPEAKER == dAttr.id) &&
- (2 == dAttr.config.ch_info.channels)) {
+ (2 == dAttr.config.ch_info.channels) &&
+ (strcmp(dAttr.custom_config.custom_key, "mspp") != 0)) {
/* Get DevicePP MFC MIID and configure to match to device config */
/* This has to be done after sending all mixer controls and
* before connect
diff --git a/stream/src/Stream.cpp b/stream/src/Stream.cpp
index 3a3e8a8..17f8314 100644
--- a/stream/src/Stream.cpp
+++ b/stream/src/Stream.cpp
@@ -836,7 +836,9 @@
PAL_ERR(LOG_TAG, "Sound card offline, status %d", status);
goto exit;
}
+ rm->lockResourceManagerMutex();
status = session->getTimestamp(stime);
+ rm->unlockResourceManagerMutex();
if (0 != status) {
PAL_ERR(LOG_TAG, "Failed to get session timestamp status %d", status);
if (errno == -ENETRESET &&
@@ -864,6 +866,16 @@
a2dpSuspend = false;
+ /* Check for BT device connected state */
+ for (int32_t i = 0; i < mDevices.size(); i++) {
+ pal_device_id_t dev_id = (pal_device_id_t)mDevices[i]->getSndDeviceId();
+ if (rm->isBtDevice(dev_id) && !(rm->isDeviceAvailable(dev_id))) {
+ PAL_ERR(LOG_TAG, "BT device %d not connected", dev_id);
+ status = -ENODEV;
+ goto exit;
+ }
+ }
+
/* SCO device is not ready */
if (rm->isDeviceAvailable(mDevices, PAL_DEVICE_OUT_BLUETOOTH_SCO) &&
!rm->isDeviceReady(PAL_DEVICE_OUT_BLUETOOTH_SCO)) {
diff --git a/stream/src/StreamCompress.cpp b/stream/src/StreamCompress.cpp
index e972608..9fe128e 100644
--- a/stream/src/StreamCompress.cpp
+++ b/stream/src/StreamCompress.cpp
@@ -996,7 +996,6 @@
if (0 != status) {
PAL_ERR(LOG_TAG, "session setParameters for rotation failed with status %d",
status);
- goto exit;
}
}
diff --git a/stream/src/StreamPCM.cpp b/stream/src/StreamPCM.cpp
index 0f35dbe..e001253 100644
--- a/stream/src/StreamPCM.cpp
+++ b/stream/src/StreamPCM.cpp
@@ -1326,7 +1326,6 @@
if (0 != status) {
PAL_ERR(LOG_TAG, "session setParameters for rotation failed with status %d",
status);
- goto exit;
}
}