audio: Prevent invalidation of second input stream
Audio HAL maintains a singleton for the current active input.
Change the semantics of this singleton to refer to the
latest active input.
Bug: 63935167
Test: verify capture in MMAP mode
Change-Id: I38803bdd19287b7526bb4460496b6be609b60a8c
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index d7769ff..63f6101 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1348,10 +1348,20 @@
struct audio_usecase *uc_info;
struct audio_device *adev = in->dev;
- adev->active_input = NULL;
-
ALOGV("%s: enter: usecase(%d: %s)", __func__,
in->usecase, use_case_table[in->usecase]);
+
+ if (adev->active_input) {
+ if (adev->active_input->usecase == in->usecase) {
+ adev->active_input = NULL;
+ } else {
+ ALOGW("%s adev->active_input->usecase %s, v/s in->usecase %s",
+ __func__,
+ use_case_table[adev->active_input->usecase],
+ use_case_table[in->usecase]);
+ }
+ }
+
uc_info = get_usecase_from_list(adev, in->usecase);
if (uc_info == NULL) {
ALOGE("%s: Could not find the usecase (%d) in the list",
@@ -3098,7 +3108,7 @@
if (ret >= 0) {
val = atoi(value);
- if (((int)in->device != val) && (val != 0)) {
+ if (((int)in->device != val) && (val != 0) && audio_is_input_device(val) ) {
in->device = val;
/* If recording is in progress, change the tx device to new device */
if (!in->standby) {