hal: Fix WFD and voice call over USB concurrency
- If WFD framework occupies the AFE proxy, it may result unintended
behavior while starting voice call over USB.
- Audio is always routed to the USB audio device when connected,
even if WFD is connected. So no need to allow afe proxy port
usage by WFD framework.
- Disallow the afe proxy port usage by external modules when
AUDIO_DEVICE_OUT_USB_DEVICE is connected.
CRs-Fixed: 998488
Change-Id: I889be7f477ae3f7ad46757592a46f3d0e8eb41e2
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index db91b51..200cbeb 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -553,7 +553,7 @@
#ifndef AFE_PROXY_ENABLED
#define audio_extn_set_afe_proxy_parameters(adev, parms) (0)
-#define audio_extn_get_afe_proxy_parameters(query, reply) (0)
+#define audio_extn_get_afe_proxy_parameters(adev, query, reply) (0)
#else
static int32_t afe_proxy_set_channel_mapping(struct audio_device *adev,
int channel_count)
@@ -667,23 +667,25 @@
}
}
-int audio_extn_get_afe_proxy_parameters(struct str_parms *query,
+int audio_extn_get_afe_proxy_parameters(const struct audio_device *adev,
+ struct str_parms *query,
struct str_parms *reply)
{
- int ret, val;
+ int ret, val = 0;
char value[32]={0};
char *str = NULL;
ret = str_parms_get_str(query, AUDIO_PARAMETER_CAN_OPEN_PROXY, value,
sizeof(value));
if (ret >= 0) {
- if (audio_extn_usb_is_proxy_inuse())
+ if (audio_extn_usb_is_proxy_inuse() ||
+ !adev->allow_afe_proxy_usage)
val = 0;
else
val = 1;
str_parms_add_int(reply, AUDIO_PARAMETER_CAN_OPEN_PROXY, val);
}
-
+ ALOGV("%s: called ... can_use_proxy %d", __func__, val);
return 0;
}
@@ -775,7 +777,7 @@
struct str_parms *reply)
{
char *kv_pairs = NULL;
- audio_extn_get_afe_proxy_parameters(query, reply);
+ audio_extn_get_afe_proxy_parameters(adev, query, reply);
audio_extn_get_fluence_parameters(adev, query, reply);
audio_extn_ssr_get_parameters(adev, query, reply);
get_active_offload_usecases(adev, query, reply);
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 2489471..65b1ab6 100755
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3528,6 +3528,16 @@
if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
ALOGV("cache new edid");
platform_cache_edid(adev->platform);
+ } else if (val & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ /*
+ * Do not allow AFE proxy port usage by WFD source when USB headset is connected.
+ * Per AudioPolicyManager, USB device is higher priority than WFD.
+ * For Voice call over USB headset, voice call audio is routed to AFE proxy ports.
+ * If WFD use case occupies AFE proxy, it may result unintended behavior while
+ * starting voice call on USB
+ */
+ ALOGV("detected USB connect .. disable proxy");
+ adev->allow_afe_proxy_usage = false;
}
}
@@ -3537,6 +3547,9 @@
if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
ALOGV("invalidate cached edid");
platform_invalidate_edid(adev->platform);
+ } else if (val & AUDIO_DEVICE_OUT_USB_DEVICE) {
+ ALOGV("detected USB disconnect .. enable proxy");
+ adev->allow_afe_proxy_usage = true;
}
}
@@ -3961,6 +3974,7 @@
adev->out_device = AUDIO_DEVICE_NONE;
adev->bluetooth_nrec = true;
adev->acdb_settings = TTY_MODE_OFF;
+ adev->allow_afe_proxy_usage = true;
/* adev->cur_hdmi_channels = 0; by calloc() */
adev->snd_dev_ref_cnt = calloc(SND_DEVICE_MAX, sizeof(int));
voice_init(adev);
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index a7d4483..e13415d 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -323,6 +323,7 @@
unsigned int cur_hdmi_channels;
unsigned int cur_wfd_channels;
bool bt_wb_speech_enabled;
+ bool allow_afe_proxy_usage;
int snd_card;
unsigned int cur_codec_backend_samplerate;