post_proc: Fix bassboost/virtualizer not disabled on speaker
When output is unintended device, there's no need to query enable_flag
before setting effect to disabled state. There's possiblity that
enable_flag is 0 as initialized value, which hinder effects from being
disabled.
Change-Id: Ib90c0ad0982dc8274129bb1bed7861e11670fbdb
diff --git a/post_proc/bass_boost.c b/post_proc/bass_boost.c
index 1c96280..e2c6d9a 100644
--- a/post_proc/bass_boost.c
+++ b/post_proc/bass_boost.c
@@ -158,24 +158,27 @@
(device == AUDIO_DEVICE_OUT_AUX_DIGITAL) ||
(device == AUDIO_DEVICE_OUT_USB_ACCESSORY) ||
(device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) {
- if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) {
- offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false);
+ if (!bass_ctxt->temp_disabled) {
+ if (effect_is_active(&bass_ctxt->common)) {
+ offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false);
+ if (bass_ctxt->ctl)
+ offload_bassboost_send_params(bass_ctxt->ctl,
+ bass_ctxt->offload_bass,
+ OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
+ }
bass_ctxt->temp_disabled = true;
- if (bass_ctxt->ctl)
- offload_bassboost_send_params(bass_ctxt->ctl,
- bass_ctxt->offload_bass,
- OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
- ALOGI("%s: ctxt %p, disabled based on device", __func__, bass_ctxt);
}
+ ALOGI("%s: ctxt %p, disabled based on device", __func__, bass_ctxt);
} else {
- if (!offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)) &&
- bass_ctxt->temp_disabled) {
- offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true);
+ if (bass_ctxt->temp_disabled) {
+ if (effect_is_active(&bass_ctxt->common)) {
+ offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true);
+ if (bass_ctxt->ctl)
+ offload_bassboost_send_params(bass_ctxt->ctl,
+ bass_ctxt->offload_bass,
+ OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
+ }
bass_ctxt->temp_disabled = false;
- if (bass_ctxt->ctl)
- offload_bassboost_send_params(bass_ctxt->ctl,
- bass_ctxt->offload_bass,
- OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG);
}
}
offload_bassboost_set_device(&(bass_ctxt->offload_bass), device);