pal: partially revert change 5149268 to fix regressions
Due to moving the invocation of function registerStream() from
derived class StreamUltraSound and StreamSensorPCMData to base
class StreamCommon, pointer sUPD and sPCM become null pointers
when they are downcasted by using dynamic_cast. Therefore, the
null pointers sUPD and sPCM are pushed to active stream lists:
active_streams_ultrasound and active_streams_sensor_pcm_data,
which result in null pointer dereference in several functions.
To fix regressions caused by change 5149268 on stream UPD and
stream Sensor PCM Data, revert related changes in below commit
39cf5f7dae407489500a99e974a2c43a377a9d6c
Change-Id: I9a09edec0ff0bce33cb088688c90e1b2769885c3
diff --git a/stream/src/StreamCommon.cpp b/stream/src/StreamCommon.cpp
index fc15901..a2cd8d2 100644
--- a/stream/src/StreamCommon.cpp
+++ b/stream/src/StreamCommon.cpp
@@ -128,7 +128,6 @@
dev->setBitWidth(inDeviceInfo.bit_width);
}
}
- bool str_registered = false;
for (int i = 0; i < no_of_devices; i++) {
//Check with RM if the configuration given can work or not
//for e.g., if incoming stream needs 24 bit device thats also
@@ -146,10 +145,6 @@
dev->insertStreamDeviceAttr(&dattr[i], this);
mPalDevices.push_back(dev);
mStreamMutex.unlock();
- if (!str_registered) {
- rm->registerStream(this);
- str_registered = true;
- }
isDeviceConfigUpdated = rm->updateDeviceConfig(&dev, &dattr[i], sattr);
mStreamMutex.lock();
diff --git a/stream/src/StreamSensorPCMData.cpp b/stream/src/StreamSensorPCMData.cpp
index f8af057..b125c33 100644
--- a/stream/src/StreamSensorPCMData.cpp
+++ b/stream/src/StreamSensorPCMData.cpp
@@ -61,6 +61,7 @@
throw std::runtime_error("Failed to get acd platform info");
}
+ rm->registerStream(this);
/* Print the concurrency feature flags supported */
PAL_INFO(LOG_TAG, "capture conc enable %d,voice conc enable %d,voip conc enable %d",
acd_info_->GetConcurrentCaptureEnable(),
diff --git a/stream/src/StreamUltraSound.cpp b/stream/src/StreamUltraSound.cpp
index 1828f51..8b6566d 100644
--- a/stream/src/StreamUltraSound.cpp
+++ b/stream/src/StreamUltraSound.cpp
@@ -48,6 +48,7 @@
{
gain = PAL_ULTRASOUND_GAIN_MUTE;
session->registerCallBack((session_callback)HandleCallBack,((uint64_t) this));
+ rm->registerStream(this);
}
StreamUltraSound::~StreamUltraSound()