hal: Fix for device check against wrong codec backend
Make sure out stream device is checked against out codec backend
device and in stream device against in codec backend. Checking out
device against in codec backend or vice versa leads to issues as
some out and in device ids are common except the bit in.
CRs-Fixed: 1088820
Change-Id: I1197411c287cf65d41ed1d16f300e962b677b832
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 7bfc5de..81741fc 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2370,6 +2370,8 @@
if (backend_tag_table[snd_device] != NULL) {
if (strcmp(backend_tag_table[snd_device], "usb-headset-mic") == 0)
port = USB_AUDIO_TX_BACKEND;
+ else if (strstr(backend_tag_table[snd_device], "bt-sco") != NULL)
+ port = BT_SCO_TX_BACKEND;
}
} else {
ALOGW("%s:napb: Invalid device - %d ", __func__, snd_device);
@@ -3025,6 +3027,10 @@
{
struct platform_data *my_data = (struct platform_data *)platform;
struct audio_device *adev = my_data->adev;
+ /*
+ * TODO: active_input always points to last opened input. Source returned will
+ * be wrong if more than one active inputs are present.
+ */
audio_source_t source = (adev->active_input == NULL) ?
AUDIO_SOURCE_DEFAULT : adev->active_input->source;
@@ -4357,8 +4363,8 @@
sample_rate, channels, backend_idx,
platform_get_snd_device_name(snd_device));
- if (bit_width !=
- my_data->current_backend_cfg[backend_idx].bit_width) {
+ if ((my_data->current_backend_cfg[backend_idx].bitwidth_mixer_ctl) &&
+ (bit_width != my_data->current_backend_cfg[backend_idx].bit_width)) {
struct mixer_ctl *ctl = NULL;
ctl = mixer_get_ctl_by_name(adev->mixer,
@@ -4392,8 +4398,8 @@
ret = 0;
}
- if (sample_rate !=
- my_data->current_backend_cfg[backend_idx].sample_rate) {
+ if ((my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl) &&
+ (sample_rate != my_data->current_backend_cfg[backend_idx].sample_rate)) {
char *rate_str = NULL;
struct mixer_ctl *ctl = NULL;