Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93f6ba45 authored by Eric Laurent's avatar Eric Laurent Committed by Android Git Automerger
Browse files

am 79178b8b: Merge "Fix problem in lvm effect bundle wrapper." into ics-mr1

* commit '79178b8b3da8f69f34a72be13f2a374afbec4f40':
  Fix problem in lvm effect bundle wrapper.
parents f8bbc7a0 047f1605
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -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()
//----------------------------------------------------------------------------
@@ -2688,8 +2691,15 @@ int Effect_process(effect_handle_t self,
        //pContext->pBundledContext->NumberEffectsEnabled,
        //pContext->pBundledContext->NumberEffectsCalled, pContext->EffectType);
        // 2 is for stereo input
        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;
}   /* end Effect_process */