hal: Fix incall recording calibration issue
For voice incall recording tx and rx usecase, calibration
is sent only once even though two recording sessions are
opened. Split the incall rec sound device and send the
calibration twice for tx and rx usecase.
CRs-Fixed: 2375699
Change-Id: Ib4e571296aefde2c8ff875d571e7110c73bb00ac
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 5233e5c..6ad5a60 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -3548,11 +3548,15 @@
int snd_device = SND_DEVICE_OUT_SPEAKER;
int new_snd_device[SND_DEVICE_OUT_END] = {0};
int i, num_devices = 1;
+ bool is_incall_rec_usecase = false;
+ snd_device_t incall_rec_device;
+
+ if (voice_is_in_call(my_data->adev))
+ is_incall_rec_usecase = voice_is_in_call_rec_stream(usecase->stream.in);
if (usecase->type == PCM_PLAYBACK)
snd_device = usecase->out_snd_device;
- else if ((usecase->type == PCM_CAPTURE) &&
- voice_is_in_call_rec_stream(usecase->stream.in))
+ else if ((usecase->type == PCM_CAPTURE) && is_incall_rec_usecase)
snd_device = voice_get_incall_rec_snd_device(usecase->in_snd_device);
else if ((usecase->type == PCM_HFP_CALL) || (usecase->type == PCM_CAPTURE))
snd_device = usecase->in_snd_device;
@@ -3561,13 +3565,25 @@
acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(snd_device)];
- if (platform_split_snd_device(platform, snd_device, &num_devices,
- new_snd_device) < 0) {
- new_snd_device[0] = snd_device;
+ if (!is_incall_rec_usecase) {
+ if (platform_split_snd_device(my_data, snd_device,
+ &num_devices, new_snd_device) < 0) {
+ new_snd_device[0] = snd_device;
+ }
+ } else {
+ incall_rec_device = voice_get_incall_rec_backend_device(usecase->stream.in);
+ if (platform_split_snd_device(my_data, incall_rec_device,
+ &num_devices, new_snd_device) < 0) {
+ new_snd_device[0] = snd_device;
+ }
}
for (i = 0; i < num_devices; i++) {
- acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(new_snd_device[i])];
+ if (!is_incall_rec_usecase)
+ acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(new_snd_device[i])];
+ else
+ // Use in_call_rec snd_device to extract the ACDB device ID instead of split snd devices
+ acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(snd_device)];
// Do not use Rx path default app type for TX path
if ((usecase->type == PCM_CAPTURE) && (app_type == DEFAULT_APP_TYPE_RX_PATH)) {
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 7b1f386..9b9e8e3 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3945,11 +3945,15 @@
int snd_device = SND_DEVICE_OUT_SPEAKER;
int new_snd_device[SND_DEVICE_OUT_END] = {0};
int i, num_devices = 1;
+ bool is_incall_rec_usecase = false;
+ snd_device_t incall_rec_device;
+
+ if (voice_is_in_call(my_data->adev))
+ is_incall_rec_usecase = voice_is_in_call_rec_stream(usecase->stream.in);
if (usecase->type == PCM_PLAYBACK)
snd_device = usecase->out_snd_device;
- else if ((usecase->type == PCM_CAPTURE) &&
- voice_is_in_call_rec_stream(usecase->stream.in))
+ else if ((usecase->type == PCM_CAPTURE) && is_incall_rec_usecase)
snd_device = voice_get_incall_rec_snd_device(usecase->in_snd_device);
else if ((usecase->type == PCM_HFP_CALL) || (usecase->type == PCM_CAPTURE))
snd_device = usecase->in_snd_device;
@@ -3963,13 +3967,25 @@
return -EINVAL;
}
- if (platform_split_snd_device(my_data, snd_device,
- &num_devices, new_snd_device) < 0) {
- new_snd_device[0] = snd_device;
+ if (!is_incall_rec_usecase) {
+ if (platform_split_snd_device(my_data, snd_device,
+ &num_devices, new_snd_device) < 0) {
+ new_snd_device[0] = snd_device;
+ }
+ } else {
+ incall_rec_device = voice_get_incall_rec_backend_device(usecase->stream.in);
+ if (platform_split_snd_device(my_data, incall_rec_device,
+ &num_devices, new_snd_device) < 0) {
+ new_snd_device[0] = snd_device;
+ }
}
for (i = 0; i < num_devices; i++) {
- acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(new_snd_device[i])];
+ if (!is_incall_rec_usecase)
+ acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(new_snd_device[i])];
+ else
+ // Use in_call_rec snd_device to extract the ACDB device ID instead of split snd devices
+ acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(snd_device)];
// Do not use Rx path default app type for TX path
if ((usecase->type == PCM_CAPTURE) && (app_type == DEFAULT_APP_TYPE_RX_PATH)) {
diff --git a/hal/voice.c b/hal/voice.c
index 26116c6..37ed33b 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -450,6 +450,11 @@
{
snd_device_t incall_record_device = {0};
+ if (!in) {
+ ALOGE("%s: input stream is NULL", __func__);
+ return 0;
+ }
+
switch(in->source) {
case AUDIO_SOURCE_VOICE_UPLINK:
incall_record_device = SND_DEVICE_IN_INCALL_REC_TX;