Set Orientation TKV for Enqore during device switch
When device switch happens during rotation, set TKV after stop
and before start of graph to retain the Orientation TKV set at
the beginning of recording. To set TKV at switch, add endpoints
to the vector first, connect session, and remove them upon failure.
Change-Id: I037573b966ec08f68154d983427c22b6de9a1090
(cherry picked from commit aa637f583421443b4adbde1f1f730acc884ebaa0)
diff --git a/session/src/SessionAlsaCompress.cpp b/session/src/SessionAlsaCompress.cpp
index e6b9e9e..abedfc9 100644
--- a/session/src/SessionAlsaCompress.cpp
+++ b/session/src/SessionAlsaCompress.cpp
@@ -939,17 +939,43 @@
deviceToConnect->getDeviceAttributes(&dAttr);
if (!rxAifBackEndsToConnect.empty()) {
- status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
- dAttr, compressDevIds, rxAifBackEndsToConnect);
for (const auto &elem : rxAifBackEndsToConnect)
rxAifBackEnds.push_back(elem);
+ status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
+ dAttr, compressDevIds, rxAifBackEndsToConnect);
+ if (status) {
+ int cnt = 0;
+ for (const auto &elem : rxAifBackEnds) {
+ cnt++;
+ for (const auto &connectElem : rxAifBackEndsToConnect) {
+ if (std::get<0>(elem) == std::get<0>(connectElem)) {
+ rxAifBackEnds.erase(rxAifBackEnds.begin() + cnt - 1, rxAifBackEnds.begin() + cnt);
+ cnt--;
+ break;
+ }
+ }
+ }
+ }
}
if (!txAifBackEndsToConnect.empty()) {
- status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
- dAttr, compressDevIds, txAifBackEndsToConnect);
for (const auto &elem : txAifBackEndsToConnect)
txAifBackEnds.push_back(elem);
+ status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
+ dAttr, compressDevIds, txAifBackEndsToConnect);
+ if (status) {
+ int cnt = 0;
+ for (const auto &elem : txAifBackEnds) {
+ cnt++;
+ for (const auto &connectElem : txAifBackEndsToConnect) {
+ if (std::get<0>(elem) == std::get<0>(connectElem)) {
+ txAifBackEnds.erase(txAifBackEnds.begin() + cnt - 1, txAifBackEnds.begin() + cnt);
+ cnt--;
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/session/src/SessionAlsaPcm.cpp b/session/src/SessionAlsaPcm.cpp
index efd5284..0fefbdf 100644
--- a/session/src/SessionAlsaPcm.cpp
+++ b/session/src/SessionAlsaPcm.cpp
@@ -2178,6 +2178,9 @@
deviceToConnect->getDeviceAttributes(&dAttr);
if (!rxAifBackEndsToConnect.empty()) {
+ for (const auto &elem : rxAifBackEndsToConnect)
+ rxAifBackEnds.push_back(elem);
+
if (streamType != PAL_STREAM_ULTRASOUND &&
streamType != PAL_STREAM_LOOPBACK)
status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
@@ -2186,16 +2189,27 @@
status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
dAttr, pcmDevTxIds, pcmDevRxIds, rxAifBackEndsToConnect);
- if (!status) {
- for (const auto &elem : rxAifBackEndsToConnect)
- rxAifBackEnds.push_back(elem);
- } else {
+ if (status) {
PAL_ERR(LOG_TAG, "failed to connect rxAifBackEnds: %d",
(pcmDevIds.size() ? pcmDevIds.at(0) : pcmDevRxIds.at(0)));
+ int cnt = 0;
+ for (const auto &elem : rxAifBackEnds) {
+ cnt++;
+ for (const auto &connectElem : rxAifBackEndsToConnect) {
+ if (std::get<0>(elem) == std::get<0>(connectElem)) {
+ rxAifBackEnds.erase(rxAifBackEnds.begin() + cnt - 1, rxAifBackEnds.begin() + cnt);
+ cnt--;
+ break;
+ }
+ }
+ }
}
}
if (!txAifBackEndsToConnect.empty()) {
+ for (const auto &elem : txAifBackEndsToConnect)
+ txAifBackEnds.push_back(elem);
+
if (streamType != PAL_STREAM_LOOPBACK)
status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
dAttr, (pcmDevIds.size() ? pcmDevIds : pcmDevTxIds), txAifBackEndsToConnect);
@@ -2203,12 +2217,20 @@
status = SessionAlsaUtils::connectSessionDevice(this, streamHandle, streamType, rm,
dAttr, pcmDevTxIds, pcmDevRxIds, txAifBackEndsToConnect);
- if (!status) {
- for (const auto &elem : txAifBackEndsToConnect)
- txAifBackEnds.push_back(elem);
- } else {
+ if (status) {
+ int cnt = 0;
PAL_ERR(LOG_TAG, "failed to connect txAifBackEnds: %d",
(pcmDevIds.size() ? pcmDevIds.at(0) : pcmDevTxIds.at(0)));
+ for (const auto &elem : txAifBackEnds) {
+ cnt++;
+ for (const auto &connectElem : txAifBackEndsToConnect) {
+ if (std::get<0>(elem) == std::get<0>(connectElem)) {
+ txAifBackEnds.erase(txAifBackEnds.begin() + cnt - 1, txAifBackEnds.begin() + cnt);
+ cnt--;
+ break;
+ }
+ }
+ }
}
}
diff --git a/session/src/SessionAlsaUtils.cpp b/session/src/SessionAlsaUtils.cpp
index 8118ead..c9f7a7b 100644
--- a/session/src/SessionAlsaUtils.cpp
+++ b/session/src/SessionAlsaUtils.cpp
@@ -2383,6 +2383,15 @@
goto exit;
}
}
+ if (sAttr.direction == PAL_AUDIO_INPUT) {
+ if (strstr(dAttr.custom_config.custom_key , "unprocessed-hdr-mic")) {
+ status = sess->setConfig(streamHandle, MODULE, ORIENTATION_TAG);
+ if (0 != status) {
+ PAL_ERR(LOG_TAG, "setting HDR record orientation config failed with status %d", status);
+ goto exit;
+ }
+ }
+ }
} else if (!(SessionAlsaUtils::isMmapUsecase(sAttr))) {
if (sess) {
SessionAlsaVoice *voiceSession = dynamic_cast<SessionAlsaVoice *>(sess);