audio sound_trigger: Check null pointer in streaming

A case was encountered at resume that recognition callback got
triggered but failed to read more data from the DSP. Current
error handling closes the pcm for this error but never open it
until start_recognition is called again. This causes media server
crash at the next attempt to read samples from the NULL pcm.
Add NULL checks for this pcm so that this failure can be handled
by the caller instead of crash.

BUG=25875632

Change-Id: Ic4817baada45560856fc26c5e8fe89facb773696
diff --git a/audio/soundtrigger/sound_trigger_hw.c b/audio/soundtrigger/sound_trigger_hw.c
index bf5d113..35ef5ec 100644
--- a/audio/soundtrigger/sound_trigger_hw.c
+++ b/audio/soundtrigger/sound_trigger_hw.c
@@ -503,6 +503,11 @@
         ret = -EBUSY;
         goto exit;
     }
+    if (!stdev->pcm) {
+        ALOGE("%s: PCM is not open", __func__);
+        ret = -EINVAL;
+        goto exit;
+    }
     // TODO: Probably want to get something from whoever called us to bind to it/assert that it's a
     // valid connection. Perhaps returning a more
     // meaningful handle would be a good idea as well.
@@ -542,6 +547,12 @@
         ret = -EINVAL;
         goto exit;
     }
+    if (!stdev->pcm) {
+        ALOGE("%s: PCM has closed", __func__);
+        ret = -EINVAL;
+        goto exit;
+    }
+
 
 read_again:
     frames = pcm_mmap_avail(stdev->pcm);