hal: update active_input after usecase is removed from list
update active_input only after the usecase that is being
stopped is removed from the usecase list. Otherwise,
active_input can be set to the same usecase that is being
terminated and input stream deallocated. At that point
members of active_input will be invalid.
CRs-Fixed: 1094825
Change-Id: I200ed352ff3c9d048884c9e464ba7d75fc7beeca
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 40aea9a..62bb88d 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1666,8 +1666,6 @@
struct audio_usecase *uc_info;
struct audio_device *adev = in->dev;
- adev->active_input = get_next_active_input(adev);
-
ALOGV("%s: enter: usecase(%d: %s)", __func__,
in->usecase, use_case_table[in->usecase]);
uc_info = get_usecase_from_list(adev, in->usecase);
@@ -1689,6 +1687,8 @@
list_remove(&uc_info->list);
free(uc_info);
+ adev->active_input = get_next_active_input(adev);
+
ALOGV("%s: exit: status(%d)", __func__, ret);
return ret;
}