summaryrefslogtreecommitdiffstats
path: root/media/libeffects
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-10-31 18:48:15 -0700
committerEric Laurent <elaurent@google.com>2011-11-01 09:12:19 -0700
commitb6431802fc6cff501a4311de288ba469839fbf86 (patch)
tree596a877457ca1b1a6e1eb6e5c547a4cb0dcbc67d /media/libeffects
parent841fa37451fb74f3d5978a15aab606bbb67e8c39 (diff)
downloadframeworks_av-b6431802fc6cff501a4311de288ba469839fbf86.zip
frameworks_av-b6431802fc6cff501a4311de288ba469839fbf86.tar.gz
frameworks_av-b6431802fc6cff501a4311de288ba469839fbf86.tar.bz2
Fix device management in lvm effect bundle wrapper.
The virtualizer and bass boost effects should be disabled when not playing throught headsets or headphones. There is a bug in current wrapper implementation that makes that those effects are not disabled if the effect is enabled by the user after the headset has been removed (current logic only works if the device selection occurs while the effect is enabled). Change-Id: I7c66b15a0339d95fb9ed13c8320d66379725d3b6
Diffstat (limited to 'media/libeffects')
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index efa1c45..270f6c1 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -2459,6 +2459,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
LOGV("\tEffect_setEnabled() type %d, enabled %d", pContext->EffectType, enabled);
if (enabled) {
+ // Bass boost or Virtualizer can be temporarily disabled if playing over device speaker due
+ // to their nature.
+ bool tempDisabled = false;
switch (pContext->EffectType) {
case LVM_BASS_BOOST:
if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
@@ -2471,6 +2474,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
pContext->pBundledContext->SamplesToExitCountBb =
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
pContext->pBundledContext->bBassEnabled = LVM_TRUE;
+ tempDisabled = pContext->pBundledContext->bBassTempDisabled;
break;
case LVM_EQUALIZER:
if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) {
@@ -2495,6 +2499,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
pContext->pBundledContext->SamplesToExitCountVirt =
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
pContext->pBundledContext->bVirtualizerEnabled = LVM_TRUE;
+ tempDisabled = pContext->pBundledContext->bVirtualizerTempDisabled;
break;
case LVM_VOLUME:
if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE) {
@@ -2508,7 +2513,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
LOGV("\tEffect_setEnabled() invalid effect type");
return -EINVAL;
}
- LvmEffect_enable(pContext);
+ if (!tempDisabled) {
+ LvmEffect_enable(pContext);
+ }
} else {
switch (pContext->EffectType) {
case LVM_BASS_BOOST:
@@ -3047,9 +3054,10 @@ int Effect_command(effect_handle_t self,
LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE start");
uint32_t device = *(uint32_t *)pCmdData;
- if(pContext->EffectType == LVM_BASS_BOOST){
- if((device == AUDIO_DEVICE_OUT_SPEAKER)||(device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)||
- (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
+ if (pContext->EffectType == LVM_BASS_BOOST) {
+ if((device == AUDIO_DEVICE_OUT_SPEAKER) ||
+ (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) ||
+ (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d",
*(int32_t *)pCmdData);
LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST");
@@ -3058,30 +3066,31 @@ int Effect_command(effect_handle_t self,
// the effect must still report its original state as this can only be changed
// by the ENABLE/DISABLE command
- if(pContext->pBundledContext->bBassEnabled == LVM_TRUE){
+ if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_BASS_BOOST %d",
*(int32_t *)pCmdData);
android::LvmEffect_disable(pContext);
- pContext->pBundledContext->bBassTempDisabled = LVM_TRUE;
}
- }else{
+ pContext->pBundledContext->bBassTempDisabled = LVM_TRUE;
+ } else {
LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_BASS_BOOST %d",
*(int32_t *)pCmdData);
// If a device supports bassboost and the effect has been temporarily disabled
// previously then re-enable it
- if(pContext->pBundledContext->bBassTempDisabled == LVM_TRUE){
+ if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_BASS_BOOST %d",
*(int32_t *)pCmdData);
android::LvmEffect_enable(pContext);
- pContext->pBundledContext->bBassTempDisabled = LVM_FALSE;
}
+ pContext->pBundledContext->bBassTempDisabled = LVM_FALSE;
}
}
- if(pContext->EffectType == LVM_VIRTUALIZER){
- if((device == AUDIO_DEVICE_OUT_SPEAKER)||(device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)||
- (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
+ if (pContext->EffectType == LVM_VIRTUALIZER) {
+ if((device == AUDIO_DEVICE_OUT_SPEAKER)||
+ (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT)||
+ (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
LOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_VIRTUALIZER %d",
*(int32_t *)pCmdData);
LOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_VIRTUALIZER");
@@ -3090,25 +3099,25 @@ int Effect_command(effect_handle_t self,
// the effect must still report its original state as this can only be changed
// by the ENABLE/DISABLE command
- if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){
+ if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) {
LOGV("\tEFFECT_CMD_SET_DEVICE disable LVM_VIRTUALIZER %d",
*(int32_t *)pCmdData);
android::LvmEffect_disable(pContext);
- pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE;
}
- }else{
+ pContext->pBundledContext->bVirtualizerTempDisabled = LVM_TRUE;
+ } else {
LOGV("\tEFFECT_CMD_SET_DEVICE device is valid for LVM_VIRTUALIZER %d",
*(int32_t *)pCmdData);
// If a device supports virtualizer and the effect has been temporarily disabled
// previously then re-enable it
- if(pContext->pBundledContext->bVirtualizerTempDisabled == LVM_TRUE){
+ if(pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE){
LOGV("\tEFFECT_CMD_SET_DEVICE re-enable LVM_VIRTUALIZER %d",
*(int32_t *)pCmdData);
android::LvmEffect_enable(pContext);
- pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
}
+ pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
}
}
LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_DEVICE end");