Merge "st-hal: fix session pause and lpi switch for concurrency"
diff --git a/sound_trigger_hw.c b/sound_trigger_hw.c
index 91ff15f..f5def84 100644
--- a/sound_trigger_hw.c
+++ b/sound_trigger_hw.c
@@ -824,8 +824,10 @@
             } else {
                 ALOGV("%s: Ignore capture events as sva has dedicated path", __func__);
             }
-            pthread_mutex_unlock(&stdev->lock);
-            return;
+            if (!conc_allowed) {
+                pthread_mutex_unlock(&stdev->lock);
+                return;
+            }
         }
     } else {
         /*
@@ -842,8 +844,6 @@
                 p_ses = node_to_item(p_ses_node, st_session_t, list_node);
                 st_session_pause(p_ses);
             }
-            pthread_mutex_unlock(&stdev->lock);
-            return;
         } else {
             if (event_type == AUDIO_EVENT_CAPTURE_DEVICE_INACTIVE) {
                 list_for_each(p_ses_node, &stdev->sound_model_list) {
@@ -863,6 +863,10 @@
             }
         }
         stdev->session_allowed = conc_allowed;
+        if (!conc_allowed) {
+            pthread_mutex_unlock(&stdev->lock);
+            return;
+        }
     }
 
     /*
@@ -1137,7 +1141,7 @@
     st_hw_check_and_update_lpi(stdev, p_ses);
 
     if (stdev->lpi_enable != platform_get_lpi_mode(stdev->platform) &&
-        !is_any_session_buffering()) {
+        !is_any_session_buffering() && stdev->session_allowed) {
         list_for_each(p_ses_node, &stdev->sound_model_list) {
             p_ses = node_to_item(p_ses_node, st_session_t, list_node);
             if (p_ses && p_ses->exec_mode == ST_EXEC_MODE_ADSP) {
@@ -1188,7 +1192,7 @@
     stdev->vad_enable = st_hw_check_vad_support(stdev, p_ses,
         stdev->lpi_enable);
     if (stdev->lpi_enable != platform_get_lpi_mode(stdev->platform) &&
-        !is_any_session_buffering() &&
+        !is_any_session_buffering() && stdev->session_allowed &&
         stdev->transit_to_non_lpi_on_battery_charging) {
         list_for_each(p_ses_node, &stdev->sound_model_list) {
             p_ses = node_to_item(p_ses_node, st_session_t, list_node);