summaryrefslogtreecommitdiffstats
path: root/media/libeffects/lvm
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2011-10-31 17:36:03 -0700
committerEric Laurent <elaurent@google.com>2011-11-02 09:14:13 -0700
commit5dc65e2ce92c7364da60bdff5f345daf145c2c0f (patch)
tree90ed0dc7e58b08a673b19a7b72676ba4c9630b70 /media/libeffects/lvm
parent09ebde724b2cd224968d1fdba4f5afd81c998c6a (diff)
downloadframeworks_av-5dc65e2ce92c7364da60bdff5f345daf145c2c0f.zip
frameworks_av-5dc65e2ce92c7364da60bdff5f345daf145c2c0f.tar.gz
frameworks_av-5dc65e2ce92c7364da60bdff5f345daf145c2c0f.tar.bz2
Fix problem in lvm effect bundle wrapper.
When an effect is disabled, the process function should either copy or accumulate the content of the input buffer to the output buffer depending on the behavior requested by the framework. Current implementation is copying the input buffer unconditionally. Related to issue 5433942. Change-Id: Ic488ca97eadcc4c763de570d7e6c6f5b7a979415
Diffstat (limited to 'media/libeffects/lvm')
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index efa1c45..fb48c51 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -49,6 +49,16 @@ extern "C" const struct effect_interface_s gLvmEffectInterface;
}\
}
+
+static inline int16_t clamp16(int32_t sample)
+{
+ // check overflow for both positive and negative values:
+ // all bits above short range must me equal to sign bit
+ if ((sample>>15) ^ (sample>>31))
+ sample = 0x7FFF ^ (sample>>31);
+ return sample;
+}
+
// Namespaces
namespace android {
namespace {
@@ -707,13 +717,6 @@ int LvmBundle_init(EffectContext *pContext){
} /* end LvmBundle_init */
-static inline int16_t clamp16(int32_t sample)
-{
- if ((sample>>15) ^ (sample>>31))
- sample = 0x7FFF ^ (sample>>31);
- return sample;
-}
-
//----------------------------------------------------------------------------
// LvmBundle_process()
//----------------------------------------------------------------------------
@@ -2683,12 +2686,19 @@ int Effect_process(effect_handle_t self,
LOGV("\tLVM_ERROR : LvmBundle_process returned error %d", lvmStatus);
return lvmStatus;
}
- }else{
+ } else {
//LOGV("\tEffect_process Not Calling process with %d effects enabled, %d called: Effect %d",
//pContext->pBundledContext->NumberEffectsEnabled,
//pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
// 2 is for stereo input
- memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2);
+ if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE) {
+ for (size_t i=0; i < outBuffer->frameCount*2; i++){
+ outBuffer->s16[i] =
+ clamp16((LVM_INT32)outBuffer->s16[i] + (LVM_INT32)inBuffer->s16[i]);
+ }
+ } else {
+ memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2);
+ }
}
return status;