hal: add sidetone support for USB
if usb device provides sidetone contols
- disable sidetone when usb is detected
- enable side tone only for calls.
Bug: 37404459
Test: made voice call, confirmed sidetone. Following call,
music capture and playback does not have sidetone present.
Change-Id: If2e4926f50aaaae07ea72fd5528ab0cd6658d8ab
Signed-off-by: Andrew Chant <achant@google.com>
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index 4e4c70d..6b3ee7b 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -505,9 +505,12 @@
usb_card_info->usb_sidetone_index[USB_SIDETONE_ENABLE_INDEX] = index;
/* Disable device sidetone by default */
mixer_ctl_set_value(ctl, 0, false);
+ ALOGV("%s:: sidetone mixer Control found(%s) ... disabling by default",
+ __func__, usb_sidetone_enable_str[index]);
break;
}
}
+#ifdef USB_SIDETONE_VOLUME
for (index = 0;
index < sizeof(usb_sidetone_volume_str)/sizeof(usb_sidetone_volume_str[0]);
index++) {
@@ -520,7 +523,7 @@
break;
}
}
-
+#endif // USB_SIDETONE_VOLUME
if ((usb_card_info->usb_snd_mixer != NULL) && (usb_audio_debug_enable))
usb_soundcard_list_controls(usb_card_info->usb_snd_mixer);
@@ -848,6 +851,7 @@
else
break;
+#ifdef USB_SIDETONE_VOLUME
if ((i = card_info->usb_sidetone_index[USB_SIDETONE_VOLUME_INDEX]) != -1) {
ctl = mixer_get_ctl_by_name(
card_info->usb_snd_mixer,
@@ -859,6 +863,7 @@
mixer_ctl_set_value(ctl, 0,
usb_get_sidetone_gain(card_info));
}
+#endif // USB_SIDETONE_VOLUME
ret = 0;
break;
}