hal: fix segfalut from call to send audio calibration

- In case of speaker protection, capture usecase is not having
  valid input stream associated with it. Hence attempt to access
  stream info while sending calibration may result in segfaults.
- Add check in send calibration, to use stream info only if its
  available, and fallback to defaults if stream is not set.

Change-Id: I880f8c66e6cba65947846dd2fef74a74be125aa9
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 0ff921d..b806393 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2014 The Android Open Source Project
@@ -1162,7 +1162,7 @@
 {
     int type = usecase->type;
 
-    if (type == PCM_PLAYBACK) {
+    if (type == PCM_PLAYBACK && usecase->stream.out != NULL) {
         struct stream_out *out = usecase->stream.out;
         int snd_device = usecase->out_snd_device;
         snd_device = (snd_device == SND_DEVICE_OUT_SPEAKER) ?
@@ -1170,7 +1170,7 @@
         platform_send_audio_calibration(adev->platform, usecase,
                                         out->app_type_cfg.app_type,
                                         usecase->stream.out->app_type_cfg.sample_rate);
-    } else if (type == PCM_CAPTURE) {
+    } else if (type == PCM_CAPTURE && usecase->stream.in != NULL) {
         platform_send_audio_calibration(adev->platform, usecase,
                          usecase->stream.in->app_type_cfg.app_type,
                          usecase->stream.in->app_type_cfg.sample_rate);