hal: Fix crash during voice call
-Validate active_input before accessing it, it NULL use
default value.
-For voice call scenario it is not necessary to have an active
input stream.
Change-Id: I258b9e8c098d76f838bcca5b968d64369243885e
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 8902f63..ac72862 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -3456,7 +3456,8 @@
AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
snd_device_t snd_device = SND_DEVICE_NONE;
int channel_count = popcount(channel_mask);
- int str_bitwidth = adev->active_input->bit_width;
+ int str_bitwidth = (adev->active_input == NULL) ?
+ CODEC_BACKEND_DEFAULT_BIT_WIDTH : adev->active_input->bit_width;
ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)",
__func__, out_device, in_device, channel_count, channel_mask);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index c0d3ebe..f9ee4b1 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3098,7 +3098,8 @@
AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
snd_device_t snd_device = SND_DEVICE_NONE;
int channel_count = popcount(channel_mask);
- int str_bitwidth = adev->active_input->bit_width;
+ int str_bitwidth = (adev->active_input == NULL) ?
+ CODEC_BACKEND_DEFAULT_BIT_WIDTH : adev->active_input->bit_width;
ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)",
__func__, out_device, in_device, channel_count, channel_mask);