hal: avoid using voip sound device with different backends
When selecting device for playback usecase with voip usecase active,
voip sound device will be selected if sound device of usecase share
same backend defined by AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND. However,
on some platforms, devices in AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND
actually use different backends, and sound devices will be wrongly
selected for playback usecase if voip sound device is updated later
than playback sound device.
Use platform_check_backends_match to check backends match before
using voip sound device for other usecases.
Change-Id: I8914323d6fb20498a96a0a6fe6fa5b5adbd5906b
CRs-Fixed: 2035597
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index a42158e..64db961 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1522,10 +1522,19 @@
out_snd_device = vc_usecase->out_snd_device;
}
} else if (voice_extn_compress_voip_is_active(adev)) {
+ bool out_snd_device_backend_match = true;
+ if (usecase->stream.out != NULL) {
+ out_snd_device_backend_match = platform_check_backends_match(
+ voip_usecase->out_snd_device,
+ platform_get_output_snd_device(
+ adev->platform,
+ usecase->stream.out));
+ }
voip_usecase = get_usecase_from_list(adev, USECASE_COMPRESS_VOIP_CALL);
if ((voip_usecase) && ((voip_usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) &&
((usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND) ||
((usecase->devices & ~AUDIO_DEVICE_BIT_IN) & AUDIO_DEVICE_IN_ALL_CODEC_BACKEND)) &&
+ out_snd_device_backend_match &&
(voip_usecase->stream.out != adev->primary_output))) {
in_snd_device = voip_usecase->in_snd_device;
out_snd_device = voip_usecase->out_snd_device;