Merge 309a76a3d6bcd8cd09287c753be04d20b946f05e on remote branch
Change-Id: I20532258bda4571b78ef71b04878d0d61914a4cc
diff --git a/Pal.cpp b/Pal.cpp
index 4a57c37..ecfde15 100644
--- a/Pal.cpp
+++ b/Pal.cpp
@@ -544,7 +544,7 @@
return status;
}
- if (!stream_handle || !volume) {
+ if (!stream_handle || !volume || volume->no_of_volpair > PAL_MAX_CHANNELS_SUPPORTED) {
status = -EINVAL;
PAL_ERR(LOG_TAG,"Invalid input parameters status %d", status);
return status;
diff --git a/PalDefs.h b/PalDefs.h
index e54df4b..c557428 100644
--- a/PalDefs.h
+++ b/PalDefs.h
@@ -903,6 +903,23 @@
PAL_PARAM_ID_VOLUME_USING_SET_PARAM = 55,
PAL_PARAM_ID_UHQA_FLAG = 56,
PAL_PARAM_ID_STREAM_ATTRIBUTES = 57,
+ PAL_PARAM_ID_SET_UPD_DUTY_CYCLE = 58,
+ PAL_PARAM_ID_MSPP_LINEAR_GAIN = 59,
+ PAL_PARAM_ID_SET_SOURCE_METADATA = 60,
+ PAL_PARAM_ID_SET_SINK_METADATA = 61,
+ PAL_PARAM_ID_ULTRASOUND_RAMPDOWN = 62,
+ PAL_PARAM_ID_VOLUME_CTRL_RAMP = 63,
+ PAL_PARAM_ID_SVA_WAKEUP_MODULE_VERSION = 64,
+ PAL_PARAM_ID_GAIN_USING_SET_PARAM = 65,
+ PAL_PARAM_ID_HAPTICS_CNFG = 66,
+ PAL_PARAM_ID_WAKEUP_ENGINE_PER_MODEL_RESET = 67,
+ PAL_PARAM_ID_RECONFIG_ENCODER = 68,
+ PAL_PARAM_ID_VUI_SET_META_DATA = 69,
+ PAL_PARAM_ID_VUI_GET_META_DATA = 70,
+ PAL_PARAM_ID_VUI_CAPTURE_META_DATA = 71,
+ PAL_PARAM_ID_TIMESTRETCH_PARAMS = 72,
+ PAL_PARAM_ID_LATENCY_MODE = 73,
+ PAL_PARAM_ID_PROXY_RECORD_SESSION = 74,
} pal_param_id_type_t;
/** HDMI/DP */
@@ -943,6 +960,10 @@
uint32_t level;
};
+struct pal_vol_ctrl_ramp_param {
+ uint32_t ramp_period_ms;
+};
+
/* Payload For ID: PAL_PARAM_ID_DEVICE_CONNECTION
* Description : Device Connection
*/
diff --git a/ipc/HwBinders/pal_ipc_server/inc/pal_server_wrapper.h b/ipc/HwBinders/pal_ipc_server/inc/pal_server_wrapper.h
index a8e6a44..214e312 100644
--- a/ipc/HwBinders/pal_ipc_server/inc/pal_server_wrapper.h
+++ b/ipc/HwBinders/pal_ipc_server/inc/pal_server_wrapper.h
@@ -25,6 +25,10 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef ANDROID_SYSTEM_pal_V1_0_pal_H
@@ -107,6 +111,7 @@
struct PAL : public IPAL /*, public android::hardware::hidl_death_recipient*/{
public:
+ std::mutex mClientLock;
PAL()
{
sInstance = this;
@@ -198,6 +203,7 @@
static PAL* sInstance;
int find_dup_fd_from_input_fd(const uint64_t streamHandle, int input_fd, int *dup_fd);
void add_input_and_dup_fd(const uint64_t streamHandle, int input_fd, int dup_fd);
+ bool isValidstreamHandle(const uint64_t streamHandle);
};
class PalClientDeathRecipient : public android::hardware::hidl_death_recipient
diff --git a/ipc/HwBinders/pal_ipc_server/src/pal_server_wrapper.cpp b/ipc/HwBinders/pal_ipc_server/src/pal_server_wrapper.cpp
index 57a84c3..d9db67e 100644
--- a/ipc/HwBinders/pal_ipc_server/src/pal_server_wrapper.cpp
+++ b/ipc/HwBinders/pal_ipc_server/src/pal_server_wrapper.cpp
@@ -26,8 +26,8 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
@@ -57,6 +57,7 @@
std::lock_guard<std::mutex> guard(mLock);
ALOGD("%s : client died pid : %d", __func__, cookie);
int pid = (int) cookie;
+ std::lock_guard<std::mutex> lock(mPalInstance->mClientLock);
auto &clients = mPalInstance->mPalClients;
for (auto itr = clients.begin(); itr != clients.end(); itr++) {
auto client = *itr;
@@ -88,6 +89,7 @@
void PAL::add_input_and_dup_fd(const uint64_t streamHandle, int input_fd, int dup_fd)
{
std::vector<std::pair<int, int>>::iterator it;
+ std::lock_guard<std::mutex> guard(mClientLock);
for (auto& s: mPalClients) {
std::lock_guard<std::mutex> lock(s->mActiveSessionsLock);
for (int i = 0; i < s->mActiveSessions.size(); i++) {
@@ -131,6 +133,7 @@
ALOGE("%s: No PAL instance running", __func__);
return false;
}
+ std::lock_guard<std::mutex> guard(PAL::getInstance()->mClientLock);
for (auto& s: PAL::getInstance()->mPalClients) {
std::lock_guard<std::mutex> lock(s->mActiveSessionsLock);
for (int idx = 0; idx < s->mActiveSessions.size(); idx++) {
@@ -170,6 +173,7 @@
* Find the original fd that was passed by client based on what
* input and dup fd list and send that back.
*/
+ PAL::getInstance()->mClientLock.lock();
for (auto& s: PAL::getInstance()->mPalClients) {
std::lock_guard<std::mutex> lock(s->mActiveSessionsLock);
for (int idx = 0; idx < s->mActiveSessions.size(); idx++) {
@@ -192,6 +196,7 @@
}
}
}
+ PAL::getInstance()->mClientLock.unlock();
rwDonePayloadHidl.resize(sizeof(struct pal_event_read_write_done_payload));
rwDonePayload =(PalEventReadWriteDonePayload *)rwDonePayloadHidl.data();
@@ -311,6 +316,32 @@
print_media_config(&attr->out_media_config);
}
+bool PAL::isValidstreamHandle(const uint64_t streamHandle) {
+ int pid = ::android::hardware::IPCThreadState::self()->getCallingPid();
+
+ std::lock_guard<std::mutex> guard(mClientLock);
+ for (auto itr = mPalClients.begin(); itr != mPalClients.end(); ) {
+ auto client = *itr;
+ if (client->pid == pid) {
+ std::lock_guard<std::mutex> lock(client->mActiveSessionsLock);
+ auto sItr = client->mActiveSessions.begin();
+ for (; sItr != client->mActiveSessions.end(); sItr++) {
+ if (sItr->session_handle == streamHandle) {
+ return true;
+ }
+ }
+ ALOGE("%s: streamHandle: %pK for pid %d not found",
+ __func__, streamHandle, pid);
+ return false;
+ }
+ itr++;
+ }
+
+ ALOGE("%s: client info for pid %d not found",
+ __func__, pid);
+ return false;
+}
+
Return<void> PAL::ipc_pal_stream_open(const hidl_vec<PalStreamAttributes>& attr_hidl,
uint32_t noOfDevices,
const hidl_vec<PalDevice>& devs_hidl,
@@ -414,6 +445,7 @@
callback, (uint64_t)sr_clbk_data.get(), &stream_handle);
if (!ret) {
+ std::lock_guard<std::mutex> guard(mClientLock);
for(auto& client: mPalClients) {
if (client->pid == pid) {
/*Another session from the same client*/
@@ -469,8 +501,13 @@
Return<int32_t> PAL::ipc_pal_stream_close(const uint64_t streamHandle)
{
int pid = ::android::hardware::IPCThreadState::self()->getCallingPid();
- Return<int32_t> status = pal_stream_close((pal_stream_handle_t *)streamHandle);
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
+ mClientLock.lock();
for (auto itr = mPalClients.begin(); itr != mPalClients.end(); ) {
auto client = *itr;
if (client->pid == pid) {
@@ -503,38 +540,77 @@
break;
}
}
+ mClientLock.unlock();
+
+ Return<int32_t> status = pal_stream_close((pal_stream_handle_t *)streamHandle);
+
return status;
}
Return<int32_t> PAL::ipc_pal_stream_start(const uint64_t streamHandle) {
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
return pal_stream_start((pal_stream_handle_t *)streamHandle);
}
Return<int32_t> PAL::ipc_pal_stream_stop(const uint64_t streamHandle) {
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_stop((pal_stream_handle_t *)streamHandle);
}
Return<int32_t> PAL::ipc_pal_stream_pause(const uint64_t streamHandle) {
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_pause((pal_stream_handle_t *)streamHandle);
}
Return<int32_t> PAL::ipc_pal_stream_drain(uint64_t streamHandle, PalDrainType type)
{
pal_drain_type_t drain_type = (pal_drain_type_t) type;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_drain((pal_stream_handle_t *)streamHandle,
drain_type);
}
Return<int32_t> PAL::ipc_pal_stream_flush(const uint64_t streamHandle) {
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_flush((pal_stream_handle_t *)streamHandle);
}
Return<int32_t> PAL::ipc_pal_stream_suspend(const uint64_t streamHandle) {
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_suspend((pal_stream_handle_t *)streamHandle);
}
Return<int32_t> PAL::ipc_pal_stream_resume(const uint64_t streamHandle) {
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_resume((pal_stream_handle_t *)streamHandle);
}
@@ -547,6 +623,11 @@
pal_buffer_config_t out_buf_cfg, in_buf_cfg;
PalBufferConfig in_buff_config_ret, out_buff_config_ret;
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
+
in_buf_cfg.buf_count = in_buff_config.buf_count;
in_buf_cfg.buf_size = in_buff_config.buf_size;
in_buf_cfg.max_metadata_size = in_buff_config.max_metadata_size;
@@ -593,6 +674,12 @@
struct pal_buffer buf = {0};
uint32_t bufSize;
const native_handle *allochandle = nullptr;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
bufSize = buff_hidl.data()->size;
if (buff_hidl.data()->buffer.size() == bufSize)
buf.buffer = (uint8_t *)calloc(1, bufSize);
@@ -659,6 +746,10 @@
goto exit;
}
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
allochandle = inBuff_hidl.data()->alloc_info.alloc_handle.handle();
@@ -709,6 +800,12 @@
ALOGE("Invalid payload size");
return -EINVAL;
}
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
param_payload = (pal_param_payload *)calloc (1,
sizeof(pal_param_payload) + paramPayload.data()->size);
if (!param_payload) {
@@ -730,6 +827,12 @@
int32_t ret = 0;
pal_param_payload *param_payload;
hidl_vec<PalParamPayload> paramPayload;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
+
ret = pal_stream_get_param((pal_stream_handle_t *)streamHandle, paramId, ¶m_payload);
if (ret == 0) {
paramPayload.resize(sizeof(PalParamPayload));
@@ -757,10 +860,17 @@
struct pal_device *devices = NULL;
int cnt = 0;
int32_t ret = -ENOMEM;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
if (noOfDevices > devs_hidl.size()) {
ALOGE("Invalid noOfDevices");
return -EINVAL;
}
+
if (devs_hidl.size()) {
PalDevice *dev_hidl = NULL;
devices = (struct pal_device *)calloc (1,
@@ -811,6 +921,12 @@
ALOGE("Invalid vol vector size");
return -EINVAL;
}
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
volume = (struct pal_volume_data *) calloc(1,
sizeof(struct pal_volume_data) +
noOfVolPairs * sizeof(pal_channel_vol_kv));
@@ -843,6 +959,11 @@
Return<int32_t> PAL::ipc_pal_stream_set_mute(const uint64_t streamHandle,
bool state)
{
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_stream_set_mute((pal_stream_handle_t *)streamHandle, state);
}
@@ -861,6 +982,12 @@
{
struct pal_session_time stime;
int32_t ret = 0;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
+
hidl_vec<PalSessionTime> sessTime_hidl;
sessTime_hidl.resize(sizeof(struct pal_session_time));
ret = pal_get_timestamp((pal_stream_handle_t *)streamHandle, &stime);
@@ -873,6 +1000,11 @@
const PalAudioEffect effect,
bool enable)
{
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return -EINVAL;
+ }
+
return pal_add_remove_effect((pal_stream_handle_t *)streamHandle,
(pal_audio_effect_t) effect, enable);
}
@@ -932,6 +1064,12 @@
int32_t ret = 0;
struct pal_mmap_buffer info;
hidl_vec<PalMmapBuffer> mMapBuffer_hidl;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
+
mMapBuffer_hidl.resize(sizeof(struct pal_mmap_buffer));
ret = pal_stream_create_mmap_buffer((pal_stream_handle_t *)streamHandle, min_size_frames, &info);
mMapBuffer_hidl.data()->buffer = (uint64_t)info.buffer;
@@ -949,6 +1087,12 @@
int32_t ret = 0;
struct pal_mmap_position mmap_position;
hidl_vec<PalMmapPosition> mmap_position_hidl;
+
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
+
mmap_position_hidl.resize(sizeof(struct pal_mmap_position));
ret = pal_stream_get_mmap_position((pal_stream_handle_t *)streamHandle, &mmap_position);
memcpy(mmap_position_hidl.data(), &mmap_position, sizeof(struct pal_mmap_position));
@@ -977,6 +1121,11 @@
size_t sz = size;
hidl_vec<uint8_t> payloadRet;
+ if (!isValidstreamHandle(streamHandle)) {
+ ALOGE("%s: Invalid streamHandle: %pK", __func__, streamHandle);
+ return Void();
+ }
+
if (size > 0) {
payload = (uint8_t *)calloc(1, size);
if (!payload) {
diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp
index 1b724bc..a1686dd 100644
--- a/resource_manager/src/ResourceManager.cpp
+++ b/resource_manager/src/ResourceManager.cpp
@@ -26,8 +26,8 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
@@ -6314,7 +6314,15 @@
if (backEndName == listAllBackEndIds[i].second) {
dev = Device::getObject((pal_device_id_t) i);
if(dev) {
- getActiveStream_l(activeStreams, dev);
+ std::list<Stream*>::iterator it;
+ for(it = mActiveStreams.begin(); it != mActiveStreams.end(); it++) {
+ std::vector <std::shared_ptr<Device>> devices;
+ (*it)->getAssociatedDevices(devices);
+ typename std::vector<std::shared_ptr<Device>>::iterator result =
+ std::find(devices.begin(), devices.end(), dev);
+ if (result != devices.end())
+ activeStreams.push_back(*it);
+ }
PAL_DBG(LOG_TAG, "got dev %d active streams on dev is %zu", i, activeStreams.size() );
for (int j=0; j < activeStreams.size(); j++) {
/*do not add if this is a dup*/
diff --git a/session/src/PayloadBuilder.cpp b/session/src/PayloadBuilder.cpp
index 3f91b7f..7752b08 100644
--- a/session/src/PayloadBuilder.cpp
+++ b/session/src/PayloadBuilder.cpp
@@ -27,7 +27,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
@@ -3671,6 +3671,7 @@
memcpy(spThrshConf, data, sizeof(param_id_cps_lpass_swr_thresholds_cfg_t) +
(sizeof(cps_reg_wr_values_t) * data->num_spkr));
}
+ break;
case PARAM_ID_SP_VI_CH_ENABLE:
{
param_id_sp_vi_ch_enable_t *spConf = NULL;
@@ -3694,6 +3695,7 @@
spConf->chan_en_flag[i] = data->chan_en_flag[i];
}
}
+ break;
case PARAM_ID_SP_RX_CH_ENABLE:
{
param_id_sp_rx_ch_enable_t *spConf = NULL;
diff --git a/stream/src/Stream.cpp b/stream/src/Stream.cpp
index 5ce9704..588bbab 100644
--- a/stream/src/Stream.cpp
+++ b/stream/src/Stream.cpp
@@ -1,6 +1,5 @@
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -27,8 +26,8 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
@@ -1032,7 +1031,13 @@
int32_t status = 0;
if (currentState == STREAM_IDLE) {
- PAL_DBG(LOG_TAG, "stream is in %d state, no need to switch device", currentState);
+ for (int i = 0; i < mDevices.size(); i++) {
+ if (dev_id == mDevices[i]->getSndDeviceId()) {
+ mDevices.erase(mDevices.begin() + i);
+ PAL_DBG(LOG_TAG, "stream is in IDLE state, erase device: %d", dev_id);
+ break;
+ }
+ }
status = 0;
goto exit;
}
@@ -1110,7 +1115,8 @@
dev->setDeviceAttributes(*dattr);
if (currentState == STREAM_IDLE) {
- PAL_DBG(LOG_TAG, "stream is in %d state, no need to switch device", currentState);
+ PAL_DBG(LOG_TAG, "stream is in IDLE state, insert %d to mDevices", dev->getSndDeviceId());
+ mDevices.push_back(dev);
status = 0;
goto exit;
}
diff --git a/stream/src/StreamCommon.cpp b/stream/src/StreamCommon.cpp
index 74c84cd..2f5dff4 100644
--- a/stream/src/StreamCommon.cpp
+++ b/stream/src/StreamCommon.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/stream/src/StreamCompress.cpp b/stream/src/StreamCompress.cpp
index 0115296..24be80a 100644
--- a/stream/src/StreamCompress.cpp
+++ b/stream/src/StreamCompress.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -131,6 +132,7 @@
session->registerCallBack(handleSessionCallBack, (uint64_t)this);
PAL_VERBOSE(LOG_TAG,"Create new Devices with no_of_devices - %d", no_of_devices);
+ bool str_registered = false;
for (uint32_t i = 0; i < no_of_devices; i++) {
dev = Device::getInstance((struct pal_device *)&dattr[i] , rm);
if (dev == nullptr) {
@@ -144,6 +146,10 @@
}
mPalDevice.push_back(dattr[i]);
mStreamMutex.unlock();
+ if (!str_registered) {
+ rm->registerStream(this);
+ str_registered = true;
+ }
isDeviceConfigUpdated = rm->updateDeviceConfig(&dev, &dattr[i], sattr);
mStreamMutex.lock();
@@ -154,7 +160,6 @@
dev = nullptr;
}
mStreamMutex.unlock();
- rm->registerStream(this);
PAL_VERBOSE(LOG_TAG,"exit, state %d", currentState);
}
@@ -853,6 +858,10 @@
int32_t StreamCompress::pause_l()
{
int32_t status = 0;
+ uint8_t volSize = 0;
+ struct pal_vol_ctrl_ramp_param ramp_param;
+ struct pal_volume_data *voldata = NULL;
+ struct pal_volume_data *volume = NULL;
std::unique_lock<std::mutex> pauseLock(pauseMutex);
//AF will try to pause the stream during SSR.
@@ -869,6 +878,45 @@
if (isPaused) {
PAL_INFO(LOG_TAG, "Stream is already paused");
} else {
+ //caching the volume before setting it to 0
+ voldata = (struct pal_volume_data *)calloc(1, (sizeof(uint32_t) +
+ (sizeof(struct pal_channel_vol_kv) * (0xFFFF))));
+ if (!voldata) {
+ status = -ENOMEM;
+ goto exit;
+ }
+
+ status = this->getVolumeData(voldata);
+ if (0 != status) {
+ PAL_ERR(LOG_TAG,"getVolumeData Failed \n");
+ goto exit;
+ }
+ /* set ramp period to 0 */
+ ramp_param.ramp_period_ms = 0;
+ status = session->setParameters(this, TAG_STREAM_VOLUME, PAL_PARAM_ID_VOLUME_CTRL_RAMP, &ramp_param);
+ if (0 != status)
+ PAL_ERR(LOG_TAG, "session setParam for vol ctrl ramp failed with status %d", status);
+
+ volSize = sizeof(uint32_t) + (sizeof(struct pal_channel_vol_kv) * (voldata->no_of_volpair));
+ status = 0; /* not fatal , reset status to 0 */
+ /* set volume to 0 */
+ volume = (struct pal_volume_data *)calloc(1, volSize);
+ if (!volume) {
+ PAL_ERR(LOG_TAG, "Failed to allocate mem for volume");
+ status = -ENOMEM;
+ goto exit;
+ }
+ ar_mem_cpy(volume, volSize, voldata, volSize);
+ for (int32_t i = 0; i < (voldata->no_of_volpair); i++) {
+ volume->volume_pair[i].vol = 0x0;
+ }
+ setVolume(volume);
+ ar_mem_cpy(mVolumeData, volSize, voldata, volSize);
+ free(volume);
+ free(voldata);
+ volume = NULL;
+ voldata = NULL;
+
status = session->setConfig(this, MODULE, PAUSE_TAG);
if (0 != status) {
PAL_ERR(LOG_TAG,"session setConfig for pause failed with status %d",status);
diff --git a/stream/src/StreamPCM.cpp b/stream/src/StreamPCM.cpp
index c297e92..4cfb876 100644
--- a/stream/src/StreamPCM.cpp
+++ b/stream/src/StreamPCM.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -131,6 +132,7 @@
}
PAL_VERBOSE(LOG_TAG, "Create new Devices with no_of_devices - %d", no_of_devices);
+ bool str_registered = false;
for (int i = no_of_devices - 1; i >= 0 ; i--) {
//Check with RM if the configuration given can work or not
//for e.g., if incoming stream needs 24 bit device thats also
@@ -150,6 +152,14 @@
}
mPalDevice.push_back(dattr[i]);
mStreamMutex.unlock();
+ /* Stream mutex is unlocked before calling stream specific API
+ * in resource manager to avoid deadlock issues between stream
+ * and active stream mutex from ResourceManager.
+ */
+ if (!str_registered) {
+ rm->registerStream(this);
+ str_registered = true;
+ }
isDeviceConfigUpdated = rm->updateDeviceConfig(&dev, &dattr[i], sattr);
mStreamMutex.lock();
@@ -169,11 +179,6 @@
session->registerCallBack(handleSoftPauseCallBack, (uint64_t)this);
mStreamMutex.unlock();
- /* Stream mutex is unlocked before calling stream specific API
- * in resource manager to avoid deadlock issues between stream
- * and active stream mutex from ResourceManager.
- */
- rm->registerStream(this);
PAL_DBG(LOG_TAG, "Exit. state %d", currentState);
return;
}
@@ -1180,6 +1185,10 @@
int32_t StreamPCM::pause_l()
{
int32_t status = 0;
+ uint8_t volSize = 0;
+ struct pal_vol_ctrl_ramp_param ramp_param;
+ struct pal_volume_data *voldata = NULL;
+ struct pal_volume_data *volume = NULL;
std::unique_lock<std::mutex> pauseLock(pauseMutex);
PAL_DBG(LOG_TAG, "Enter. session handle - %pK", session);
if (rm->cardState == CARD_STATUS_OFFLINE) {
@@ -1192,6 +1201,45 @@
if (isPaused) {
PAL_INFO(LOG_TAG, "Stream is already paused");
} else {
+ //caching the volume before setting it to 0
+ voldata = (struct pal_volume_data *)calloc(1, (sizeof(uint32_t) +
+ (sizeof(struct pal_channel_vol_kv) * (0xFFFF))));
+ if (!voldata) {
+ status = -ENOMEM;
+ goto exit;
+ }
+
+ status = this->getVolumeData(voldata);
+ if (0 != status) {
+ PAL_ERR(LOG_TAG,"getVolumeData Failed \n");
+ goto exit;
+ }
+ /* set ramp period to 0 */
+ ramp_param.ramp_period_ms = 0;
+ status = session->setParameters(this, TAG_STREAM_VOLUME, PAL_PARAM_ID_VOLUME_CTRL_RAMP, &ramp_param);
+ if (0 != status)
+ PAL_ERR(LOG_TAG, "session setParam for vol ctrl ramp failed with status %d", status);
+
+ volSize = sizeof(uint32_t) + (sizeof(struct pal_channel_vol_kv) * (voldata->no_of_volpair));
+ status = 0; /* not fatal , reset status to 0 */
+ /* set volume to 0 */
+ volume = (struct pal_volume_data *)calloc(1, volSize);
+ if (!volume) {
+ PAL_ERR(LOG_TAG, "Failed to allocate mem for volume");
+ status = -ENOMEM;
+ goto exit;
+ }
+ ar_mem_cpy(volume, volSize, voldata, volSize);
+ for (int32_t i = 0; i < (voldata->no_of_volpair); i++) {
+ volume->volume_pair[i].vol = 0x0;
+ }
+ setVolume(volume);
+ ar_mem_cpy(mVolumeData, volSize, voldata, volSize);
+ free(volume);
+ free(voldata);
+ volume = NULL;
+ voldata = NULL;
+
status = session->setConfig(this, MODULE, PAUSE_TAG);
if (0 != status) {
PAL_ERR(LOG_TAG, "session setConfig for pause failed with status %d",
diff --git a/stream/src/StreamSensorPCMData.cpp b/stream/src/StreamSensorPCMData.cpp
index 86529fd..277c1e1 100644
--- a/stream/src/StreamSensorPCMData.cpp
+++ b/stream/src/StreamSensorPCMData.cpp
@@ -25,6 +25,10 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#define LOG_TAG "PAL: StreamSensorPCMData"
diff --git a/stream/src/StreamUltraSound.cpp b/stream/src/StreamUltraSound.cpp
index 2ce4f95..2df53a1 100644
--- a/stream/src/StreamUltraSound.cpp
+++ b/stream/src/StreamUltraSound.cpp
@@ -25,6 +25,10 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center, Inc. are provided under the following license:
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#define LOG_TAG "PAL: StreamUltraSound"