audio hal: add support for USB_HEADSET device
Add support for USB_HEADSET device in device selection logic where
only USB_DEVICE was supported so far.
Bug: 36220140
Test: check music/video playback, voice/VoIP calls, OK google and
Camcorder with and without USB headset
Change-Id: Ia1a241b9a9cdec6c48c0596a057fabac30b1b16f
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3ad965e..e5a8854 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1266,7 +1266,7 @@
/* Enable new sound devices */
if (out_snd_device != SND_DEVICE_NONE) {
if ((usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) ||
- (usecase->devices & AUDIO_DEVICE_OUT_USB_DEVICE))
+ (usecase->devices & (AUDIO_DEVICE_OUT_USB_DEVICE|AUDIO_DEVICE_OUT_USB_HEADSET)))
check_and_route_playback_usecases(adev, usecase, out_snd_device);
enable_snd_device(adev, out_snd_device);
}
@@ -3885,17 +3885,17 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value));
if (ret >= 0) {
audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10);
- if (device == AUDIO_DEVICE_OUT_USB_DEVICE) {
+ if (audio_is_usb_out_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_add_device(AUDIO_DEVICE_OUT_USB_DEVICE, card);
+ audio_extn_usb_add_device(device, card);
}
- } else if (device == AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_add_device(AUDIO_DEVICE_IN_USB_DEVICE, card);
+ audio_extn_usb_add_device(device, card);
}
}
}
@@ -3903,18 +3903,18 @@
ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, sizeof(value));
if (ret >= 0) {
audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10);
- if (device == AUDIO_DEVICE_OUT_USB_DEVICE) {
+ if (audio_is_usb_out_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_remove_device(AUDIO_DEVICE_OUT_USB_DEVICE, card);
+ audio_extn_usb_remove_device(device, card);
}
- } else if (device == AUDIO_DEVICE_IN_USB_DEVICE) {
+ } else if (audio_is_usb_in_device(device)) {
ret = str_parms_get_str(parms, "card", value, sizeof(value));
if (ret >= 0) {
const int card = atoi(value);
- audio_extn_usb_remove_device(AUDIO_DEVICE_IN_USB_DEVICE, card);
+ audio_extn_usb_remove_device(device, card);
}
}
}