hal: use handset-mic as input device when USB headset is unplugged.
During VoIP call, when USB headset is unplugged, AUDIO_DEVICE_OUT_USB_DEVICE
is first disconnected. This causes compress-voip stops, and other active
playback usecases output devices route to handset. But input device still
routes to AUDIO_DEVICE_IN_USB_HEADSET. When device restore happens, input
device selects AUDIO_DEVICE_IN_USB_HEADSET even if USB headset is not existed.
This causes mute issue happens.
Fix it by checking USB headset device state to select handset as input device
when USB headset is unplugged.
CRs-Fixed: 2264971
Change-Id: I69b2f0f030309a28256cf69330f85069994f3ea0
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 0618387..b4633d2 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -4284,7 +4284,7 @@
snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS;
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
- } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
+ } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
}
platform_set_echo_reference(adev, true, out_device);
@@ -4317,7 +4317,7 @@
snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
- } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
+ } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
}
platform_set_echo_reference(adev, true, out_device);
@@ -4672,7 +4672,7 @@
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
} else if (in_device & AUDIO_DEVICE_IN_FM_TUNER) {
snd_device = SND_DEVICE_IN_CAPTURE_FM;
- } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
+ } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
} else {
ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
@@ -4712,7 +4712,7 @@
} else if (out_device &
(AUDIO_DEVICE_OUT_USB_DEVICE |
AUDIO_DEVICE_OUT_USB_HEADSET)) {
- if (audio_extn_usb_is_capture_supported())
+ if (audio_extn_usb_is_capture_supported() && audio_extn_usb_connected(NULL))
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
else
snd_device = SND_DEVICE_IN_HANDSET_MIC;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
old mode 100644
new mode 100755
index 2de822e..876a501
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -4102,7 +4102,7 @@
snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS;
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
- } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
+ } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
}
platform_set_echo_reference(adev, true, out_device);
@@ -4139,7 +4139,7 @@
snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
} else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE;
- } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
+ } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
}
platform_set_echo_reference(adev, true, out_device);
@@ -4528,7 +4528,7 @@
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
} else if (in_device & AUDIO_DEVICE_IN_FM_TUNER) {
snd_device = SND_DEVICE_IN_CAPTURE_FM;
- } else if (audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
+ } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
} else {
ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
@@ -4576,7 +4576,7 @@
} else if (out_device &
(AUDIO_DEVICE_OUT_USB_DEVICE |
AUDIO_DEVICE_OUT_USB_HEADSET)) {
- if (audio_extn_usb_is_capture_supported())
+ if (audio_extn_usb_is_capture_supported() && audio_extn_usb_connected(NULL))
snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
else
snd_device = SND_DEVICE_IN_HANDSET_MIC;