hal: speaker swap: fix pause rotation issue
- on pause, rotation is getting reset
- root cause is the time mixer control for rotation is send
backend is not active hence set doesn't work
- fix this by explicitly call set \ un-set based on usecase
Bug: 62337071
Test: verify audio rotation on angler and wahoo, build test for msm8960
and msm8916
Change-Id: I944c5299d55a2bb6ef91ac7d74e60bf9014b5512
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c616221..b885841 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -680,9 +680,15 @@
if (adev->snd_dev_ref_cnt[snd_device] == 0) {
audio_extn_dsm_feedback_enable(adev, snd_device, false);
if ((snd_device == SND_DEVICE_OUT_SPEAKER ||
+ snd_device == SND_DEVICE_OUT_SPEAKER_REVERSE ||
snd_device == SND_DEVICE_OUT_VOICE_SPEAKER) &&
audio_extn_spkr_prot_is_enabled()) {
audio_extn_spkr_prot_stop_processing(snd_device);
+
+ // when speaker device is disabled, reset swap.
+ // will be renabled on usecase start
+ platform_set_swap_channels(adev, false);
+
} else if (platform_can_split_snd_device(snd_device,
&num_devices,
new_snd_devices) == 0) {
@@ -1871,6 +1877,14 @@
audio_extn_utils_send_app_type_gain(out->dev,
out->app_type_cfg.app_type,
&out->app_type_cfg.gain[0]);
+
+ // consider a scenario where on pause lower layers are tear down.
+ // so on resume, swap mixer control need to be sent only when
+ // backend is active, hence rather than sending from enable device
+ // sending it from start of streamtream
+
+ platform_set_swap_channels(adev, true);
+
ALOGV("%s: exit", __func__);
return 0;
error_open:
@@ -2192,6 +2206,12 @@
}
select_devices(adev, out->usecase);
audio_extn_tfa_98xx_update();
+
+ // on device switch force swap, lower functions will make sure
+ // to check if swap is allowed or not.
+
+ if (!same_dev)
+ platform_set_swap_channels(adev, true);
}
}
@@ -3904,7 +3924,10 @@
status = -EINVAL;
}
if (status == 0) {
- platform_swap_lr_channels(adev, reverse_speakers);
+ // check and set swap
+ // - check if orientation changed and speaker active
+ // - set rotation and cache the rotation value
+ platform_check_and_set_swap_lr_channels(adev, reverse_speakers);
}
}