Merge "sthal: add a check to skip client detection callback"
diff --git a/SoundTriggerSession.cpp b/SoundTriggerSession.cpp
index 3b09ec8..2dfa978 100644
--- a/SoundTriggerSession.cpp
+++ b/SoundTriggerSession.cpp
@@ -231,7 +231,10 @@
     session->ses_mutex_.unlock();
     lock_status = false;
     ATRACE_BEGIN("sthal: client detection callback");
-    callback(st_event, session->GetCookie());
+    if (session->state_ == ACTIVE)
+        callback(st_event, session->GetCookie());
+    else
+        ALOGW("%s: skip detection callback as client has stopped", __func__);
     ATRACE_END();
 
 exit: