summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwjiang <wjiang@codeaurora.org>2014-04-29 15:52:44 +0800
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:24:27 -0600
commitab9bb1594982ad1affed948711d6f487e1c90271 (patch)
tree20b3dad3e645af300df3a055b24ecd93d7a62959
parent20f360507591a3802dd40aa37888c12714118025 (diff)
downloadframeworks_av-ab9bb1594982ad1affed948711d6f487e1c90271.zip
frameworks_av-ab9bb1594982ad1affed948711d6f487e1c90271.tar.gz
frameworks_av-ab9bb1594982ad1affed948711d6f487e1c90271.tar.bz2
libeffect: Fix enabled effect count calculation error
When switching from tunnel to arm effects, effect chain will be moved from offload thread to mixer thread. During this procedure effect instance is not destroyed, instead it's preserved and mounted onto new chain. The migrant sequence is 1) disable instance -> 2) move to new effect chain -> 3) enable instance again. However, the accumulated effect enabled count is not decreased when effect instance is disabled. As a result, LvmBundle_process() is only called once when Effect_process() called twice, which causes input buffer get processed alternately and glitch sound appears. Change-Id: Idd3b8753a73694cc36617ed55b40fda93155abed CRs-Fixed: 636353
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp52
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.h2
2 files changed, 32 insertions, 22 deletions
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index af904a6..ad7ca4a 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -226,7 +226,7 @@ extern "C" int EffectCreate(const effect_uuid_t *uuid,
pContext->pBundledContext->bVirtualizerTempDisabled = LVM_FALSE;
pContext->pBundledContext->nOutputDevice = AUDIO_DEVICE_NONE;
pContext->pBundledContext->nVirtualizerForcedDevice = AUDIO_DEVICE_NONE;
- pContext->pBundledContext->NumberEffectsEnabled = 0;
+ pContext->pBundledContext->EffectsBitMap = 0;
pContext->pBundledContext->NumberEffectsCalled = 0;
pContext->pBundledContext->firstVolume = LVM_TRUE;
pContext->pBundledContext->volume = 0;
@@ -366,28 +366,28 @@ extern "C" int EffectRelease(effect_handle_t handle){
ALOGV("\tEffectRelease LVM_BASS_BOOST Clearing global intstantiated flag");
pSessionContext->bBassInstantiated = LVM_FALSE;
if(pContext->pBundledContext->SamplesToExitCountBb > 0){
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_BASS_BOOST);
}
pContext->pBundledContext->SamplesToExitCountBb = 0;
} else if(pContext->EffectType == LVM_VIRTUALIZER) {
ALOGV("\tEffectRelease LVM_VIRTUALIZER Clearing global intstantiated flag");
pSessionContext->bVirtualizerInstantiated = LVM_FALSE;
if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VIRTUALIZER);
}
pContext->pBundledContext->SamplesToExitCountVirt = 0;
} else if(pContext->EffectType == LVM_EQUALIZER) {
ALOGV("\tEffectRelease LVM_EQUALIZER Clearing global intstantiated flag");
pSessionContext->bEqualizerInstantiated =LVM_FALSE;
if(pContext->pBundledContext->SamplesToExitCountEq > 0){
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_EQUALIZER);
}
pContext->pBundledContext->SamplesToExitCountEq = 0;
} else if(pContext->EffectType == LVM_VOLUME) {
ALOGV("\tEffectRelease LVM_VOLUME Clearing global intstantiated flag");
pSessionContext->bVolumeInstantiated = LVM_FALSE;
if (pContext->pBundledContext->bVolumeEnabled == LVM_TRUE){
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VOLUME);
}
} else {
ALOGV("\tLVM_ERROR : EffectRelease : Unsupported effect\n\n\n\n\n\n\n");
@@ -2753,7 +2753,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
return -EINVAL;
}
if(pContext->pBundledContext->SamplesToExitCountBb <= 0){
- pContext->pBundledContext->NumberEffectsEnabled++;
+ pContext->pBundledContext->EffectsBitMap |= (1 << LVM_BASS_BOOST);
}
pContext->pBundledContext->SamplesToExitCountBb =
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
@@ -2766,7 +2766,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
return -EINVAL;
}
if(pContext->pBundledContext->SamplesToExitCountEq <= 0){
- pContext->pBundledContext->NumberEffectsEnabled++;
+ pContext->pBundledContext->EffectsBitMap |= (1 << LVM_EQUALIZER);
}
pContext->pBundledContext->SamplesToExitCountEq =
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
@@ -2778,7 +2778,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
return -EINVAL;
}
if(pContext->pBundledContext->SamplesToExitCountVirt <= 0){
- pContext->pBundledContext->NumberEffectsEnabled++;
+ pContext->pBundledContext->EffectsBitMap |= (1 << LVM_VIRTUALIZER);
}
pContext->pBundledContext->SamplesToExitCountVirt =
(LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*0.1);
@@ -2790,7 +2790,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
ALOGV("\tEffect_setEnabled() LVM_VOLUME is already enabled");
return -EINVAL;
}
- pContext->pBundledContext->NumberEffectsEnabled++;
+ pContext->pBundledContext->EffectsBitMap |= (1 << LVM_VOLUME);
pContext->pBundledContext->bVolumeEnabled = LVM_TRUE;
break;
default:
@@ -2807,6 +2807,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
ALOGV("\tEffect_setEnabled() LVM_BASS_BOOST is already disabled");
return -EINVAL;
}
+ if(pContext->pBundledContext->SamplesToExitCountBb <= 0) {
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_BASS_BOOST);
+ }
pContext->pBundledContext->bBassEnabled = LVM_FALSE;
break;
case LVM_EQUALIZER:
@@ -2814,6 +2817,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
ALOGV("\tEffect_setEnabled() LVM_EQUALIZER is already disabled");
return -EINVAL;
}
+ if(pContext->pBundledContext->SamplesToExitCountEq <= 0) {
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_EQUALIZER);
+ }
pContext->pBundledContext->bEqualizerEnabled = LVM_FALSE;
break;
case LVM_VIRTUALIZER:
@@ -2821,6 +2827,9 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
ALOGV("\tEffect_setEnabled() LVM_VIRTUALIZER is already disabled");
return -EINVAL;
}
+ if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) {
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VIRTUALIZER);
+ }
pContext->pBundledContext->bVirtualizerEnabled = LVM_FALSE;
break;
case LVM_VOLUME:
@@ -2828,6 +2837,7 @@ int Effect_setEnabled(EffectContext *pContext, bool enabled)
ALOGV("\tEffect_setEnabled() LVM_VOLUME is already disabled");
return -EINVAL;
}
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VOLUME);
pContext->pBundledContext->bVolumeEnabled = LVM_FALSE;
break;
default:
@@ -2877,7 +2887,7 @@ int Effect_process(effect_handle_t self,
LVM_INT16 *out = (LVM_INT16 *)outBuffer->raw;
//ALOGV("\tEffect_process Start : Enabled = %d Called = %d (%8d %8d %8d)",
-//pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled,
+//popcount(pContext->pBundledContext->EffectsBitMap), pContext->pBundledContext->NumberEffectsCalled,
// pContext->pBundledContext->SamplesToExitCountBb,
// pContext->pBundledContext->SamplesToExitCountVirt,
// pContext->pBundledContext->SamplesToExitCountEq);
@@ -2911,7 +2921,7 @@ int Effect_process(effect_handle_t self,
}
if(pContext->pBundledContext->SamplesToExitCountBb <= 0) {
status = -ENODATA;
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_BASS_BOOST);
ALOGV("\tEffect_process() this is the last frame for LVM_BASS_BOOST");
}
}
@@ -2919,7 +2929,7 @@ int Effect_process(effect_handle_t self,
(pContext->EffectType == LVM_VOLUME)){
//ALOGV("\tEffect_process() LVM_VOLUME Effect is not enabled");
status = -ENODATA;
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VOLUME);
}
if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&&
(pContext->EffectType == LVM_EQUALIZER)){
@@ -2931,7 +2941,7 @@ int Effect_process(effect_handle_t self,
}
if(pContext->pBundledContext->SamplesToExitCountEq <= 0) {
status = -ENODATA;
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_EQUALIZER);
ALOGV("\tEffect_process() this is the last frame for LVM_EQUALIZER");
}
}
@@ -2945,7 +2955,7 @@ int Effect_process(effect_handle_t self,
}
if(pContext->pBundledContext->SamplesToExitCountVirt <= 0) {
status = -ENODATA;
- pContext->pBundledContext->NumberEffectsEnabled--;
+ pContext->pBundledContext->EffectsBitMap &= ~(1 << LVM_VIRTUALIZER);
ALOGV("\tEffect_process() this is the last frame for LVM_VIRTUALIZER");
}
}
@@ -2955,9 +2965,9 @@ int Effect_process(effect_handle_t self,
}
if(pContext->pBundledContext->NumberEffectsCalled ==
- pContext->pBundledContext->NumberEffectsEnabled){
+ popcount(pContext->pBundledContext->EffectsBitMap)){
//ALOGV("\tEffect_process Calling process with %d effects enabled, %d called: Effect %d",
- //pContext->pBundledContext->NumberEffectsEnabled,
+ //popcount(pContext->pBundledContext->EffectsBitMap),
//pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
if(status == -ENODATA){
@@ -2976,7 +2986,7 @@ int Effect_process(effect_handle_t self,
}
} else {
//ALOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d",
- //pContext->pBundledContext->NumberEffectsEnabled,
+ //popcount(pContext->pBundledContext->EffectsBitMap),
//pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
// 2 is for stereo input
if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) {
@@ -3028,9 +3038,9 @@ int Effect_command(effect_handle_t self,
// called the number of effect called could be greater
// pContext->pBundledContext->NumberEffectsCalled = 0;
- //ALOGV("\tEffect_command NumberEffectsCalled = %d, NumberEffectsEnabled = %d",
- // pContext->pBundledContext->NumberEffectsCalled,
- // pContext->pBundledContext->NumberEffectsEnabled);
+ //ALOGV("\tEffect_command: Enabled = %d Called = %d",
+ // popcount(pContext->pBundledContext->EffectsBitMap),
+ // pContext->pBundledContext->NumberEffectsCalled);
switch (cmdCode){
case EFFECT_CMD_INIT:
@@ -3311,7 +3321,7 @@ int Effect_command(effect_handle_t self,
(device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)){
ALOGV("\tEFFECT_CMD_SET_DEVICE device is invalid for LVM_BASS_BOOST %d",
*(int32_t *)pCmdData);
- ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BAS_BOOST");
+ ALOGV("\tEFFECT_CMD_SET_DEVICE temporary disable LVM_BASS_BOOST");
// If a device doesnt support bassboost the effect must be temporarily disabled
// the effect must still report its original state as this can only be changed
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
index 9459b87..5fa5668 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -75,8 +75,8 @@ struct BundledEffectContext{
bool bVirtualizerTempDisabled; /* Flag for effect to be re-enabled */
audio_devices_t nOutputDevice; /* Output device for the effect */
audio_devices_t nVirtualizerForcedDevice; /* Forced device virtualization mode*/
- int NumberEffectsEnabled; /* Effects in this session */
int NumberEffectsCalled; /* Effects called so far */
+ uint32_t EffectsBitMap; /* Effects enable bit mask */
bool firstVolume; /* No smoothing on first Vol change */
// Saved parameters for each effect */
// Bass Boost