st-hal: Fix deadlock for SSR during buffering

There is a deadlock that can occur when an SSR offline event
comes during buffering. The buffering thread sends a
deferred stop event to the state machine if it stops with
an error. This is intended for buffer overflow and other
possible internal errors, but not for SSR usecases.

Change-Id: I0fbba51f698784ac2f36f2526b78549b48f6f227
diff --git a/st_session.c b/st_session.c
index c5f1b31..f5b7672 100644
--- a/st_session.c
+++ b/st_session.c
@@ -232,7 +232,8 @@
         do {
             lock_status = pthread_mutex_trylock(&st_ses->lock);
         } while (lock_status && !st_ses->det_stc_ses->pending_stop &&
-                 (st_ses->current_state == buffering_state_fn));
+                 (st_ses->current_state == buffering_state_fn) &&
+                 !st_ses->stdev->ssr_offline_received);
 
         if (st_ses->det_stc_ses->pending_stop)
             ALOGV("%s:[%d] pending stop already queued, ignore event",
@@ -243,6 +244,9 @@
         else if (st_ses->current_state != buffering_state_fn)
             ALOGV("%s:[%d] session already stopped buffering, ignore event",
                 __func__, st_ses->sm_handle);
+        else if (st_ses->stdev->ssr_offline_received)
+            ALOGV("%s:[%d] SSR handling in progress, ignore event",
+                  __func__, st_ses->sm_handle);
         else if (!lock_status)
             DISPATCH_EVENT(st_ses, ev, status);