LVM release 1.05 delivery

- Click have been removed from the HP filter activation in the BassBosst Effect.
- SessionId is now stored as a SessionNo
- Effects now stop being called after a delay
- Unix EOL fixed for .java and .xml
- Updated lines limited to 100 characters.
- Removed the remaining warnings from the wrapper code
- Added reverb

Change-Id: I03a2b3b5ee2286958f4901acc8d9b0daf9e2d7c6
diff --git a/media/libeffects/lvm/lib/Android.mk b/media/libeffects/lvm/lib/Android.mk
index a944212..ff34707 100644
--- a/media/libeffects/lvm/lib/Android.mk
+++ b/media/libeffects/lvm/lib/Android.mk
@@ -122,3 +122,58 @@
     $(LOCAL_PATH)/StereoWidening/lib
 
 include $(BUILD_STATIC_LIBRARY)
+
+# Reverb library
+include $(CLEAR_VARS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES:= \
+    Reverb/src/LVREV_ApplyNewSettings.c \
+    Reverb/src/LVREV_ClearAudioBuffers.c \
+    Reverb/src/LVREV_GetControlParameters.c \
+    Reverb/src/LVREV_GetInstanceHandle.c \
+    Reverb/src/LVREV_GetMemoryTable.c \
+    Reverb/src/LVREV_Process.c \
+    Reverb/src/LVREV_SetControlParameters.c \
+    Reverb/src/LVREV_Tables.c \
+    Common/src/Abs_32.c \
+    Common/src/InstAlloc.c \
+    Common/src/LoadConst_16.c \
+    Common/src/LoadConst_32.c \
+    Common/src/From2iToMono_32.c \
+    Common/src/Mult3s_32x16.c \
+    Common/src/FO_1I_D32F32C31_TRC_WRA_01.c \
+    Common/src/FO_1I_D32F32Cll_TRC_WRA_01_Init.c \
+    Common/src/DelayAllPass_Sat_32x16To32.c \
+    Common/src/Copy_16.c \
+    Common/src/Mac3s_Sat_32x16.c \
+    Common/src/DelayWrite_32.c \
+    Common/src/Shift_Sat_v32xv32.c \
+    Common/src/Add2_Sat_32x32.c \
+    Common/src/JoinTo2i_32x32.c \
+    Common/src/MonoTo2I_32.c \
+    Common/src/LVM_FO_HPF.c \
+    Common/src/LVM_FO_LPF.c \
+    Common/src/LVM_Polynomial.c \
+    Common/src/LVM_Power10.c \
+    Common/src/LVM_GetOmega.c \
+    Common/src/MixSoft_2St_D32C31_SAT.c \
+    Common/src/MixSoft_1St_D32C31_WRA.c \
+    Common/src/MixInSoft_D32C31_SAT.c \
+    Common/src/LVM_Mixer_TimeConstant.c \
+    Common/src/Core_MixHard_2St_D32C31_SAT.c \
+    Common/src/Core_MixSoft_1St_D32C31_WRA.c \
+    Common/src/Core_MixInSoft_D32C31_SAT.c
+
+LOCAL_MODULE:= libreverb
+
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_C_INCLUDES += \
+    $(LOCAL_PATH)/Reverb/lib \
+    $(LOCAL_PATH)/Reverb/src \
+    $(LOCAL_PATH)/Common/lib \
+    $(LOCAL_PATH)/Common/src
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
index 8cf84b7..4a9dc72 100755
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Control.c
@@ -17,9 +17,9 @@
 
 /****************************************************************************************
 
-     $Author: nxp007753 $
-     $Revision: 1315 $
-     $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
+     $Author: beq06068 $
+     $Revision: 1401 $
+     $Date: 2010-08-03 09:52:22 +0200 (Tue, 03 Aug 2010) $
 
 *****************************************************************************************/
 
@@ -128,7 +128,7 @@
                  (void *)&pInstance->pData->HPFTaps,                /* Destination Cast to void: \
                                                                      no dereferencing in function*/
                  sizeof(pInstance->pData->HPFTaps)/sizeof(LVM_INT16));   /* Number of words */
-    BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance,      /* Initialise the filter */
+    BQ_2I_D32F32Cll_TRC_WRA_01_Init(&pInstance->pCoef->HPFInstance,         /* Initialise the filter */
                                     &pInstance->pData->HPFTaps,
                                     (BQ_C32_Coefs_t *)&LVDBE_HPF_Table[Offset]);
 
@@ -140,7 +140,7 @@
                  (void *)&pInstance->pData->BPFTaps,                /* Destination Cast to void:\
                                                                      no dereferencing in function*/
                  sizeof(pInstance->pData->BPFTaps)/sizeof(LVM_INT16));   /* Number of words */
-    BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance,      /* Initialise the filter */
+    BP_1I_D32F32Cll_TRC_WRA_02_Init(&pInstance->pCoef->BPFInstance,         /* Initialise the filter */
                                     &pInstance->pData->BPFTaps,
                                     (BP_C32_Coefs_t *)&LVDBE_BPF_Table[Offset]);
 
@@ -317,6 +317,7 @@
 {
 
     LVDBE_Instance_t    *pInstance =(LVDBE_Instance_t  *)hInstance;
+    LVMixer3_2St_st     *pBypassMixer_Instance = &pInstance->pData->BypassMixer;
 
 
     /*
@@ -339,6 +340,14 @@
     {
         LVDBE_SetAGC(pInstance,                         /* Instance pointer */
                      pParams);                          /* New parameters */
+
+        LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[0],
+            LVDBE_BYPASS_MIXER_TC,pParams->SampleRate,2);
+
+        LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[1],
+            LVDBE_BYPASS_MIXER_TC,pParams->SampleRate,2);
+
+
     }
 
 
@@ -356,17 +365,13 @@
 
     if (pInstance->Params.OperatingMode==LVDBE_ON && pParams->OperatingMode==LVDBE_OFF)
     {
-        LVDBE_Params_t  Params  = *pParams;             /* make local copy of params */
-        Params.EffectLevel      = 0;                    /* zero effect level before switching off module*/
-        pInstance->bTransitionOnToOff  = LVM_TRUE;             /* Set the CallBack */
-        LVDBE_SetAGC(pInstance,                         /* Instance pointer */
-                     &Params);                          /* New parameters */
+        LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[0],0);
+        LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[1],0x00007FFF);
     }
     if (pInstance->Params.OperatingMode==LVDBE_OFF && pParams->OperatingMode==LVDBE_ON)
     {
-        pInstance->bTransitionOnToOff  = LVM_FALSE;     /* Set the CallBack */
-        LVDBE_SetAGC(pInstance,                         /* Instance pointer */
-                     pParams);                          /* New parameters */
+        LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[0],0x00007FFF);
+        LVC_Mixer_SetTarget(&pInstance->pData->BypassMixer.MixerStream[1],0);
     }
 
     /*
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
index 75869c7..95c421d 100755
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
@@ -17,9 +17,9 @@
 
 /****************************************************************************************
 
-     $Author: nxp007753 $
-     $Revision: 1081 $
-     $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+     $Author: beq06068 $
+     $Revision: 1399 $
+     $Date: 2010-08-03 08:16:00 +0200 (Tue, 03 Aug 2010) $
 
 *****************************************************************************************/
 
@@ -160,6 +160,7 @@
 
     LVDBE_Instance_t      *pInstance;
     LVMixer3_1St_st       *pMixer_Instance;
+    LVMixer3_2St_st       *pBypassMixer_Instance;
     LVM_INT16             i;
     LVM_INT32             MixGain;
 
@@ -227,7 +228,7 @@
     /*
      * Initialise the filters
      */
-    LVDBE_SetFilters(pInstance,                                 /* Set the filter taps and coefficients */
+    LVDBE_SetFilters(pInstance,                 /* Set the filter taps and coefficients */
                      &pInstance->Params);
 
 
@@ -236,7 +237,8 @@
      */
     LVDBE_SetAGC(pInstance,                                     /* Set the AGC gain */
                  &pInstance->Params);
-    pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain;   /* Default to the bass boost setting */
+    pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain;
+                                                /* Default to the bass boost setting */
 
 
     /*
@@ -245,7 +247,8 @@
     LVDBE_SetVolume(pInstance,                                         /* Set the Volume */
                     &pInstance->Params);
 
-    pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target;  /* Initialise as the target */
+    pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target;
+                                                /* Initialise as the target */
 
     pMixer_Instance = &pInstance->pData->BypassVolume;
     MixGain = LVC_Mixer_GetTarget(&pMixer_Instance->MixerStream[0]);
@@ -258,9 +261,31 @@
     pMixer_Instance->MixerStream[0].CallbackSet = 0;
 
     /*
-     * Initialise the clicks minimisation variable
+     * Initialise the clicks minimisation BypassMixer
      */
-    pInstance->bTransitionOnToOff   =   LVM_FALSE;
+
+    pBypassMixer_Instance = &pInstance->pData->BypassMixer;
+
+    /*
+     * Setup the mixer gain for the processed path
+     */
+    pBypassMixer_Instance->MixerStream[0].CallbackParam = 0;
+    pBypassMixer_Instance->MixerStream[0].pCallbackHandle = LVM_NULL;
+    pBypassMixer_Instance->MixerStream[0].pCallBack = LVM_NULL;
+    pBypassMixer_Instance->MixerStream[0].CallbackSet=0;
+    LVC_Mixer_Init(&pBypassMixer_Instance->MixerStream[0],0,0);
+    LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[0],
+        LVDBE_BYPASS_MIXER_TC,pInstance->Params.SampleRate,2);
+    /*
+     * Setup the mixer gain for the unprocessed path
+     */
+    pBypassMixer_Instance->MixerStream[1].CallbackParam = 0;
+    pBypassMixer_Instance->MixerStream[1].pCallbackHandle = LVM_NULL;
+    pBypassMixer_Instance->MixerStream[1].pCallBack = LVM_NULL;
+    pBypassMixer_Instance->MixerStream[1].CallbackSet=0;
+    LVC_Mixer_Init(&pBypassMixer_Instance->MixerStream[1],0x00007FFF,0x00007FFF);
+    LVC_Mixer_SetTimeConstant(&pBypassMixer_Instance->MixerStream[1],
+        LVDBE_BYPASS_MIXER_TC,pInstance->Params.SampleRate,2);
 
     return(LVDBE_SUCCESS);
 }
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h
index 3e09cf4..df32873 100755
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Private.h
@@ -17,9 +17,9 @@
 
 /****************************************************************************************
 
-     $Author: nxp007753 $
-     $Revision: 1081 $
-     $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+     $Author: beq06068 $
+     $Revision: 1399 $
+     $Date: 2010-08-03 08:16:00 +0200 (Tue, 03 Aug 2010) $
 
 *****************************************************************************************/
 
@@ -75,6 +75,8 @@
 #define LVDBE_SCRATCHBUFFERS_INPLACE     4       /* Number of buffers required for inplace processing */
 
 #define LVDBE_MIXER_TC                   5       /* Mixer time  */
+#define LVDBE_BYPASS_MIXER_TC            100     /* Bypass mixer time */
+
 
 /****************************************************************************************/
 /*                                                                                      */
@@ -92,6 +94,7 @@
     Biquad_2I_Order2_Taps_t     HPFTaps;            /* High pass filter taps */
     Biquad_1I_Order2_Taps_t     BPFTaps;            /* Band pass filter taps */
     LVMixer3_1St_st             BypassVolume;       /* Bypass volume scaler */
+    LVMixer3_2St_st             BypassMixer;        /* Bypass Mixer for Click Removal */
 
 } LVDBE_Data_t;
 
@@ -115,9 +118,6 @@
     /* Data and coefficient pointers */
     LVDBE_Data_t                *pData;                /* Instance data */
     LVDBE_Coef_t                *pCoef;                /* Instance coefficients */
-
-    LVM_INT32                   bTransitionOnToOff;
-
 } LVDBE_Instance_t;
 
 
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c
index 35eec07..04032c0 100755
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Process.c
@@ -17,9 +17,9 @@
 
 /****************************************************************************************
 
-     $Author: nxp007753 $
-     $Revision: 1081 $
-     $Date: 2010-07-05 11:48:44 +0200 (Mon, 05 Jul 2010) $
+     $Author: beq06068 $
+     $Revision: 1400 $
+     $Date: 2010-08-03 09:22:37 +0200 (Tue, 03 Aug 2010) $
 
 *****************************************************************************************/
 
@@ -89,10 +89,16 @@
 
     LVDBE_Instance_t    *pInstance =(LVDBE_Instance_t  *)hInstance;
     LVM_INT32           *pScratch  = (LVM_INT32 *)pInstance->MemoryTable.Region[LVDBE_MEMREGION_SCRATCH].pBaseAddress;
-    LVM_INT32           *pMono     = (LVM_INT32 *)pOutData;
+    LVM_INT32           *pMono;
     LVM_INT16           *pInput    = (LVM_INT16 *)pInData;
 
 
+    /* Scratch for Volume Control starts at offset of 2*NumSamples short values from pScratch */
+    LVM_INT16           *pScratchVol = (LVM_INT16 *)(&pScratch[NumSamples]);
+
+    /* Scratch for Mono path starts at offset of 2*NumSamples 32-bit values from pScratch */
+    pMono                            = &pScratch[2*NumSamples];
+
     /*
      * Check the number of samples is not too large
      */
@@ -104,18 +110,20 @@
     /*
      * Check if the algorithm is enabled
      */
-    if ((pInstance->Params.OperatingMode != LVDBE_OFF) ||
-        (pInstance->bTransitionOnToOff == LVM_TRUE))
+    /* DBE path is processed when DBE is ON or during On/Off transitions */
+    if ((pInstance->Params.OperatingMode == LVDBE_ON)||
+        (LVC_Mixer_GetCurrent(&pInstance->pData->BypassMixer.MixerStream[0])
+         !=LVC_Mixer_GetTarget(&pInstance->pData->BypassMixer.MixerStream[0])))
     {
 
         /*
          * Convert 16-bit samples to 32-bit and scale
          * (For a 16-bit implementation apply headroom loss here)
          */
-        Int16LShiftToInt32_16x32(pInput,                               /* Source 16-bit data      */
-                                 pScratch,                             /* Destination 32-bit data */
-                                 (LVM_INT16)(2*NumSamples),            /* Left and right          */
-                                 LVDBE_SCALESHIFT);                    /* Shift scale             */
+        Int16LShiftToInt32_16x32(pInput,                               /* Source 16-bit data    */
+                                 pScratch,                             /* Dest. 32-bit data     */
+                                 (LVM_INT16)(2*NumSamples),            /* Left and right        */
+                                 LVDBE_SCALESHIFT);                    /* Shift scale           */
 
 
         /*
@@ -123,61 +131,54 @@
          */
         if (pInstance->Params.HPFSelect == LVDBE_HPF_ON)
         {
-              BQ_2I_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance,    /* Filter instance         */
-                                       (LVM_INT32 *)pScratch,               /* Source                  */
-                                       (LVM_INT32 *)pScratch,               /* Destination             */
-                                       (LVM_INT16)NumSamples);              /* Number of samples       */
+              BQ_2I_D32F32C30_TRC_WRA_01(&pInstance->pCoef->HPFInstance,/* Filter instance      */
+                                       (LVM_INT32 *)pScratch,           /* Source               */
+                                       (LVM_INT32 *)pScratch,           /* Destination          */
+                                       (LVM_INT16)NumSamples);          /* Number of samples    */
         }
 
 
         /*
          * Create the mono stream
          */
-        From2iToMono_32(pScratch,                                      /* Stereo source           */
-                        pMono,                                         /* Mono destination        */
-                        (LVM_INT16)NumSamples);                        /* Number of samples       */
+        From2iToMono_32(pScratch,                                      /* Stereo source         */
+                        pMono,                                         /* Mono destination      */
+                        (LVM_INT16)NumSamples);                        /* Number of samples     */
 
 
         /*
          * Apply the band pass filter
          */
-          BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance,     /* Filter instance         */
-                                   (LVM_INT32 *)pMono,                 /* Source                  */
-                                   (LVM_INT32 *)pMono,                 /* Destination             */
-                                   (LVM_INT16)NumSamples);             /* Number of samples       */
+        BP_1I_D32F32C30_TRC_WRA_02(&pInstance->pCoef->BPFInstance,     /* Filter instance       */
+                                   (LVM_INT32 *)pMono,                 /* Source                */
+                                   (LVM_INT32 *)pMono,                 /* Destination           */
+                                   (LVM_INT16)NumSamples);             /* Number of samples     */
 
 
         /*
          * Apply the AGC and mix
          */
-        AGC_MIX_VOL_2St1Mon_D32_WRA(&pInstance->pData->AGCInstance,    /* Instance pointer        */
-                                    pScratch,                          /* Stereo source           */
-                                    pMono,                             /* Mono band pass source   */
-                                    pScratch,                          /* Stereo destination      */
-                                    NumSamples);                       /* Number of samples       */
-
-        if(pInstance->bTransitionOnToOff == LVM_TRUE)
-        {
-            if ((pInstance->pData->AGCInstance.AGC_Gain == pInstance->pData->AGCInstance.AGC_Target)&&
-                (pInstance->pData->AGCInstance.AGC_Gain == 0))
-            {
-                    pInstance->bTransitionOnToOff = LVM_FALSE;
-            }
-        }
-
-
+        AGC_MIX_VOL_2St1Mon_D32_WRA(&pInstance->pData->AGCInstance,    /* Instance pointer      */
+                                    pScratch,                          /* Stereo source         */
+                                    pMono,                             /* Mono band pass source */
+                                    pScratch,                          /* Stereo destination    */
+                                    NumSamples);                       /* Number of samples     */
 
         /*
          * Convert 32-bit samples to 16-bit and saturate
          * (Not required for 16-bit implemenations)
          */
-        Int32RShiftToInt16_Sat_32x16(pScratch,                         /* Source 32-bit data      */
-                                     pOutData,                         /* Destination 16-bit data */
-                                     (LVM_INT16)(2*NumSamples),        /* Left and right          */
-                                     LVDBE_SCALESHIFT);                /* Shift scale             */
+        Int32RShiftToInt16_Sat_32x16(pScratch,                         /* Source 32-bit data    */
+                                     (LVM_INT16 *)pScratch,            /* Dest. 16-bit data     */
+                                     (LVM_INT16)(2*NumSamples),        /* Left and right        */
+                                     LVDBE_SCALESHIFT);                /* Shift scale           */
 
     }
-    else
+
+    /* Bypass Volume path is processed when DBE is OFF or during On/Off transitions */
+    if ((pInstance->Params.OperatingMode == LVDBE_OFF)||
+        (LVC_Mixer_GetCurrent(&pInstance->pData->BypassMixer.MixerStream[1])
+         !=LVC_Mixer_GetTarget(&pInstance->pData->BypassMixer.MixerStream[1])))
     {
 
         /*
@@ -186,11 +187,20 @@
          */
         LVC_MixSoft_1St_D16C31_SAT(&pInstance->pData->BypassVolume,
                                   pInData,
-                               pOutData,
-                               (LVM_INT16)(2*NumSamples));           /* Left and right           */
+                                  pScratchVol,
+                               (LVM_INT16)(2*NumSamples));           /* Left and right          */
 
     }
 
+    /*
+     * Mix DBE processed path and bypass volume path
+     */
+    LVC_MixSoft_2St_D16C31_SAT(&pInstance->pData->BypassMixer,
+                                    (LVM_INT16 *) pScratch,
+                                    pScratchVol,
+                                    pOutData,
+                                    (LVM_INT16)(2*NumSamples));
+
     return(LVDBE_SUCCESS);
 }
 
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
index 922f77d..cec7501 100755
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Control.c
@@ -18,8 +18,8 @@
 /****************************************************************************************
 
      $Author: nxp007753 $
-     $Revision: 1316 $
-     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $
+     $Revision: 1331 $
+     $Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
 
 *****************************************************************************************/
 
diff --git a/media/libeffects/lvm/lib/Reverb/lib/LVREV.h b/media/libeffects/lvm/lib/Reverb/lib/LVREV.h
new file mode 100755
index 0000000..4c32db0
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/lib/LVREV.h
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/************************************************************************/
+/*                                                                      */
+/*     Project::                                                        */
+/*     $Author: beq03888 $*/
+/*     $Revision: 1204 $*/
+/*     $Date: 2010-07-14 08:55:43 +0200 (Wed, 14 Jul 2010) $*/
+/*                                                                      */
+/************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Header file for the application layer interface of the LVREV module                 */
+/*                                                                                      */
+/*  This files includes all definitions, types, structures and function prototypes      */
+/*  required by the calling layer. All other types, structures and functions are        */
+/*  private.                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+
+#ifndef __LVREV_H__
+#define __LVREV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVM_Types.h"
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Definitions                                                                         */
+/*                                                                                      */
+/****************************************************************************************/
+/* General */
+#define LVREV_BLOCKSIZE_MULTIPLE                1       /* Processing block size multiple */
+#define LVREV_MAX_T60                        7000       /* Maximum decay time is 7000ms */
+
+/* Memory table*/
+#define LVREV_NR_MEMORY_REGIONS                 4       /* Number of memory regions */
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Types                                                                               */
+/*                                                                                      */
+/****************************************************************************************/
+/* Instance handle */
+typedef void *LVREV_Handle_t;
+
+
+/* Status return values */
+typedef enum
+{
+    LVREV_SUCCESS            = 0,                       /* Successful return from a routine */
+    LVREV_NULLADDRESS        = 1,                       /* NULL allocation address */
+    LVREV_OUTOFRANGE         = 2,                       /* Out of range control parameter */
+    LVREV_INVALIDNUMSAMPLES  = 3,                       /* Invalid number of samples */
+    LVREV_RETURNSTATUS_DUMMY = LVM_MAXENUM
+} LVREV_ReturnStatus_en;
+
+
+/* Reverb delay lines */
+typedef enum
+{
+    LVREV_DELAYLINES_1     = 1,                         /* One delay line */
+    LVREV_DELAYLINES_2     = 2,                         /* Two delay lines */
+    LVREV_DELAYLINES_4     = 4,                         /* Four delay lines */
+    LVREV_DELAYLINES_DUMMY = LVM_MAXENUM
+} LVREV_NumDelayLines_en;
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Structures                                                                          */
+/*                                                                                      */
+/****************************************************************************************/
+
+/* Memory table containing the region definitions */
+typedef struct
+{
+    LVM_MemoryRegion_st        Region[LVREV_NR_MEMORY_REGIONS];  /* One definition for each region */
+} LVREV_MemoryTable_st;
+
+
+/* Control Parameter structure */
+typedef struct
+{
+    /* General parameters */
+    LVM_Mode_en                 OperatingMode;          /* Operating mode */
+    LVM_Fs_en                   SampleRate;             /* Sample rate */
+    LVM_Format_en               SourceFormat;           /* Source data format */
+
+    /* Parameters for REV */
+    LVM_UINT16                  Level;                  /* Level, 0 to 100 representing percentage of reverb */
+    LVM_UINT16                  LPF;                    /* Low pass filter, in Hz */
+    LVM_UINT16                  HPF;                    /* High pass filter, in Hz */
+    LVM_UINT16                  T60;                    /* Decay time constant, in ms */
+    LVM_UINT16                  Density;                /* Echo density, 0 to 100 for minimum to maximum density */
+    LVM_UINT16                  Damping;                /* Damping */
+    LVM_UINT16                  RoomSize;               /* Simulated room size, 1 to 100 for minimum to maximum size */
+
+} LVREV_ControlParams_st;
+
+
+/* Instance Parameter structure */
+typedef struct
+{
+    /* General */
+    LVM_UINT16                  MaxBlockSize;           /* Maximum processing block size */
+
+    /* Reverb */
+    LVM_Format_en               SourceFormat;           /* Source data formats to support */
+    LVREV_NumDelayLines_en      NumDelays;              /* The number of delay lines, 1, 2 or 4 */
+
+} LVREV_InstanceParams_st;
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Function Prototypes                                                                 */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_GetMemoryTable                                        */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  This function is used to obtain the LVREV module memory requirements to support     */
+/*  memory allocation. It can also be used to return the memory base address provided   */
+/*  during memory allocation to support freeing of memory when the LVREV module is no   */
+/*  longer required. It is called in two ways:                                          */
+/*                                                                                      */
+/*  hInstance = NULL                Returns the memory requirements                     */
+/*  hInstance = Instance handle     Returns the memory requirements and allocated       */
+/*                                  base addresses.                                     */
+/*                                                                                      */
+/*  When this function is called with hInstance = NULL the memory base address pointers */
+/*  will be NULL on return.                                                             */
+/*                                                                                      */
+/*  When the function is called for freeing memory, hInstance = Instance Handle the     */
+/*  memory table returns the allocated memory and base addresses used during            */
+/*  initialisation.                                                                     */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance Handle                                             */
+/*  pMemoryTable            Pointer to an empty memory table                            */
+/*  pInstanceParams         Pointer to the instance parameters                          */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When pMemoryTable is NULL                                   */
+/*  LVREV_NULLADDRESS       When requesting memory requirements and pInstanceParams     */
+/*                          is NULL                                                     */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1.  This function may be interrupted by the LVREV_Process function                  */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_GetMemoryTable(LVREV_Handle_t           hInstance,
+                                           LVREV_MemoryTable_st     *pMemoryTable,
+                                           LVREV_InstanceParams_st  *pInstanceParams);
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_GetInstanceHandle                                     */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  This function is used to create a LVREV module instance. It returns the created     */
+/*  instance handle through phInstance. All parameters are set to invalid values, the   */
+/*  LVREV_SetControlParameters function must be called with a set of valid control      */
+/*  parameters before the LVREV_Process function can be called.                         */
+/*                                                                                      */
+/*  The memory allocation must be provided by the application by filling in the memory  */
+/*  region base addresses in the memory table before calling this function.             */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  phInstance              Pointer to the instance handle                              */
+/*  pMemoryTable            Pointer to the memory definition table                      */
+/*  pInstanceParams         Pointer to the instance parameters                          */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When phInstance or pMemoryTable or pInstanceParams is NULL  */
+/*  LVREV_NULLADDRESS       When one of the memory regions has a NULL pointer           */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t            *phInstance,
+                                              LVREV_MemoryTable_st      *pMemoryTable,
+                                              LVREV_InstanceParams_st   *pInstanceParams);
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVXX_GetControlParameters                                   */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Request the LVREV module control parameters. The current parameter set is returned  */
+/*  via the parameter pointer.                                                          */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pControlParams          Pointer to an empty parameter structure                     */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When hInstance or pControlParams is NULL                    */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1.  This function may be interrupted by the LVREV_Process function                  */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t           hInstance,
+                                                 LVREV_ControlParams_st   *pControlParams);
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_SetControlParameters                                  */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Sets or changes the LVREV module parameters.                                        */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pNewParams              Pointer to a parameter structure                            */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When hInstance or pNewParams is NULL                        */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1.  This function may be interrupted by the LVREV_Process function                  */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t           hInstance,
+                                                 LVREV_ControlParams_st   *pNewParams);
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_ClearAudioBuffers                                     */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  This function is used to clear the internal audio buffers of the module.            */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS          Initialisation succeeded                                     */
+/*  LVREV_NULLADDRESS      Instance is NULL                                             */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1. This function must not be interrupted by the LVREV_Process function              */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t  hInstance);
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_Process                                               */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Process function for the LVREV module.                                              */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pInData                 Pointer to the input data                                   */
+/*  pOutData                Pointer to the output data                                  */
+/*  NumSamples              Number of samples in the input buffer                       */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS           Succeeded                                                   */
+/*  LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size           */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1. The input and output buffers must be 32-bit aligned                              */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t      hInstance,
+                                    const LVM_INT32     *pInData,
+                                    LVM_INT32           *pOutData,
+                                    const LVM_UINT16          NumSamples);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif      /* __LVREV_H__ */
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c
new file mode 100755
index 0000000..0026652
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_ApplyNewSettings.c
@@ -0,0 +1,656 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp007753 $ */
+/*     $Revision: 1316 $ */
+/*     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+#include "Filter.h"
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_ApplyNewSettings                                      */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Applies the new control parameters                                                  */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  pPrivate                Pointer to the instance private parameters                  */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_Success           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When pPrivate is NULL                                       */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*                                                                                      */
+/****************************************************************************************/
+
+LVREV_ReturnStatus_en LVREV_ApplyNewSettings (LVREV_Instance_st     *pPrivate)
+{
+
+    LVM_Mode_en  OperatingMode;
+    LVM_INT32    NumberOfDelayLines;
+
+
+    /* Check for NULL pointer */
+    if(pPrivate == LVM_NULL)
+    {
+        return LVREV_NULLADDRESS;
+    }
+
+    OperatingMode = pPrivate->NewParams.OperatingMode;
+
+    if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
+    {
+        NumberOfDelayLines = 4;
+    }
+    else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2)
+    {
+        NumberOfDelayLines = 2;
+    }
+    else
+    {
+        NumberOfDelayLines = 1;
+    }
+
+    /*
+     * Update the high pass filter coefficients
+     */
+    if((pPrivate->NewParams.HPF        != pPrivate->CurrentParams.HPF)        ||
+       (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
+       (pPrivate->bFirstControl        == LVM_TRUE))
+    {
+        LVM_INT32       Omega;
+        FO_C32_Coefs_t  Coeffs;
+
+        Omega = LVM_GetOmega(pPrivate->NewParams.HPF, pPrivate->NewParams.SampleRate);
+        LVM_FO_HPF(Omega, &Coeffs);
+        FO_1I_D32F32Cll_TRC_WRA_01_Init( &pPrivate->pFastCoef->HPCoefs, &pPrivate->pFastData->HPTaps, &Coeffs);
+        LoadConst_32(0,
+            (void *)&pPrivate->pFastData->HPTaps, /* Destination Cast to void: no dereferencing in function*/
+            sizeof(Biquad_1I_Order1_Taps_t)/sizeof(LVM_INT32));
+    }
+
+
+    /*
+     * Update the low pass filter coefficients
+     */
+    if((pPrivate->NewParams.LPF        != pPrivate->CurrentParams.LPF)        ||
+       (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
+       (pPrivate->bFirstControl        == LVM_TRUE))
+    {
+        LVM_INT32       Omega;
+        FO_C32_Coefs_t  Coeffs;
+
+
+        Coeffs.A0 = 0x7FFFFFFF;
+        Coeffs.A1 = 0;
+        Coeffs.B1 = 0;
+        if(pPrivate->NewParams.LPF <= (LVM_FsTable[pPrivate->NewParams.SampleRate] >> 1))
+        {
+            Omega = LVM_GetOmega(pPrivate->NewParams.LPF, pPrivate->NewParams.SampleRate);
+
+            /*
+             * Do not apply filter if w =2*pi*fc/fs >= 2.9
+             */
+            if(Omega<=LVREV_2_9_INQ29)
+            {
+                LVM_FO_LPF(Omega, &Coeffs);
+            }
+        }
+        FO_1I_D32F32Cll_TRC_WRA_01_Init( &pPrivate->pFastCoef->LPCoefs, &pPrivate->pFastData->LPTaps, &Coeffs);
+        LoadConst_32(0,
+            (void *)&pPrivate->pFastData->LPTaps,        /* Destination Cast to void: no dereferencing in function*/
+            sizeof(Biquad_1I_Order1_Taps_t)/sizeof(LVM_INT32));
+    }
+
+
+    /*
+     * Calculate the room size parameter
+     */
+    if( pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize)
+    {
+        /* Room size range is 10ms to 200ms
+         * 0%   -- 10ms
+         * 50%  -- 65ms
+         * 100% -- 120ms
+         */
+        pPrivate->RoomSizeInms = 10 + (((pPrivate->NewParams.RoomSize*11) + 5)/10);
+    }
+
+
+    /*
+     * Update the T delay number of samples and the all pass delay number of samples
+     */
+    if( (pPrivate->NewParams.RoomSize   != pPrivate->CurrentParams.RoomSize)   ||
+        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
+        (pPrivate->bFirstControl        == LVM_TRUE))
+    {
+
+        LVM_UINT32  Temp;
+        LVM_INT32   APDelaySize;
+        LVM_INT32   Fs = LVM_GetFsFromTable(pPrivate->NewParams.SampleRate);
+        LVM_UINT32  DelayLengthSamples = (LVM_UINT32)(Fs * pPrivate->RoomSizeInms);
+        LVM_INT16   i;
+        LVM_INT16   ScaleTable[]  = {LVREV_T_3_Power_minus0_on_4, LVREV_T_3_Power_minus1_on_4, LVREV_T_3_Power_minus2_on_4, LVREV_T_3_Power_minus3_on_4};
+        LVM_INT16   MaxT_Delay[]  = {LVREV_MAX_T0_DELAY, LVREV_MAX_T1_DELAY, LVREV_MAX_T2_DELAY, LVREV_MAX_T3_DELAY};
+        LVM_INT16   MaxAP_Delay[] = {LVREV_MAX_AP0_DELAY, LVREV_MAX_AP1_DELAY, LVREV_MAX_AP2_DELAY, LVREV_MAX_AP3_DELAY};
+
+
+        /*
+         * For each delay line
+         */
+        for (i=0; i<NumberOfDelayLines; i++)
+        {
+            if (i != 0)
+            {
+                LVM_INT32 Temp1;  /* to avoid QAC warning on type conversion */
+                LVM_INT32 Temp2;  /* to avoid QAC warning on type conversion */
+
+                Temp2=(LVM_INT32)DelayLengthSamples;
+                MUL32x16INTO32(Temp2, ScaleTable[i], Temp1, 15)
+                Temp=(LVM_UINT32)Temp1;
+            }
+            else
+            {
+               Temp = DelayLengthSamples;
+            }
+            APDelaySize = Temp  / 1500;
+
+
+            /*
+             * Set the fixed delay
+             */
+            Temp                  = (MaxT_Delay[i] - MaxAP_Delay[i]) * Fs / 48000;
+            pPrivate->Delay_AP[i] = pPrivate->T[i] - Temp;
+
+
+            /*
+             * Set the tap selection
+             */
+            if (pPrivate->AB_Selection)
+            {
+                /* Smooth from tap A to tap B */
+                pPrivate->pOffsetB[i]             = &pPrivate->pDelay_T[i][pPrivate->T[i] - Temp - APDelaySize];
+                pPrivate->B_DelaySize[i]          = APDelaySize;
+                pPrivate->Mixer_APTaps[i].Target1 = 0;
+                pPrivate->Mixer_APTaps[i].Target2 = 0x7fffffff;
+            }
+            else
+            {
+                /* Smooth from tap B to tap A */
+                pPrivate->pOffsetA[i]             = &pPrivate->pDelay_T[i][pPrivate->T[i] - Temp - APDelaySize];
+                pPrivate->A_DelaySize[i]          = APDelaySize;
+                pPrivate->Mixer_APTaps[i].Target2 = 0;
+                pPrivate->Mixer_APTaps[i].Target1 = 0x7fffffff;
+            }
+
+            /*
+             * Set the maximum block size to the smallest delay size
+             */
+            pPrivate->MaxBlkLen   = Temp;
+            if (pPrivate->MaxBlkLen > pPrivate->A_DelaySize[i])
+            {
+                pPrivate->MaxBlkLen = pPrivate->A_DelaySize[i];
+            }
+            if (pPrivate->MaxBlkLen > pPrivate->B_DelaySize[i])
+            {
+                pPrivate->MaxBlkLen = pPrivate->B_DelaySize[i];
+            }
+        }
+        if (pPrivate->AB_Selection)
+        {
+            pPrivate->AB_Selection = 0;
+        }
+        else
+        {
+            pPrivate->AB_Selection = 1;
+        }
+
+
+        /*
+         * Limit the maximum block length
+         */
+        pPrivate->MaxBlkLen=pPrivate->MaxBlkLen-2;                                  /* Just as a precausion, but no problem if we remove this line      */
+        if(pPrivate->MaxBlkLen > pPrivate->InstanceParams.MaxBlockSize)
+        {
+            pPrivate->MaxBlkLen = (LVM_INT32)pPrivate->InstanceParams.MaxBlockSize;
+        }
+    }
+
+
+    /*
+     * Update the low pass filter coefficient
+     */
+    if( (pPrivate->NewParams.Damping    != pPrivate->CurrentParams.Damping)    ||
+        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
+        (pPrivate->bFirstControl        == LVM_TRUE))
+    {
+
+        LVM_INT32       Temp;
+        LVM_INT32       Omega;
+        FO_C32_Coefs_t  Coeffs;
+        LVM_INT16       i;
+        LVM_INT16       Damping      = (LVM_INT16)((pPrivate->NewParams.Damping * 100) + 1000);
+        LVM_INT32       ScaleTable[] = {LVREV_T_3_Power_0_on_4, LVREV_T_3_Power_1_on_4, LVREV_T_3_Power_2_on_4, LVREV_T_3_Power_3_on_4};
+
+
+        /*
+         * For each filter
+         */
+        for (i=0; i<NumberOfDelayLines; i++)
+        {
+            if (i != 0)
+            {
+                MUL32x16INTO32(ScaleTable[i], Damping, Temp, 15)
+            }
+            else
+            {
+                Temp = Damping;
+            }
+            if(Temp <= (LVM_FsTable[pPrivate->NewParams.SampleRate] >> 1))
+            {
+                Omega = LVM_GetOmega((LVM_UINT16)Temp, pPrivate->NewParams.SampleRate);
+                LVM_FO_LPF(Omega, &Coeffs);
+            }
+            else
+            {
+                Coeffs.A0 = 0x7FF00000;
+                Coeffs.A1 = 0;
+                Coeffs.B1 = 0;
+            }
+            FO_1I_D32F32Cll_TRC_WRA_01_Init(&pPrivate->pFastCoef->RevLPCoefs[i], &pPrivate->pFastData->RevLPTaps[i], &Coeffs);
+        }
+    }
+
+
+    /*
+     * Update All-pass filter mixer time constants
+     */
+    if( (pPrivate->NewParams.RoomSize   != pPrivate->CurrentParams.RoomSize)   ||
+        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
+        (pPrivate->NewParams.Density    != pPrivate->CurrentParams.Density))
+    {
+        LVM_INT16   i;
+        LVM_INT32   Alpha    = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_ALLPASS_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), 1);
+        LVM_INT32   AlphaTap = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_ALLPASS_TAP_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), 1);
+
+        for (i=0; i<4; i++)
+        {
+            pPrivate->Mixer_APTaps[i].Alpha1       = AlphaTap;
+            pPrivate->Mixer_APTaps[i].Alpha2       = AlphaTap;
+            pPrivate->Mixer_SGFeedback[i].Alpha    = Alpha;
+            pPrivate->Mixer_SGFeedforward[i].Alpha = Alpha;
+        }
+    }
+
+
+    /*
+     * Update the feed back gain
+     */
+    if( (pPrivate->NewParams.RoomSize   != pPrivate->CurrentParams.RoomSize)   ||
+        (pPrivate->NewParams.SampleRate != pPrivate->CurrentParams.SampleRate) ||
+        (pPrivate->NewParams.T60        != pPrivate->CurrentParams.T60)        ||
+        (pPrivate->bFirstControl        == LVM_TRUE))
+    {
+
+        LVM_INT32               G[4];                       /* Feedback gain (Q7.24) */
+
+        if(pPrivate->NewParams.T60 == 0)
+        {
+            G[3] = 0;
+            G[2] = 0;
+            G[1] = 0;
+            G[0] = 0;
+        }
+        else
+        {
+            LVM_INT32   Temp1;
+            LVM_INT32   Temp2;
+            LVM_INT16   i;
+            LVM_INT16   ScaleTable[] = {LVREV_T_3_Power_minus0_on_4, LVREV_T_3_Power_minus1_on_4, LVREV_T_3_Power_minus2_on_4, LVREV_T_3_Power_minus3_on_4};
+
+
+            /*
+             * For each delay line
+             */
+            for (i=0; i<NumberOfDelayLines; i++)
+            {
+                Temp1 = (3 * pPrivate->RoomSizeInms * ScaleTable[i]) / pPrivate->NewParams.T60;
+                if(Temp1 >= (4 << 15))
+                {
+                    G[i] = 0;
+                }
+                else if((Temp1 >= (2 << 15)))
+                {
+                    Temp2 = LVM_Power10(-(Temp1 << 14));
+                    Temp1 = LVM_Power10(-(Temp1 << 14));
+                    MUL32x32INTO32(Temp1,Temp2,Temp1,24)
+                }
+                else
+                {
+                    Temp1 = LVM_Power10(-(Temp1 << 15));
+                }
+                if (NumberOfDelayLines == 1)
+                {
+                    G[i] = Temp1;
+                }
+                else
+                {
+                    LVM_INT32   TempG;
+                    MUL32x16INTO32(Temp1,ONE_OVER_SQRT_TWO,TempG,15)
+                    G[i]=TempG;
+                }
+            }
+        }
+
+        /* Set up the feedback mixers for four delay lines */
+        pPrivate->FeedbackMixer[0].Target=G[0]<<7;
+        pPrivate->FeedbackMixer[1].Target=G[1]<<7;
+        pPrivate->FeedbackMixer[2].Target=G[2]<<7;
+        pPrivate->FeedbackMixer[3].Target=G[3]<<7;
+    }
+
+
+    /*
+     * Calculate the gain correction
+     */
+    if((pPrivate->NewParams.RoomSize != pPrivate->CurrentParams.RoomSize) ||
+       (pPrivate->NewParams.Level    != pPrivate->CurrentParams.Level)    ||
+       (pPrivate->NewParams.T60      != pPrivate->CurrentParams.T60) )
+    {
+        LVM_INT32 Index=0;
+        LVM_INT32 i=0;
+        LVM_INT32 Gain=0;
+        LVM_INT32 RoomSize=0;
+        LVM_INT32 T60;
+        LVM_INT32 Coefs[5];
+
+        if(pPrivate->NewParams.RoomSize==0)
+        {
+            RoomSize=1;
+        }
+        else
+        {
+            RoomSize=(LVM_INT32)pPrivate->NewParams.RoomSize;
+        }
+
+        if(pPrivate->NewParams.T60<100)
+        {
+            T60 = 100 * LVREV_T60_SCALE;
+        }
+        else
+        {
+            T60 = pPrivate->NewParams.T60 * LVREV_T60_SCALE;
+        }
+
+        /* Find the nearest room size in table */
+        for(i=0;i<24;i++)
+        {
+            if(RoomSize<= LVREV_GainPolyTable[i][0])
+            {
+                Index=i;
+                break;
+            }
+        }
+
+
+        if(RoomSize==LVREV_GainPolyTable[Index][0])
+        {
+            /* Take table values if the room size is in table */
+            for(i=1;i<5;i++)
+            {
+                Coefs[i-1]=LVREV_GainPolyTable[Index][i];
+            }
+            Coefs[4]=0;
+            Gain=LVM_Polynomial(3,Coefs,T60);       /* Q.24 result */
+        }
+        else
+        {
+            /* Interpolate the gain between nearest room sizes */
+
+            LVM_INT32 Gain1,Gain2;
+            LVM_INT32 Tot_Dist,Dist;
+
+            Tot_Dist=LVREV_GainPolyTable[Index][0]-LVREV_GainPolyTable[Index-1][0];
+            Dist=RoomSize-LVREV_GainPolyTable[Index-1][0];
+
+
+            /* Get gain for first */
+            for(i=1;i<5;i++)
+            {
+                Coefs[i-1]=LVREV_GainPolyTable[Index-1][i];
+            }
+            Coefs[4]=0;
+
+            Gain1=LVM_Polynomial(3,Coefs,T60);      /* Q.24 result */
+
+            /* Get gain for second */
+            for(i=1;i<5;i++)
+            {
+                Coefs[i-1]=LVREV_GainPolyTable[Index][i];
+            }
+            Coefs[4]=0;
+
+            Gain2=LVM_Polynomial(3,Coefs,T60);      /* Q.24 result */
+
+            /* Linear Interpolate the gain */
+            Gain = Gain1+ (((Gain2-Gain1)*Dist)/(Tot_Dist));
+        }
+
+
+        /*
+         * Get the inverse of gain: Q.15
+         * Gain is mostly above one except few cases, take only gains above 1
+         */
+        if(Gain < 16777216L)
+        {
+            pPrivate->Gain= 32767;
+        }
+        else
+        {
+            pPrivate->Gain=(LVM_INT16)(LVM_MAXINT_32/(Gain>>8));
+        }
+
+
+        Index=((32767*100)/(100+pPrivate->NewParams.Level));
+        pPrivate->Gain=(LVM_INT16)((pPrivate->Gain*Index)>>15);
+        pPrivate->GainMixer.Target = pPrivate->Gain*Index;
+    }
+
+
+    /*
+     * Update the all pass comb filter coefficient
+     */
+    if( (pPrivate->NewParams.Density != pPrivate->CurrentParams.Density) ||
+        (pPrivate->bFirstControl     == LVM_TRUE))
+    {
+        LVM_INT16   i;
+        LVM_INT32   b = pPrivate->NewParams.Density * LVREV_B_8_on_1000;
+
+        for (i=0;i<4; i++)
+        {
+            pPrivate->Mixer_SGFeedback[i].Target    = b;
+            pPrivate->Mixer_SGFeedforward[i].Target = b;
+        }
+    }
+
+
+    /*
+     * Update the bypass mixer time constant
+     */
+    if((pPrivate->NewParams.SampleRate   != pPrivate->CurrentParams.SampleRate)   ||
+       (pPrivate->NewParams.SourceFormat != pPrivate->CurrentParams.SourceFormat) ||
+       (pPrivate->bFirstControl          == LVM_TRUE))
+    {
+        LVM_UINT16   NumChannels = 1;                       /* Assume MONO format */
+        LVM_INT32    Alpha;
+
+        Alpha = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_FEEDBACKMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
+        pPrivate->FeedbackMixer[0].Alpha=Alpha;
+        pPrivate->FeedbackMixer[1].Alpha=Alpha;
+        pPrivate->FeedbackMixer[2].Alpha=Alpha;
+        pPrivate->FeedbackMixer[3].Alpha=Alpha;
+
+        if (pPrivate->NewParams.SourceFormat != LVM_MONO)
+        {
+            /* Stereo or Mono-in-Stereo format data */
+            NumChannels = 2;
+        }
+        pPrivate->BypassMixer.Alpha1 = (LVM_INT32)LVM_Mixer_TimeConstant(LVREV_BYPASSMIXER_TC, LVM_GetFsFromTable(pPrivate->NewParams.SampleRate), NumChannels);
+        pPrivate->BypassMixer.Alpha2 = pPrivate->BypassMixer.Alpha1;
+        pPrivate->GainMixer.Alpha    = pPrivate->BypassMixer.Alpha1;
+    }
+
+
+    /*
+     * Update the bypass mixer targets
+     */
+    if( (pPrivate->NewParams.Level != pPrivate->CurrentParams.Level) &&
+        (pPrivate->NewParams.OperatingMode == LVM_MODE_ON))
+    {
+        pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16;
+        pPrivate->BypassMixer.Target1 = LVREV_HEADROOM << 16;
+        if ((pPrivate->NewParams.Level == 0) && (pPrivate->bFirstControl == LVM_FALSE))
+        {
+            pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE;
+        }
+        if (pPrivate->NewParams.Level != 0)
+        {
+            pPrivate->bDisableReverb = LVM_FALSE;
+        }
+    }
+
+    if(pPrivate->NewParams.OperatingMode != pPrivate->CurrentParams.OperatingMode)
+    {
+        if(pPrivate->NewParams.OperatingMode == LVM_MODE_ON)
+        {
+            pPrivate->BypassMixer.Target2 = ((LVM_INT32)(pPrivate->NewParams.Level * 32767)/100)<<16;
+            pPrivate->BypassMixer.Target1 = LVREV_HEADROOM << 16;
+
+            pPrivate->BypassMixer.CallbackSet2 = LVM_FALSE;
+            OperatingMode                      = LVM_MODE_ON;
+            if (pPrivate->NewParams.Level == 0)
+            {
+                pPrivate->bDisableReverb = LVM_TRUE;
+            }
+            else
+            {
+                pPrivate->bDisableReverb = LVM_FALSE;
+            }
+        }
+        else if (pPrivate->bFirstControl == LVM_FALSE)
+        {
+            pPrivate->BypassMixer.Target2 = 0x00000000;
+            pPrivate->BypassMixer.Target1 = 0x7FFFFFFF;
+            pPrivate->BypassMixer.CallbackSet2 = LVM_TRUE;
+            pPrivate->GainMixer.Target    = 0x03FFFFFF;
+            OperatingMode = LVM_MODE_ON;
+        }
+        else
+        {
+            OperatingMode = LVM_MODE_OFF;
+        }
+    }
+
+
+    /*
+     * If it is the first call to ApplyNew settings force the current to the target to begin immediate playback of the effect
+     */
+    if(pPrivate->bFirstControl == LVM_TRUE)
+    {
+        pPrivate->BypassMixer.Current1 = pPrivate->BypassMixer.Target1;
+        pPrivate->BypassMixer.Current2 = pPrivate->BypassMixer.Target2;
+    }
+
+
+    /*
+     * Copy the new parameters
+     */
+    pPrivate->CurrentParams = pPrivate->NewParams;
+    pPrivate->CurrentParams.OperatingMode = OperatingMode;
+
+
+    /*
+     * Update flag
+     */
+    if(pPrivate->bFirstControl == LVM_TRUE)
+    {
+        pPrivate->bFirstControl = LVM_FALSE;
+    }
+
+
+    return LVREV_SUCCESS;
+}
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                BypassMixer_Callback                                        */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Controls the On to Off operating mode transition                                    */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  pPrivate                Pointer to the instance private parameters                  */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_Success           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When pPrivate is NULL                                       */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*                                                                                      */
+/****************************************************************************************/
+LVM_INT32 BypassMixer_Callback (void *pCallbackData,
+                                void *pGeneralPurpose,
+                                LVM_INT16 GeneralPurpose )
+{
+
+    LVREV_Instance_st     *pLVREV_Private = (LVREV_Instance_st *)pCallbackData;
+
+
+    /*
+     * Avoid build warnings
+     */
+    (void)pGeneralPurpose;
+    (void)GeneralPurpose;
+
+
+    /*
+     * Turn off
+     */
+    pLVREV_Private->CurrentParams.OperatingMode = LVM_MODE_OFF;
+    pLVREV_Private->bDisableReverb              = LVM_TRUE;
+    LVREV_ClearAudioBuffers((LVREV_Handle_t)pCallbackData);
+
+
+    return 0;
+}
+
+/* End of file */
+
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_ClearAudioBuffers.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_ClearAudioBuffers.c
new file mode 100755
index 0000000..b02b1a7
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_ClearAudioBuffers.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp007753 $ */
+/*     $Revision: 1316 $ */
+/*     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/* Includes                                                                             */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+#include "VectorArithmetic.h"
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_ClearAudioBuffers                                     */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  This function is used to clear the internal audio buffers of the module.            */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS          Initialisation succeeded                                     */
+/*  LVREV_NULLADDRESS      Instance is NULL                                             */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1. This function must not be interrupted by the LVM_Process function                */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_ClearAudioBuffers(LVREV_Handle_t  hInstance)
+{
+
+   LVREV_Instance_st     *pLVREV_Private = (LVREV_Instance_st *)hInstance;
+
+
+    /*
+     * Check for error conditions
+     */
+    /* Check for NULL pointers */
+    if(hInstance == LVM_NULL)
+    {
+        return LVREV_NULLADDRESS;
+    }
+
+    /*
+     * Clear all filter tap data, delay-lines and other signal related data
+     */
+
+
+    LoadConst_32(0,
+        (void *)&pLVREV_Private->pFastData->HPTaps, /* Destination Cast to void: no dereferencing in function*/
+        2);
+    LoadConst_32(0,
+        (void *)&pLVREV_Private->pFastData->LPTaps, /* Destination Cast to void: no dereferencing in function*/
+        2);
+
+    if((LVM_UINT16)pLVREV_Private->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
+    {
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[3], 2);
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[2], 2);
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[1], 2);
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[0], 2);
+
+        LoadConst_32(0,pLVREV_Private->pDelay_T[3], (LVM_INT16)LVREV_MAX_T3_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[2], (LVM_INT16)LVREV_MAX_T2_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[1], (LVM_INT16)LVREV_MAX_T1_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[0], (LVM_INT16)LVREV_MAX_T0_DELAY);
+
+    }
+
+    if((LVM_UINT16)pLVREV_Private->InstanceParams.NumDelays >= LVREV_DELAYLINES_2)
+    {
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[1], 2);
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[0], 2);
+
+        LoadConst_32(0,pLVREV_Private->pDelay_T[1], (LVM_INT16)LVREV_MAX_T1_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[0], (LVM_INT16)LVREV_MAX_T0_DELAY);
+    }
+
+    if((LVM_UINT16)pLVREV_Private->InstanceParams.NumDelays >= LVREV_DELAYLINES_1)
+    {
+        LoadConst_32(0, (LVM_INT32 *)&pLVREV_Private->pFastData->RevLPTaps[0], 2);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[0], (LVM_INT16)LVREV_MAX_T0_DELAY);
+    }
+
+    return LVREV_SUCCESS;
+}
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_GetControlParameters.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetControlParameters.c
new file mode 100755
index 0000000..ebf145e
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetControlParameters.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp27078 $*/
+/*     $Revision: 762 $*/
+/*     $Date: 2010-06-11 14:50:33 +0200 (Fri, 11 Jun 2010) $*/
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_GetControlParameters                                  */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Request the LVREV module control parameters. The current parameter set is returned  */
+/*  via the parameter pointer.                                                          */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pControlParams          Pointer to an empty parameter structure                     */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_Success           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When hInstance or pControlParams is NULL                    */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1.  This function may be interrupted by the LVREV_Process function                  */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_GetControlParameters(LVREV_Handle_t           hInstance,
+                                                 LVREV_ControlParams_st   *pControlParams)
+{
+
+    LVREV_Instance_st  *pLVREV_Private = (LVREV_Instance_st *)hInstance;
+
+
+    /*
+     * Check for error conditions
+     */
+    if((hInstance == LVM_NULL) || (pControlParams == LVM_NULL))
+    {
+        return LVREV_NULLADDRESS;
+    }
+
+    /*
+     * Return the current parameters
+     */
+    *pControlParams = pLVREV_Private->NewParams;
+
+    return LVREV_SUCCESS;
+}
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c
new file mode 100755
index 0000000..ca1c84d
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetInstanceHandle.c
@@ -0,0 +1,331 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp007753 $ */
+/*     $Revision: 1316 $ */
+/*     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+#include "InstAlloc.h"
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_GetInstanceHandle                                     */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  This function is used to create a LVREV module instance. It returns the created     */
+/*  instance handle through phInstance. All parameters are set to their default,        */
+/*  inactive state.                                                                     */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  phInstance              pointer to the instance handle                              */
+/*  pMemoryTable            Pointer to the memory definition table                      */
+/*  pInstanceParams         Pointer to the instance parameters                          */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_SUCCESS           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When phInstance or pMemoryTable or pInstanceParams is NULL  */
+/*  LVREV_NULLADDRESS       When one of the memory regions has a NULL pointer           */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_GetInstanceHandle(LVREV_Handle_t            *phInstance,
+                                              LVREV_MemoryTable_st      *pMemoryTable,
+                                              LVREV_InstanceParams_st   *pInstanceParams)
+{
+
+    INST_ALLOC              SlowData;
+    INST_ALLOC              FastData;
+    INST_ALLOC              FastCoef;
+    INST_ALLOC              Temporary;
+    LVREV_Instance_st       *pLVREV_Private;
+    LVM_INT16               i;
+    LVM_UINT16              MaxBlockSize;
+
+
+    /*
+     * Check for error conditions
+     */
+    /* Check for NULL pointers */
+    if((phInstance == LVM_NULL) || (pMemoryTable == LVM_NULL) || (pInstanceParams == LVM_NULL))
+    {
+        return LVREV_NULLADDRESS;
+    }
+    /* Check the memory table for NULL pointers */
+    for (i = 0; i < LVREV_NR_MEMORY_REGIONS; i++)
+    {
+        if (pMemoryTable->Region[i].Size!=0)
+        {
+            if (pMemoryTable->Region[i].pBaseAddress==LVM_NULL)
+            {
+                return(LVREV_NULLADDRESS);
+            }
+        }
+    }
+
+    /*
+     * Check all instance parameters are in range
+     */
+    /* Check for a non-zero block size */
+    if (pInstanceParams->MaxBlockSize == 0)
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    /* Check for a valid number of delay lines */
+    if ((pInstanceParams->NumDelays != LVREV_DELAYLINES_1)&&
+        (pInstanceParams->NumDelays != LVREV_DELAYLINES_2)&&
+        (pInstanceParams->NumDelays != LVREV_DELAYLINES_4))
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    /*
+     * Initialise the InstAlloc instances
+     */
+    InstAlloc_Init(&SlowData,  pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress);
+    InstAlloc_Init(&FastData,  pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress);
+    InstAlloc_Init(&FastCoef,  pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress);
+    InstAlloc_Init(&Temporary, pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress);
+
+    /*
+     * Zero all memory regions
+     */
+     LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size)/sizeof(LVM_INT16)));
+     LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size)/sizeof(LVM_INT16)));
+     LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size)/sizeof(LVM_INT16)));
+     LoadConst_16(0, (LVM_INT16 *)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress, (LVM_INT16)((pMemoryTable->Region[LVM_TEMPORARY_FAST].Size)/sizeof(LVM_INT16)));
+
+    /*
+     * Set the instance handle if not already initialised
+     */
+    if (*phInstance == LVM_NULL)
+    {
+        *phInstance = InstAlloc_AddMember(&SlowData, sizeof(LVREV_Instance_st));
+    }
+    pLVREV_Private              =(LVREV_Instance_st *)*phInstance;
+    pLVREV_Private->MemoryTable = *pMemoryTable;
+
+    if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_4)
+    {
+        MaxBlockSize = LVREV_MAX_AP3_DELAY;
+    }
+    else if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_2)
+    {
+        MaxBlockSize = LVREV_MAX_AP1_DELAY;
+    }
+    else
+    {
+        MaxBlockSize = LVREV_MAX_AP0_DELAY;
+    }
+
+    if(MaxBlockSize>pInstanceParams->MaxBlockSize)
+    {
+        MaxBlockSize=pInstanceParams->MaxBlockSize;
+    }
+
+
+    /*
+     * Set the data, coefficient and temporary memory pointers
+     */
+    pLVREV_Private->pFastData = InstAlloc_AddMember(&FastData, sizeof(LVREV_FastData_st));                              /* Fast data memory base address */
+
+    if(pInstanceParams->NumDelays == LVREV_DELAYLINES_4)
+    {
+        pLVREV_Private->pDelay_T[3]     = InstAlloc_AddMember(&FastData, LVREV_MAX_T3_DELAY  * sizeof(LVM_INT32));
+        pLVREV_Private->pDelay_T[2]     = InstAlloc_AddMember(&FastData, LVREV_MAX_T2_DELAY  * sizeof(LVM_INT32));
+        pLVREV_Private->pDelay_T[1]     = InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
+        pLVREV_Private->pDelay_T[0]     = InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
+
+        for( i = 0; i < 4; i++)
+        {
+            pLVREV_Private->pScratchDelayLine[i] = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);       /* Scratch for each delay line output */
+        }
+
+        LoadConst_32(0,pLVREV_Private->pDelay_T[3]  ,(LVM_INT16)LVREV_MAX_T3_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[2]  ,(LVM_INT16)LVREV_MAX_T2_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[1]  ,(LVM_INT16)LVREV_MAX_T1_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[0]  ,(LVM_INT16)LVREV_MAX_T0_DELAY);
+    }
+
+    if(pInstanceParams->NumDelays == LVREV_DELAYLINES_2)
+    {
+        pLVREV_Private->pDelay_T[1]  = InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
+        pLVREV_Private->pDelay_T[0]  = InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
+
+        for( i = 0; i < 2; i++)
+        {
+            pLVREV_Private->pScratchDelayLine[i] = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);       /* Scratch for each delay line output */
+        }
+
+        LoadConst_32(0,pLVREV_Private->pDelay_T[1] , (LVM_INT16)LVREV_MAX_T1_DELAY);
+        LoadConst_32(0,pLVREV_Private->pDelay_T[0] , (LVM_INT16)LVREV_MAX_T0_DELAY);
+    }
+
+    if(pInstanceParams->NumDelays == LVREV_DELAYLINES_1)
+    {
+        pLVREV_Private->pDelay_T[0]  = InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
+
+        for( i = 0; i < 1; i++)
+        {
+            pLVREV_Private->pScratchDelayLine[i] = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);       /* Scratch for each delay line output */
+        }
+
+        LoadConst_32(0,pLVREV_Private->pDelay_T[0]  , (LVM_INT16)LVREV_MAX_T0_DELAY);
+    }
+
+    /* All-pass delay buffer addresses and sizes */
+    pLVREV_Private->T[0]         = LVREV_MAX_T0_DELAY;
+    pLVREV_Private->T[1]         = LVREV_MAX_T1_DELAY;
+    pLVREV_Private->T[2]         = LVREV_MAX_T2_DELAY;
+    pLVREV_Private->T[3]         = LVREV_MAX_T3_DELAY;
+    pLVREV_Private->AB_Selection = 1;       /* Select smoothing A to B */
+
+
+    pLVREV_Private->pFastCoef       = InstAlloc_AddMember(&FastCoef, sizeof(LVREV_FastCoef_st));                        /* Fast coefficient memory base address */
+    pLVREV_Private->pScratch        = InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);                /* General purpose scratch */
+    pLVREV_Private->pInputSave      = InstAlloc_AddMember(&Temporary, 2 * sizeof(LVM_INT32) * MaxBlockSize);            /* Mono->stereo input save for end mix */
+    LoadConst_32(0, pLVREV_Private->pInputSave, (LVM_INT16)(MaxBlockSize*2));
+
+
+    /*
+     * Save the instance parameters in the instance structure
+     */
+    pLVREV_Private->InstanceParams = *pInstanceParams;
+
+
+    /*
+     * Set the parameters to invalid
+     */
+    pLVREV_Private->CurrentParams.SampleRate    = LVM_FS_INVALID;
+    pLVREV_Private->CurrentParams.OperatingMode = LVM_MODE_DUMMY;
+    pLVREV_Private->CurrentParams.SourceFormat  = LVM_SOURCE_DUMMY;
+
+    pLVREV_Private->bControlPending             = LVM_FALSE;
+    pLVREV_Private->bFirstControl               = LVM_TRUE;
+    pLVREV_Private->bDisableReverb              = LVM_FALSE;
+
+
+    /*
+     * Set mixer parameters
+     */
+    pLVREV_Private->BypassMixer.CallbackParam2      = 0;
+    pLVREV_Private->BypassMixer.pCallbackHandle2    = pLVREV_Private;
+    pLVREV_Private->BypassMixer.pGeneralPurpose2    = LVM_NULL;
+    pLVREV_Private->BypassMixer.pCallBack2          = BypassMixer_Callback;
+    pLVREV_Private->BypassMixer.CallbackSet2        = LVM_FALSE;
+    pLVREV_Private->BypassMixer.Current2            = 0;
+    pLVREV_Private->BypassMixer.Target2             = 0;
+    pLVREV_Private->BypassMixer.CallbackParam1      = 0;
+    pLVREV_Private->BypassMixer.pCallbackHandle1    = LVM_NULL;
+    pLVREV_Private->BypassMixer.pGeneralPurpose1    = LVM_NULL;
+    pLVREV_Private->BypassMixer.pCallBack1          = LVM_NULL;
+    pLVREV_Private->BypassMixer.CallbackSet1        = LVM_FALSE;
+    pLVREV_Private->BypassMixer.Current1            = 0x7fffffff;
+    pLVREV_Private->BypassMixer.Target1             = 0x7fffffff;
+
+    pLVREV_Private->RoomSizeInms                    = 100;  // 100 msec
+
+
+    /*
+     *  Set the output gain mixer parameters
+     */
+    pLVREV_Private->GainMixer.CallbackParam      = 0;
+    pLVREV_Private->GainMixer.pCallbackHandle    = LVM_NULL;
+    pLVREV_Private->GainMixer.pGeneralPurpose    = LVM_NULL;
+    pLVREV_Private->GainMixer.pCallBack          = LVM_NULL;
+    pLVREV_Private->GainMixer.CallbackSet        = LVM_FALSE;
+    pLVREV_Private->GainMixer.Current            = 0x03ffffff;
+    pLVREV_Private->GainMixer.Target             = 0x03ffffff;
+
+
+    /*
+     * Set the All-Pass Filter mixers
+     */
+    for (i=0; i<4; i++)
+    {
+        pLVREV_Private->pOffsetA[i] = pLVREV_Private->pDelay_T[i];
+        pLVREV_Private->pOffsetB[i] = pLVREV_Private->pDelay_T[i];
+        /* Delay tap selection mixer */
+        pLVREV_Private->Mixer_APTaps[i].CallbackParam2   = 0;
+        pLVREV_Private->Mixer_APTaps[i].pCallbackHandle2 = LVM_NULL;
+        pLVREV_Private->Mixer_APTaps[i].pGeneralPurpose2 = LVM_NULL;
+        pLVREV_Private->Mixer_APTaps[i].pCallBack2       = LVM_NULL;
+        pLVREV_Private->Mixer_APTaps[i].CallbackSet2     = LVM_FALSE;
+        pLVREV_Private->Mixer_APTaps[i].Current2         = 0;
+        pLVREV_Private->Mixer_APTaps[i].Target2          = 0;
+        pLVREV_Private->Mixer_APTaps[i].CallbackParam1   = 0;
+        pLVREV_Private->Mixer_APTaps[i].pCallbackHandle1 = LVM_NULL;
+        pLVREV_Private->Mixer_APTaps[i].pGeneralPurpose1 = LVM_NULL;
+        pLVREV_Private->Mixer_APTaps[i].pCallBack1       = LVM_NULL;
+        pLVREV_Private->Mixer_APTaps[i].CallbackSet1     = LVM_FALSE;
+        pLVREV_Private->Mixer_APTaps[i].Current1         = 0;
+        pLVREV_Private->Mixer_APTaps[i].Target1          = 0x7fffffff;
+        /* Feedforward mixer */
+        pLVREV_Private->Mixer_SGFeedforward[i].CallbackParam   = 0;
+        pLVREV_Private->Mixer_SGFeedforward[i].pCallbackHandle = LVM_NULL;
+        pLVREV_Private->Mixer_SGFeedforward[i].pGeneralPurpose = LVM_NULL;
+        pLVREV_Private->Mixer_SGFeedforward[i].pCallBack       = LVM_NULL;
+        pLVREV_Private->Mixer_SGFeedforward[i].CallbackSet     = LVM_FALSE;
+        pLVREV_Private->Mixer_SGFeedforward[i].Current         = 0;
+        pLVREV_Private->Mixer_SGFeedforward[i].Target          = 0;
+        /* Feedback mixer */
+        pLVREV_Private->Mixer_SGFeedback[i].CallbackParam   = 0;
+        pLVREV_Private->Mixer_SGFeedback[i].pCallbackHandle = LVM_NULL;
+        pLVREV_Private->Mixer_SGFeedback[i].pGeneralPurpose = LVM_NULL;
+        pLVREV_Private->Mixer_SGFeedback[i].pCallBack       = LVM_NULL;
+        pLVREV_Private->Mixer_SGFeedback[i].CallbackSet     = LVM_FALSE;
+        pLVREV_Private->Mixer_SGFeedback[i].Current         = 0;
+        pLVREV_Private->Mixer_SGFeedback[i].Target          = 0;
+        /* Feedback gain mixer */
+        pLVREV_Private->FeedbackMixer[i].CallbackParam    = 0;
+        pLVREV_Private->FeedbackMixer[i].pCallbackHandle  = LVM_NULL;
+        pLVREV_Private->FeedbackMixer[i].pGeneralPurpose  = LVM_NULL;
+        pLVREV_Private->FeedbackMixer[i].pCallBack        = LVM_NULL;
+        pLVREV_Private->FeedbackMixer[i].CallbackSet      = LVM_FALSE;
+        pLVREV_Private->FeedbackMixer[i].Current          = 0;
+        pLVREV_Private->FeedbackMixer[i].Target           = 0;
+    }
+    /* Delay tap index */
+    pLVREV_Private->A_DelaySize[0] = LVREV_MAX_AP0_DELAY;
+    pLVREV_Private->B_DelaySize[0] = LVREV_MAX_AP0_DELAY;
+    pLVREV_Private->A_DelaySize[1] = LVREV_MAX_AP1_DELAY;
+    pLVREV_Private->B_DelaySize[1] = LVREV_MAX_AP1_DELAY;
+    pLVREV_Private->A_DelaySize[2] = LVREV_MAX_AP2_DELAY;
+    pLVREV_Private->B_DelaySize[2] = LVREV_MAX_AP2_DELAY;
+    pLVREV_Private->A_DelaySize[3] = LVREV_MAX_AP3_DELAY;
+    pLVREV_Private->B_DelaySize[3] = LVREV_MAX_AP3_DELAY;
+
+
+    LVREV_ClearAudioBuffers(*phInstance);
+
+    return LVREV_SUCCESS;
+}
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_GetMemoryTable.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetMemoryTable.c
new file mode 100755
index 0000000..e16a3d3
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_GetMemoryTable.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: beq07716 $*/
+/*     $Revision: 1007 $*/
+/*     $Date: 2010-06-28 14:06:36 +0200 (Mon, 28 Jun 2010) $*/
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+#include "InstAlloc.h"
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_GetMemoryTable                                        */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  This function is used for memory allocation and free. It can be called in           */
+/*  two ways:                                                                           */
+/*                                                                                      */
+/*  hInstance = NULL                Returns the memory requirements                     */
+/*  hInstance = Instance handle     Returns the memory requirements and allocated       */
+/*                                  base addresses.                                     */
+/*                                                                                      */
+/*  When this function is called for memory allocation (hInstance=NULL) the memory      */
+/*  base address pointers are NULL on return.                                           */
+/*                                                                                      */
+/*  When the function is called for free (hInstance = Instance Handle) the memory       */
+/*  table returns the allocated memory and base addresses used during initialisation.   */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance Handle                                             */
+/*  pMemoryTable            Pointer to an empty memory table                            */
+/*  pInstanceParams         Pointer to the instance parameters                          */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_Success           Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When pMemoryTable is NULL                                   */
+/*  LVREV_NULLADDRESS       When requesting memory requirements and pInstanceParams     */
+/*                          is NULL                                                     */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1.  This function may be interrupted by the LVREV_Process function                  */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_GetMemoryTable(LVREV_Handle_t           hInstance,
+                                           LVREV_MemoryTable_st     *pMemoryTable,
+                                           LVREV_InstanceParams_st  *pInstanceParams)
+{
+
+    INST_ALLOC              SlowData;
+    INST_ALLOC              FastData;
+    INST_ALLOC              FastCoef;
+    INST_ALLOC              Temporary;
+    LVM_INT16               i;
+    LVM_UINT16              MaxBlockSize;
+
+
+    /*
+     * Check for error conditions
+     */
+    /* Check for NULL pointer */
+    if (pMemoryTable == LVM_NULL)
+    {
+        return(LVREV_NULLADDRESS);
+    }
+
+    /*
+     * Check all instance parameters are in range
+     */
+    if (pInstanceParams != LVM_NULL)
+    {
+        /*
+         * Call for memory allocation, so check the parameters
+         */
+        /* Check for a non-zero block size */
+        if (pInstanceParams->MaxBlockSize == 0)
+        {
+            return LVREV_OUTOFRANGE;
+        }
+
+        /* Check for a valid number of delay lines */
+        if ((pInstanceParams->NumDelays != LVREV_DELAYLINES_1) &&
+            (pInstanceParams->NumDelays != LVREV_DELAYLINES_2) &&
+            (pInstanceParams->NumDelays != LVREV_DELAYLINES_4))
+        {
+            return LVREV_OUTOFRANGE;
+        }
+    }
+
+    /*
+     * Initialise the InstAlloc instances
+     */
+    InstAlloc_Init(&SlowData,  (void *)LVM_NULL);
+    InstAlloc_Init(&FastData,  (void *)LVM_NULL);
+    InstAlloc_Init(&FastCoef,  (void *)LVM_NULL);
+    InstAlloc_Init(&Temporary, (void *)LVM_NULL);
+
+
+    /*
+     * Fill in the memory table
+     */
+    if (hInstance == LVM_NULL)
+    {
+        /*
+         * Check for null pointers
+         */
+        if (pInstanceParams == LVM_NULL)
+        {
+            return(LVREV_NULLADDRESS);
+        }
+
+
+        /*
+         * Select the maximum internal block size
+         */
+        if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_4)
+        {
+            MaxBlockSize = LVREV_MAX_AP3_DELAY;
+        }
+        else if(pInstanceParams->NumDelays ==LVREV_DELAYLINES_2)
+        {
+            MaxBlockSize = LVREV_MAX_AP1_DELAY;
+        }
+        else
+        {
+            MaxBlockSize = LVREV_MAX_AP0_DELAY;
+        }
+
+        if(MaxBlockSize>pInstanceParams->MaxBlockSize)
+        {
+            MaxBlockSize=pInstanceParams->MaxBlockSize;
+        }
+
+
+        /*
+         * Slow data memory
+         */
+        InstAlloc_AddMember(&SlowData, sizeof(LVREV_Instance_st));
+        pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size         = InstAlloc_GetTotal(&SlowData);
+        pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Type         = LVM_PERSISTENT_SLOW_DATA;
+        pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;
+
+
+        /*
+         * Persistent fast data memory
+         */
+        InstAlloc_AddMember(&FastData, sizeof(LVREV_FastData_st));
+        if(pInstanceParams->NumDelays == LVREV_DELAYLINES_4)
+        {
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T3_DELAY  * sizeof(LVM_INT32));
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T2_DELAY  * sizeof(LVM_INT32));
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
+        }
+
+        if(pInstanceParams->NumDelays == LVREV_DELAYLINES_2)
+        {
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T1_DELAY * sizeof(LVM_INT32));
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
+        }
+
+        if(pInstanceParams->NumDelays == LVREV_DELAYLINES_1)
+        {
+            InstAlloc_AddMember(&FastData, LVREV_MAX_T0_DELAY * sizeof(LVM_INT32));
+        }
+
+        pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size         = InstAlloc_GetTotal(&FastData);
+        pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Type         = LVM_PERSISTENT_FAST_DATA;
+        pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;
+
+
+        /*
+         * Persistent fast coefficient memory
+         */
+        InstAlloc_AddMember(&FastCoef, sizeof(LVREV_FastCoef_st));
+        pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size         = InstAlloc_GetTotal(&FastCoef);
+        pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Type         = LVM_PERSISTENT_FAST_COEF;
+        pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;
+
+
+        /*
+         * Temporary fast memory
+         */
+        InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);          /* General purpose scratch memory */
+        InstAlloc_AddMember(&Temporary, 2*sizeof(LVM_INT32) * MaxBlockSize);        /* Mono->stereo input saved for end mix */
+
+        if(pInstanceParams->NumDelays == LVREV_DELAYLINES_4)
+        {
+            for(i=0; i<4; i++)
+            {
+                InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);      /* A Scratch buffer for each delay line */
+            }
+        }
+
+        if(pInstanceParams->NumDelays == LVREV_DELAYLINES_2)
+        {
+            for(i=0; i<2; i++)
+            {
+                InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);      /* A Scratch buffer for each delay line */
+            }
+        }
+
+        if(pInstanceParams->NumDelays == LVREV_DELAYLINES_1)
+        {
+            for(i=0; i<1; i++)
+            {
+                InstAlloc_AddMember(&Temporary, sizeof(LVM_INT32) * MaxBlockSize);      /* A Scratch buffer for each delay line */
+            }
+        }
+
+        pMemoryTable->Region[LVM_TEMPORARY_FAST].Size         = InstAlloc_GetTotal(&Temporary);
+        pMemoryTable->Region[LVM_TEMPORARY_FAST].Type         = LVM_TEMPORARY_FAST;
+        pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress = LVM_NULL;
+
+    }
+    else
+    {
+        LVREV_Instance_st   *pLVREV_Private = (LVREV_Instance_st *)hInstance;
+
+
+        /*
+         * Read back memory allocation table
+         */
+        *pMemoryTable = pLVREV_Private->MemoryTable;
+    }
+
+
+    return(LVREV_SUCCESS);
+}
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_Private.h b/media/libeffects/lvm/lib/Reverb/src/LVREV_Private.h
new file mode 100755
index 0000000..896b051
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_Private.h
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp007753 $ */
+/*     $Revision: 1316 $ */
+/*     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+#ifndef __LVREV_PRIVATE_H__
+#define __LVREV_PRIVATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV.h"
+#include "LVREV_Tables.h"
+#include "BIQUAD.h"
+#include "Filter.h"
+#include "VectorArithmetic.h"
+#include "Mixer.h"
+#include "LVM_Macros.h"
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Defines                                                                             */
+/*                                                                                      */
+/****************************************************************************************/
+/* General */
+#define ONE_OVER_SQRT_TWO               23170           /* 1/sqrt(2) * 2^15 */
+#define LVREV_B_8_on_1000            17179869           /* 0.8 * 2^31 */
+#define LVREV_HEADROOM                   8192           /* -12dB * 2^15 */
+#define LVREV_2_9_INQ29           1583769190L           /* 2.9 in Q29 format */
+#define LVREV_MIN3DB                   0x5A82           /* -3dB in Q15 format */
+
+/* Intenal constants */
+#define LVREV_LP_Poly_Order                 4
+#define LVREV_LP_Poly_Shift                 5
+#define LVREV_T_3_Power_0_on_4          32768
+#define LVREV_T_3_Power_1_on_4          43125
+#define LVREV_T_3_Power_2_on_4          56755
+#define LVREV_T_3_Power_3_on_4          74694
+#define LVREV_T60_SCALE                306774           /*(32767/7000)<<16 */
+#define LVREV_T_3_Power_minus0_on_4     32767           /* 3^(-0/4) * 2^15 */
+#define LVREV_T_3_Power_minus1_on_4     24898           /* 3^(-1/4) * 2^15 */
+#define LVREV_T_3_Power_minus2_on_4     18919           /* 3^(-2/4) * 2^15 */
+#define LVREV_T_3_Power_minus3_on_4     14375           /* 3^(-3/4) * 2^15 */
+#define LVREV_MAX_T3_DELAY               2527           /* ((48000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1000 */
+#define LVREV_MAX_T2_DELAY               3326           /* ((48000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1000 */
+#define LVREV_MAX_T1_DELAY               4377           /* ((48000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1000 */
+#define LVREV_MAX_T0_DELAY               5760           /* ((48000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1000 */
+#define LVREV_MAX_AP3_DELAY              1685           /* ((48000 * 120 * LVREV_T_3_Power_minus3_on_4) >> 15) / 1500 */
+#define LVREV_MAX_AP2_DELAY              2218           /* ((48000 * 120 * LVREV_T_3_Power_minus2_on_4) >> 15) / 1500 */
+#define LVREV_MAX_AP1_DELAY              2918           /* ((48000 * 120 * LVREV_T_3_Power_minus1_on_4) >> 15) / 1500 */
+#define LVREV_MAX_AP0_DELAY              3840           /* ((48000 * 120 * LVREV_T_3_Power_minus0_on_4) >> 15) / 1500 */
+#define LVREV_BYPASSMIXER_TC             1000           /* Bypass mixer time constant*/
+#define LVREV_ALLPASS_TC                 1000           /* All-pass filter time constant */
+#define LVREV_ALLPASS_TAP_TC             10000           /* All-pass filter dely tap change */
+#define LVREV_FEEDBACKMIXER_TC            100           /* Feedback mixer time constant*/
+#define LVREV_OUTPUTGAIN_SHIFT              5           /* Bits shift for output gain correction */
+
+/* Parameter limits */
+#define LVREV_NUM_FS                        9           /* Number of supported sample rates */
+#define LVREV_MAXBLKSIZE_LIMIT             64           /* Maximum block size low limit */
+#define LVREV_MAX_LEVEL                   100           /* Maximum level, 100% */
+#define LVREV_MIN_LPF_CORNER               50           /* Low pass filter limits */
+#define LVREV_MAX_LPF_CORNER            23999
+#define LVREV_MIN_HPF_CORNER               20           /* High pass filrer limits */
+#define LVREV_MAX_HPF_CORNER             1000
+#define LVREV_MAX_T60                    7000           /* Maximum T60 time in ms */
+#define LVREV_MAX_DENSITY                 100           /* Maximum density, 100% */
+#define LVREV_MAX_DAMPING                 100           /* Maximum damping, 100% */
+#define LVREV_MAX_ROOMSIZE                100           /* Maximum room size, 100% */
+
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Structures                                                                          */
+/*                                                                                      */
+/****************************************************************************************/
+/* Fast data structure */
+typedef struct
+{
+
+    Biquad_1I_Order1_Taps_t HPTaps;                     /* High pass filter taps */
+    Biquad_1I_Order1_Taps_t LPTaps;                     /* Low pass filter taps */
+    Biquad_1I_Order1_Taps_t RevLPTaps[4];               /* Reverb low pass filters taps */
+
+} LVREV_FastData_st;
+
+
+/* Fast coefficient structure */
+typedef struct
+{
+
+    Biquad_Instance_t       HPCoefs;                    /* High pass filter coefficients */
+    Biquad_Instance_t       LPCoefs;                    /* Low pass filter coefficients */
+    Biquad_Instance_t       RevLPCoefs[4];              /* Reverb low pass filters coefficients */
+
+} LVREV_FastCoef_st;
+
+
+/* Instance parameter structure */
+typedef struct
+{
+    /* General */
+    LVREV_InstanceParams_st InstanceParams;             /* Initialisation time instance parameters */
+    LVREV_MemoryTable_st    MemoryTable;                /* Memory table */
+    LVREV_ControlParams_st  CurrentParams;              /* Parameters being used */
+    LVREV_ControlParams_st  NewParams;                  /* New parameters from the calling application */
+    LVM_CHAR                bControlPending;            /* Flag to indicate new parameters are available */
+    LVM_CHAR                bFirstControl;              /* Flag to indicate that the control function is called for the first time */
+    LVM_CHAR                bDisableReverb;             /* Flag to indicate that the mix level is 0% and the reverb can be disabled */
+    LVM_INT32               RoomSizeInms;               /* Room size in msec */
+    LVM_INT32               MaxBlkLen;                  /* Maximum block size for internal processing */
+
+    /* Aligned memory pointers */
+    LVREV_FastData_st       *pFastData;                 /* Fast data memory base address */
+    LVREV_FastCoef_st       *pFastCoef;                 /* Fast coefficient memory base address */
+    LVM_INT32               *pScratchDelayLine[4];      /* Delay line scratch memory */
+    LVM_INT32               *pScratch;                  /* Multi ussge scratch */
+    LVM_INT32               *pInputSave;                /* Reverb block input save for dry/wet mixing*/
+
+    /* Feedback matrix */
+    Mix_1St_Cll_t           FeedbackMixer[4];           /* Mixer for Pop and Click Supression caused by feedback Gain */
+
+    /* All-Pass Filter */
+    LVM_INT32               T[4];                       /* Maximum delay size of buffer */
+    LVM_INT32               *pDelay_T[4];               /* Pointer to delay buffers */
+    LVM_INT32               Delay_AP[4];                /* Offset to AP delay buffer start */
+    LVM_INT16               AB_Selection;               /* Smooth from tap A to B when 1 otherwise B to A */
+    LVM_INT32               A_DelaySize[4];             /* A delay length in samples */
+    LVM_INT32               B_DelaySize[4];             /* B delay length in samples */
+    LVM_INT32               *pOffsetA[4];               /* Offset for the A delay tap */
+    LVM_INT32               *pOffsetB[4];               /* Offset for the B delay tap */
+    Mix_2St_Cll_t           Mixer_APTaps[4];            /* Smoothed AP delay mixer */
+    Mix_1St_Cll_t           Mixer_SGFeedback[4];        /* Smoothed SAfeedback gain */
+    Mix_1St_Cll_t           Mixer_SGFeedforward[4];     /* Smoothed AP feedforward gain */
+
+    /* Output gain */
+    Mix_2St_Cll_t           BypassMixer;                /* Dry/wet mixer */
+    LVM_INT16               Gain;                       /* Gain applied to output to maintain average signal power */
+    Mix_1St_Cll_t           GainMixer;                  /* Gain smoothing */
+
+} LVREV_Instance_st;
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Function prototypes                                                                 */
+/*                                                                                      */
+/****************************************************************************************/
+
+LVREV_ReturnStatus_en   LVREV_ApplyNewSettings(LVREV_Instance_st     *pPrivate);
+
+void                    ReverbBlock(LVM_INT32           *pInput,
+                                    LVM_INT32           *pOutput,
+                                    LVREV_Instance_st   *pPrivate,
+                                    LVM_UINT16          NumSamples);
+
+LVM_INT32               BypassMixer_Callback(void       *pCallbackData,
+                                             void       *pGeneralPurpose,
+                                             LVM_INT16  GeneralPurpose );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /** __LVREV_PRIVATE_H__ **/
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c
new file mode 100755
index 0000000..822ac8f
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_Process.c
@@ -0,0 +1,550 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp007753 $ */
+/*     $Revision: 1316 $ */
+/*     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/* Includes                                                                             */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+#include "VectorArithmetic.h"
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_Process                                               */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Process function for the LVREV module.                                              */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pInData                 Pointer to the input data                                   */
+/*  pOutData                Pointer to the output data                                  */
+/*  NumSamples              Number of samples in the input buffer                       */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_Success           Succeeded                                                   */
+/*  LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size           */
+/*  LVREV_NULLADDRESS       When one of hInstance, pInData or pOutData is NULL          */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1. The input and output buffers must be 32-bit aligned                              */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_Process(LVREV_Handle_t      hInstance,
+                                    const LVM_INT32     *pInData,
+                                    LVM_INT32           *pOutData,
+                                    const LVM_UINT16    NumSamples)
+{
+   LVREV_Instance_st     *pLVREV_Private = (LVREV_Instance_st *)hInstance;
+   LVM_INT32             *pInput  = (LVM_INT32 *)pInData;
+   LVM_INT32             *pOutput = pOutData;
+   LVM_INT32             SamplesToProcess, RemainingSamples, format;
+
+    /*
+     * Check for error conditions
+     */
+
+    /* Check for NULL pointers */
+    if((hInstance == LVM_NULL) || (pInData == LVM_NULL) || (pOutData == LVM_NULL))
+    {
+        return LVREV_NULLADDRESS;
+    }
+
+
+    /*
+     * Apply the new controls settings if required
+     */
+    if(pLVREV_Private->bControlPending == LVM_TRUE)
+    {
+        LVREV_ReturnStatus_en   errorCode;
+
+        /*
+         * Clear the pending flag and update the control settings
+         */
+        pLVREV_Private->bControlPending = LVM_FALSE;
+
+        errorCode = LVREV_ApplyNewSettings (pLVREV_Private);
+
+        if(errorCode != LVREV_SUCCESS)
+        {
+            return errorCode;
+        }
+    }
+
+    /*
+     * Trap the case where the number of samples is zero.
+     */
+    if (NumSamples == 0)
+    {
+        return LVREV_SUCCESS;
+    }
+
+    RemainingSamples = (LVM_INT32)NumSamples;
+
+    format = 1;
+    if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
+    {
+        format = 2;
+    }
+
+    while (RemainingSamples!=0)
+    {
+        /*
+         * If OFF copy and reformat the data as necessary
+         */
+        if (pLVREV_Private->CurrentParams.OperatingMode == LVM_MODE_OFF)
+        {
+            if((pInput != pOutput) || (pLVREV_Private->CurrentParams.SourceFormat == LVM_MONO))
+            {
+                /*
+                 * Copy the data to the output buffer
+                 */
+
+                if (pLVREV_Private->CurrentParams.SourceFormat != LVM_MONO)
+                {
+                    RemainingSamples = (RemainingSamples << 1);           /* Stereo data */
+                }
+
+                Copy_16((LVM_INT16 *)pInput,
+                        (LVM_INT16 *)pOutput,
+                        (LVM_INT16)(RemainingSamples << 1));
+            }
+
+            RemainingSamples = 0;
+        }
+
+        /*
+         * Process the data
+         */
+        else
+        {
+
+            if(RemainingSamples >  pLVREV_Private->MaxBlkLen)
+            {
+                SamplesToProcess =  pLVREV_Private->MaxBlkLen;
+                RemainingSamples = (LVM_INT16)(RemainingSamples - SamplesToProcess);
+            }
+            else
+            {
+                SamplesToProcess = RemainingSamples;
+                RemainingSamples = 0;
+            }
+
+            ReverbBlock(pInput, pOutput, pLVREV_Private, (LVM_UINT16)SamplesToProcess);
+
+            pInput  = (LVM_INT32 *)(pInput +(SamplesToProcess*format));
+            pOutput = (LVM_INT32 *)(pOutput+(SamplesToProcess*format));
+        }
+    }
+
+    return LVREV_SUCCESS;
+}
+
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                ReverbBlock                                                 */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Process function for the LVREV module.                                              */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pInData                 Pointer to the input data                                   */
+/*  pOutData                Pointer to the output data                                  */
+/*  NumSamples              Number of samples in the input buffer                       */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVREV_Success           Succeeded                                                   */
+/*  LVREV_INVALIDNUMSAMPLES NumSamples was larger than the maximum block size           */
+/*  LVREV_NULLADDRESS       When one of hInstance, pInData or pOutData is NULL          */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1. The input and output buffers must be 32-bit aligned                              */
+/*                                                                                      */
+/****************************************************************************************/
+
+void ReverbBlock(LVM_INT32 *pInput, LVM_INT32 *pOutput, LVREV_Instance_st *pPrivate, LVM_UINT16 NumSamples)
+{
+    LVM_INT16   j, size;
+    LVM_INT32   *pDelayLine;
+    LVM_INT32   *pDelayLineInput = pPrivate->pScratch;
+    LVM_INT32   *pScratch = pPrivate->pScratch;
+    LVM_INT32   *pIn;
+    LVM_INT32   *pTemp = pPrivate->pInputSave;
+    LVM_INT32   NumberOfDelayLines;
+
+    /******************************************************************************
+     * All calculations will go into the buffer pointed to by pTemp, this will    *
+     * then be mixed with the original input to create the final output.          *
+     *                                                                            *
+     * When INPLACE processing is selected this must be a temporary buffer and    *
+     * hence this is the worst case, so for simplicity this will ALWAYS be so     *
+     *                                                                            *
+     * The input buffer will remain untouched until the output of the mixer if    *
+     * INPLACE processing is selected.                                            *
+     *                                                                            *
+     * The temp buffer will always be NumSamples in size regardless of MONO or    *
+     * STEREO input. In the case of stereo input all processing is done in MONO   *
+     * and the final output is converted to STEREO after the mixer                *
+     ******************************************************************************/
+
+    if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4 )
+    {
+        NumberOfDelayLines = 4;
+    }
+    else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2 )
+    {
+        NumberOfDelayLines = 2;
+    }
+    else
+    {
+        NumberOfDelayLines = 1;
+    }
+
+    if(pPrivate->CurrentParams.SourceFormat == LVM_MONO)
+    {
+        pIn = pInput;
+    }
+    else
+    {
+        /*
+         *  Stereo to mono conversion
+         */
+
+        From2iToMono_32( pInput,
+                         pTemp,
+                         (LVM_INT16)NumSamples);
+
+        pIn = pTemp;
+    }
+
+    Mult3s_32x16(pIn,
+                 (LVM_INT16)LVREV_HEADROOM,
+                 pTemp,
+                 (LVM_INT16)NumSamples);
+
+    /*
+     *  High pass filter
+     */
+    FO_1I_D32F32C31_TRC_WRA_01( &pPrivate->pFastCoef->HPCoefs,
+                                pTemp,
+                                pTemp,
+                                (LVM_INT16)NumSamples);
+    /*
+     *  Low pass filter
+     */
+    FO_1I_D32F32C31_TRC_WRA_01( &pPrivate->pFastCoef->LPCoefs,
+                                pTemp,
+                                pTemp,
+                                (LVM_INT16)NumSamples);
+
+    /*
+     *  Process all delay lines
+     */
+
+    for(j = 0; j < NumberOfDelayLines; j++)
+    {
+        pDelayLine = pPrivate->pScratchDelayLine[j];
+
+        /*
+         * All-pass filter with pop and click suppression
+         */
+        /* Get the smoothed, delayed output. Put it in the output buffer */
+        MixSoft_2St_D32C31_SAT(&pPrivate->Mixer_APTaps[j],
+                               pPrivate->pOffsetA[j],
+                               pPrivate->pOffsetB[j],
+                               pDelayLine,
+                               (LVM_INT16)NumSamples);
+        /* Re-align the all pass filter delay buffer and copying the fixed delay data to the AP delay in the process */
+        Copy_16((LVM_INT16 *)&pPrivate->pDelay_T[j][NumSamples],
+                (LVM_INT16 *)pPrivate->pDelay_T[j],
+                (LVM_INT16)((pPrivate->T[j]-NumSamples) << 1));         /* 32-bit data */
+        /* Apply the smoothed feedback and save to fixed delay input (currently empty) */
+        MixSoft_1St_D32C31_WRA(&pPrivate->Mixer_SGFeedback[j],
+                               pDelayLine,
+                               &pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
+                               (LVM_INT16)NumSamples);
+        /* Sum into the AP delay line */
+        Mac3s_Sat_32x16(&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
+                        -0x7fff,                                        /* Invert since the feedback coefficient is negative */
+                        &pPrivate->pDelay_T[j][pPrivate->Delay_AP[j]-NumSamples],
+                        (LVM_INT16)NumSamples);
+        /* Apply smoothed feedforward sand save to fixed delay input (currently empty) */
+        MixSoft_1St_D32C31_WRA(&pPrivate->Mixer_SGFeedforward[j],
+                               &pPrivate->pDelay_T[j][pPrivate->Delay_AP[j]-NumSamples],
+                               &pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
+                               (LVM_INT16)NumSamples);
+        /* Sum into the AP output */
+        Mac3s_Sat_32x16(&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
+                        0x7fff,
+                        pDelayLine,
+                        (LVM_INT16)NumSamples);
+
+        /*
+         *  Feedback gain
+         */
+        MixSoft_1St_D32C31_WRA(&pPrivate->FeedbackMixer[j], pDelayLine, pDelayLine, NumSamples);
+
+        /*
+         *  Low pass filter
+         */
+        FO_1I_D32F32C31_TRC_WRA_01( &pPrivate->pFastCoef->RevLPCoefs[j],
+                                    pDelayLine,
+                                    pDelayLine,
+                                    (LVM_INT16)NumSamples);
+    }
+
+    /*
+     *  Apply rotation matrix and delay samples
+     */
+    for(j = 0; j < NumberOfDelayLines; j++)
+    {
+
+        Copy_16( (LVM_INT16*)(pTemp),
+                 (LVM_INT16*)(pDelayLineInput),
+                 (LVM_INT16)(NumSamples << 1));
+
+        /*
+         *  Rotation matrix mix
+         */
+        switch(j)
+        {
+            case 3:
+                /*
+                 *  Add delay line 1 and 2 contribution
+                 */
+                 Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+                 Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[2], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+
+                break;
+            case 2:
+
+                /*
+                 *  Add delay line 0 and 3 contribution
+                 */
+                 Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+                 Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[3], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+
+                break;
+            case 1:
+                if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
+                {
+                    /*
+                     *  Add delay line 0 and 3 contribution
+                     */
+                    Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+                    Add2_Sat_32x32(pPrivate->pScratchDelayLine[3], pDelayLineInput, (LVM_INT16)NumSamples);
+
+                }
+                else
+                {
+                    /*
+                     *  Add delay line 0 and 1 contribution
+                     */
+                     Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+                     Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+
+                }
+                break;
+            case 0:
+                if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_4)
+                {
+                    /*
+                     *  Add delay line 1 and 2 contribution
+                     */
+                    Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+                    Add2_Sat_32x32(pPrivate->pScratchDelayLine[2], pDelayLineInput, (LVM_INT16)NumSamples);
+
+                }
+                else if(pPrivate->InstanceParams.NumDelays == LVREV_DELAYLINES_2)
+                {
+                    /*
+                     *  Add delay line 0 and 1 contribution
+                     */
+                    Add2_Sat_32x32(pPrivate->pScratchDelayLine[0], pDelayLineInput, (LVM_INT16)NumSamples);
+                    Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[1], -0x8000, pDelayLineInput, (LVM_INT16)NumSamples);
+
+                }
+                else
+                {
+                    /*
+                     *  Add delay line 0 contribution
+                     */
+
+                    /*             SOURCE                          DESTINATION*/
+                    Add2_Sat_32x32(pPrivate->pScratchDelayLine[0], pDelayLineInput, (LVM_INT16)NumSamples);
+                }
+                break;
+            default:
+                break;
+        }
+
+        /*
+         *  Delay samples
+         */
+        Copy_16((LVM_INT16 *)pDelayLineInput,
+                (LVM_INT16 *)&pPrivate->pDelay_T[j][pPrivate->T[j]-NumSamples],
+                (LVM_INT16)(NumSamples << 1));              /* 32-bit data */
+
+    }
+
+
+    /*
+     *  Create stereo output
+     */
+    switch(pPrivate->InstanceParams.NumDelays)
+    {
+        case LVREV_DELAYLINES_4:
+             Add2_Sat_32x32(pPrivate->pScratchDelayLine[3],
+                            pPrivate->pScratchDelayLine[0],
+                            (LVM_INT16)NumSamples);
+             Add2_Sat_32x32(pPrivate->pScratchDelayLine[2],
+                            pPrivate->pScratchDelayLine[1],
+                            (LVM_INT16)NumSamples);
+
+             if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
+             {
+                JoinTo2i_32x32(pPrivate->pScratchDelayLine[0],
+                               pPrivate->pScratchDelayLine[1],
+                               pTemp,
+                               (LVM_INT16)NumSamples);
+
+             }
+             else
+             {
+                 Add2_Sat_32x32(pPrivate->pScratchDelayLine[1],
+                                pPrivate->pScratchDelayLine[0],
+                                (LVM_INT16)NumSamples);
+
+                /*Apply 3-dB gain in-order to compensate for the gain change in stereo mode*/
+                Mult3s_32x16(pPrivate->pScratchDelayLine[0],
+                             LVREV_MIN3DB,
+                             pTemp,
+                             (LVM_INT16)NumSamples);
+             }
+            break;
+        case LVREV_DELAYLINES_2:
+
+             Copy_16( (LVM_INT16*)pPrivate->pScratchDelayLine[1],
+                      (LVM_INT16*)pScratch,
+                      (LVM_INT16)(NumSamples << 1));
+
+
+
+             if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
+             {
+
+                Mac3s_Sat_32x16(pPrivate->pScratchDelayLine[0],
+                                -0x8000,
+                                pScratch,
+                                (LVM_INT16)NumSamples);
+             }
+
+             Add2_Sat_32x32(pPrivate->pScratchDelayLine[1],
+                            pPrivate->pScratchDelayLine[0],
+                            (LVM_INT16)NumSamples);
+
+
+             if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
+             {
+                 JoinTo2i_32x32(pPrivate->pScratchDelayLine[0],
+                                pScratch,
+                                pTemp,
+                                (LVM_INT16)NumSamples);
+             }
+             else
+             {
+                Copy_16(    (LVM_INT16*)pPrivate->pScratchDelayLine[0],
+                            (LVM_INT16*)pTemp,
+                            (LVM_INT16)(NumSamples << 1));
+
+             }
+            break;
+        case LVREV_DELAYLINES_1:
+            if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
+            {
+
+                MonoTo2I_32(pPrivate->pScratchDelayLine[0],
+                            pTemp,
+                            (LVM_INT16)NumSamples);
+            }
+            else
+            {
+                pTemp = pPrivate->pScratchDelayLine[0];
+            }
+            break;
+        default:
+            break;
+    }
+
+
+    /*
+     *  Dry/wet mixer
+     */
+    if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
+    {
+        size = (LVM_INT16)(NumSamples << 1);
+    }
+    else
+    {
+        size = (LVM_INT16)NumSamples;
+    }
+
+    MixSoft_2St_D32C31_SAT(&pPrivate->BypassMixer,
+                           pInput,
+                           pTemp,
+                           pOutput,
+                           size);
+
+    /* Apply Gain*/
+    if(pPrivate->CurrentParams.SourceFormat != LVM_MONO)
+    {
+        size = (LVM_INT16)(NumSamples << 1);
+    }
+    else
+    {
+        size = (LVM_INT16)NumSamples;
+    }
+
+    Shift_Sat_v32xv32 (LVREV_OUTPUTGAIN_SHIFT,
+                       pOutput,
+                       pOutput,
+                       size);
+
+    MixSoft_1St_D32C31_WRA(&pPrivate->GainMixer,
+                           pOutput,
+                           pOutput,
+                           size);
+    return;
+}
+
+
+/* End of file */
+
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_SetControlParameters.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_SetControlParameters.c
new file mode 100755
index 0000000..124fd3b
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_SetControlParameters.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: nxp007753 $ */
+/*     $Revision: 1316 $ */
+/*     $Date: 2010-07-23 11:53:24 +0200 (Fri, 23 Jul 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+
+/****************************************************************************************/
+/*                                                                                      */
+/* FUNCTION:                LVREV_SetControlParameters                                  */
+/*                                                                                      */
+/* DESCRIPTION:                                                                         */
+/*  Sets or changes the LVREV module parameters.                                        */
+/*                                                                                      */
+/* PARAMETERS:                                                                          */
+/*  hInstance               Instance handle                                             */
+/*  pNewParams              Pointer to a parameter structure                            */
+/*                                                                                      */
+/* RETURNS:                                                                             */
+/*  LVM_Success             Succeeded                                                   */
+/*  LVREV_NULLADDRESS       When hInstance or pNewParams is NULL                        */
+/*  LVREV_OUTOFRANGE        When any of the new parameters is out of range              */
+/*                                                                                      */
+/* NOTES:                                                                               */
+/*  1.  This function may be interrupted by the LVREV_Process function                  */
+/*                                                                                      */
+/****************************************************************************************/
+LVREV_ReturnStatus_en LVREV_SetControlParameters(LVREV_Handle_t           hInstance,
+                                                 LVREV_ControlParams_st   *pNewParams)
+{
+
+    LVREV_Instance_st     *pLVREV_Private = (LVREV_Instance_st *)hInstance;
+
+
+    /*
+     * Check for error conditions
+     */
+    if((hInstance == LVM_NULL) || (pNewParams == LVM_NULL))
+    {
+        return LVREV_NULLADDRESS;
+    }
+
+    /*
+     * Check all new control parameters are in range
+     */
+    if(    ((pNewParams->OperatingMode != LVM_MODE_OFF) && (pNewParams->OperatingMode != LVM_MODE_ON))                                         ||
+        ((pNewParams->SampleRate != LVM_FS_8000) && (pNewParams->SampleRate != LVM_FS_11025) && (pNewParams->SampleRate != LVM_FS_12000)       &&
+        (pNewParams->SampleRate != LVM_FS_16000) && (pNewParams->SampleRate != LVM_FS_22050) && (pNewParams->SampleRate != LVM_FS_24000)       &&
+        (pNewParams->SampleRate != LVM_FS_32000) && (pNewParams->SampleRate != LVM_FS_44100) && (pNewParams->SampleRate != LVM_FS_48000))      ||
+        ((pNewParams->SourceFormat != LVM_STEREO) && (pNewParams->SourceFormat != LVM_MONOINSTEREO) && (pNewParams->SourceFormat != LVM_MONO)) )
+    {
+        return (LVREV_OUTOFRANGE);
+    }
+
+
+    if (pNewParams->Level > LVREV_MAX_LEVEL)
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    if ((pNewParams->LPF < LVREV_MIN_LPF_CORNER) || (pNewParams->LPF > LVREV_MAX_LPF_CORNER))
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    if ((pNewParams->HPF < LVREV_MIN_HPF_CORNER) || (pNewParams->HPF > LVREV_MAX_HPF_CORNER))
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    if (pNewParams->T60 > LVREV_MAX_T60)
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    if (pNewParams->Density > LVREV_MAX_DENSITY)
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    if (pNewParams->Damping > LVREV_MAX_DAMPING)
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+    if (pNewParams->RoomSize > LVREV_MAX_ROOMSIZE)
+    {
+        return LVREV_OUTOFRANGE;
+    }
+
+
+
+    /*
+     * Copy the new parameters and set the flag to indicate they are available
+     */
+    pLVREV_Private->NewParams       = *pNewParams;
+    pLVREV_Private->bControlPending = LVM_TRUE;
+
+    return LVREV_SUCCESS;
+}
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.c b/media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.c
new file mode 100755
index 0000000..9249a31
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: beq07716 $ */
+/*     $Revision: 1011 $ */
+/*     $Date: 2010-06-28 15:07:08 +0200 (Mon, 28 Jun 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV.h"
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Tables                                                                              */
+/*                                                                                      */
+/****************************************************************************************/
+
+/* Table with supported sampling rates.  The table can be indexed using LVM_Fs_en       */
+const LVM_UINT16 LVM_FsTable[] = {
+    8000 ,
+    11025,
+    12000,
+    16000,
+    22050,
+    24000,
+    32000,
+    44100,
+    48000
+};
+
+/* Table with supported sampling rates.  The table can be indexed using LVM_Fs_en       */
+LVM_UINT16 LVM_GetFsFromTable(LVM_Fs_en FsIndex){
+    if (FsIndex > LVM_FS_48000)
+        return 0;
+
+    return (LVM_FsTable[FsIndex]);
+}
+
+/* In order to maintain consistant input and out put signal strengths
+   output gain/attenuation is applied. This gain depends on T60 and Rooms
+   size parameters. These polynomial coefficients are calculated experimentally.
+   First value in the table is room size
+   second value is  A0
+   third value is   A1
+   fourth value is  A2
+   fifth value is   A3
+   sixth value is   A4
+
+     shift value  is to be added array (to use LVM_Polynomial function)
+
+  The gain is calculated using variable x=(T60*32767/7000)*32768;
+
+   first values is used to get polynomial set for given room size,
+   For room sizes which are not in the table, linear interpolation can be used.
+
+  */
+
+/* Normalizing output including Reverb Level part (only shift up)*/
+const LVM_INT32 LVREV_GainPolyTable[24][5]={{1,17547434,128867434,-120988896,50761228,},
+                                            {2,18256869,172666902,-193169292,88345744,},
+                                            {3,16591311,139250151,-149667234,66770059,},
+                                            {4,17379977,170835131,-173579321,76278163,},
+                                            {5,18963512,210364934,-228623519,103435022,},
+                                            {6,17796318,135756417,-144084053,64327698,},
+                                            {7,17454695,174593214,-187513064,85146582,},
+                                            {8,17229257,140715570,-145790588,65361740,},
+                                            {9,17000547,163195946,-176733969,79562130,},
+                                            {10,16711699,142476304,-133339887,58366547,},
+                                            {13,18108419,149223697,-161762020,74397589,},
+                                            {15,16682043,124844884,-134284487,60082180,},
+                                            {17,16627346,120936430,-121766674,53146421,},
+                                            {20,17338325,125432694,-126616983,56534237,},
+                                            {25,16489146,99218217,-94597467,40616506,},
+                                            {30,15582373,84479043,-75365006,30952348,},
+                                            {40,16000669,84896611,-75031127,30696306,},
+                                            {50,15087054,71695031,-59349268,23279669,},
+                                            {60,15830714,68672971,-58211201,23671158,},
+                                            {70,15536061,66657972,-55901437,22560153,},
+                                            {75,15013145,48179917,-24138354,5232074,},
+                                            {80,15688738,50195036,-34206760,11515792,},
+                                            {90,16003322,48323661,-35607378,13153872,},
+                                            {100,15955223,48558201,-33706865,11715792,},
+                                            };
+
+/* End of file */
+
diff --git a/media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.h b/media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.h
new file mode 100755
index 0000000..98471be
--- /dev/null
+++ b/media/libeffects/lvm/lib/Reverb/src/LVREV_Tables.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2004-2010 NXP Software
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/****************************************************************************************/
+/*                                                                                      */
+/*     Project::                                                                        */
+/*     $Author: beq07716 $ */
+/*     $Revision: 773 $ */
+/*     $Date: 2010-06-14 10:43:54 +0200 (Mon, 14 Jun 2010) $ */
+/*                                                                                      */
+/****************************************************************************************/
+
+
+#ifndef _LVREV_TABLES_H_
+#define _LVREV_TABLES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Includes                                                                            */
+/*                                                                                      */
+/****************************************************************************************/
+#include "LVREV_Private.h"
+
+/****************************************************************************************/
+/*                                                                                      */
+/*  Definitions                                                                         */
+/*                                                                                      */
+/****************************************************************************************/
+
+extern const    LVM_UINT16  LVM_FsTable[];
+extern          LVM_UINT16  LVM_GetFsFromTable(LVM_Fs_en FsIndex);
+extern          LVM_INT32   LVREV_GainPolyTable[24][5];
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /** _LVREV_TABLES_H_ **/
+
+/* End of file */
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
index fea44bf..668b151 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Control.c
@@ -17,9 +17,9 @@
 
 /************************************************************************************
 
-     $Author: beq06068 $
-     $Revision: 1307 $
-     $Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
+     $Author: nxp007753 $
+     $Revision: 1331 $
+     $Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
 
 *************************************************************************************/
 
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
index 7ab6571..d8023d64 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Equaliser.c
@@ -18,8 +18,8 @@
 /************************************************************************************
 
      $Author: nxp007753 $
-     $Revision: 1315 $
-     $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
+     $Revision: 1331 $
+     $Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
 
 *************************************************************************************/
 
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
index f5f7cd0..82a8db2 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_Init.c
@@ -17,9 +17,9 @@
 
 /************************************************************************************
 
-     $Author: beq06068 $
-     $Revision: 1307 $
-     $Date: 2010-07-22 17:41:25 +0200 (Thu, 22 Jul 2010) $
+     $Author: nxp007753 $
+     $Revision: 1331 $
+     $Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
 
 *************************************************************************************/
 
diff --git a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
index b67d824..83748e6 100755
--- a/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
+++ b/media/libeffects/lvm/lib/StereoWidening/src/LVCS_StereoEnhancer.c
@@ -18,8 +18,8 @@
 /************************************************************************************
 
      $Author: nxp007753 $
-     $Revision: 1315 $
-     $Date: 2010-07-23 11:52:08 +0200 (Fri, 23 Jul 2010) $
+     $Revision: 1331 $
+     $Date: 2010-07-27 12:26:23 +0200 (Tue, 27 Jul 2010) $
 
 *************************************************************************************/
 
diff --git a/media/libeffects/lvm/wrapper/Android.mk b/media/libeffects/lvm/wrapper/Android.mk
index 7855dcd..2e9b9b4 100644
--- a/media/libeffects/lvm/wrapper/Android.mk
+++ b/media/libeffects/lvm/wrapper/Android.mk
@@ -34,3 +34,36 @@
 
 
 include $(BUILD_SHARED_LIBRARY)
+
+# reverb wrapper
+include $(CLEAR_VARS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES:= \
+    Reverb/EffectReverb.cpp
+
+LOCAL_MODULE:= libreverbwrapper
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
+
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_STATIC_LIBRARIES += libreverb
+
+LOCAL_SHARED_LIBRARIES := \
+     libcutils \
+
+ifeq ($(TARGET_SIMULATOR),true)
+LOCAL_LDLIBS += -ldl
+else
+LOCAL_SHARED_LIBRARIES += libdl
+endif
+
+LOCAL_C_INCLUDES += \
+    $(LOCAL_PATH)/Reverb \
+    $(LOCAL_PATH)/../lib/Common/lib/ \
+    $(LOCAL_PATH)/../lib/Reverb/lib/ \
+
+
+include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index bcd646a..798271e 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -66,7 +66,9 @@
 
 // Flag to allow a one time init of global memory, only happens on first call ever
 int LvmInitFlag = LVM_FALSE;
-SessionContext GlobalSessionMemory[32];
+int LvmSessionsActive = 0;
+SessionContext GlobalSessionMemory[LVM_MAX_SESSIONS];
+int SessionIndex[LVM_MAX_SESSIONS];
 
 // NXP SW BassBoost UUID
 const effect_descriptor_t gBassBoostDescriptor = {
@@ -125,24 +127,24 @@
 int  LvmEffect_disable         (EffectContext *pContext);
 void LvmEffect_free            (EffectContext *pContext);
 int  Effect_configure          (EffectContext *pContext, effect_config_t *pConfig);
-int  BassBoost_setParameter    (EffectContext *pContext, int32_t *pParam, void *pValue);
+int  BassBoost_setParameter    (EffectContext *pContext, void *pParam, void *pValue);
 int  BassBoost_getParameter    (EffectContext *pContext,
-                               int32_t        *pParam,
+                               void           *pParam,
                                size_t         *pValueSize,
                                void           *pValue);
-int  Virtualizer_setParameter  (EffectContext *pContext, int32_t *pParam, void *pValue);
+int  Virtualizer_setParameter  (EffectContext *pContext, void *pParam, void *pValue);
 int  Virtualizer_getParameter  (EffectContext *pContext,
-                               int32_t        *pParam,
+                               void           *pParam,
                                size_t         *pValueSize,
                                void           *pValue);
-int  Equalizer_setParameter    (EffectContext *pContext, int32_t *pParam, void *pValue);
+int  Equalizer_setParameter    (EffectContext *pContext, void *pParam, void *pValue);
 int  Equalizer_getParameter    (EffectContext *pContext,
-                                int32_t       *pParam,
+                                void          *pParam,
                                 size_t        *pValueSize,
                                 void          *pValue);
-int  Volume_setParameter       (EffectContext *pContext, int32_t *pParam, void *pValue);
+int  Volume_setParameter       (EffectContext *pContext, void *pParam, void *pValue);
 int  Volume_getParameter       (EffectContext *pContext,
-                                int32_t       *pParam,
+                                void          *pParam,
                                 size_t        *pValueSize,
                                 void          *pValue);
 
@@ -189,6 +191,7 @@
                             int32_t             ioId,
                             effect_interface_t  *pInterface){
     int ret;
+    int sessionNo;
     int i;
     EffectContext *pContext = new EffectContext;
 
@@ -199,7 +202,7 @@
         return -EINVAL;
     }
 
-    if((sessionId < 0)||(sessionId >= LVM_MAX_SESSIONS)){
+    if(sessionId < 0){
         LOGV("\tLVM_ERROR : EffectCreate sessionId is less than 0");
         return -EINVAL;
     }
@@ -210,16 +213,41 @@
         LvmGlobalBundle_init();
     }
 
+    LOGV("\tEffectCreate: There are %d LVM sessions acive\n", LvmSessionsActive);
+
+    // Find next available sessionNo
+    for(i=0; i<LVM_MAX_SESSIONS; i++){
+        if((SessionIndex[i] == -1)||(SessionIndex[i] == sessionId)){
+            sessionNo       = i;
+            SessionIndex[i] = sessionId;
+            LOGV("\tEffectCreate: Allocating SessionNo %d for SessionId %d\n", sessionNo,sessionId);
+            break;
+        }
+    }
+
+    if(i==LVM_MAX_SESSIONS){
+        LOGV("\tLVM_ERROR : Cannot find memory to allocate for current session");
+        return -EINVAL;
+    }
     // If this is the first create in this session
-    if(GlobalSessionMemory[sessionId].bBundledEffectsEnabled == LVM_FALSE){
-        LOGV("\tEffectCreate - This is the first effect in current session %d", sessionId);
-        LOGV("\tEffectCreate - Setting up Bundled Effects Instance for session %d", sessionId);
+    if(GlobalSessionMemory[sessionNo].bBundledEffectsEnabled == LVM_FALSE){
+        LOGV("\tEffectCreate - This is the first effect in current sessionId %d sessionNo %d",
+                sessionId, sessionNo);
 
-        GlobalSessionMemory[sessionId].bBundledEffectsEnabled = LVM_TRUE;
-        GlobalSessionMemory[sessionId].pBundledContext        = new BundledEffectContext;
+        LvmSessionsActive++;
 
-        pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext;
-        pContext->pBundledContext->SessionNo                = sessionId;
+        if(LvmSessionsActive >= LVM_MAX_SESSIONS){
+            LOGV("\tLVM_ERROR : Number of active session is greater than LVM_MAX_SESSIONS (%d)",
+                  LVM_MAX_SESSIONS);
+            return -EINVAL;
+        }
+
+        GlobalSessionMemory[sessionNo].bBundledEffectsEnabled = LVM_TRUE;
+        GlobalSessionMemory[sessionNo].pBundledContext        = new BundledEffectContext;
+
+        pContext->pBundledContext = GlobalSessionMemory[sessionNo].pBundledContext;
+        pContext->pBundledContext->SessionNo                = sessionNo;
+        pContext->pBundledContext->SessionId                = sessionId;
         pContext->pBundledContext->hInstance                = NULL;
         pContext->pBundledContext->bVolumeEnabled           = LVM_FALSE;
         pContext->pBundledContext->bEqualizerEnabled        = LVM_FALSE;
@@ -267,37 +295,39 @@
         }
     }
     else{
-        pContext->pBundledContext = GlobalSessionMemory[sessionId].pBundledContext;
+        LOGV("\tEffectCreate - Assigning memory for previously created effect on sessionNo %d",
+                sessionNo);
+        pContext->pBundledContext =
+                GlobalSessionMemory[sessionNo].pBundledContext;
     }
-
     LOGV("\tEffectCreate - pBundledContext is %p", pContext->pBundledContext);
 
     // Create each Effect
     if (memcmp(uuid, &gBassBoostDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Bass Boost
         LOGV("\tEffectCreate - Effect to be created is LVM_BASS_BOOST");
-        GlobalSessionMemory[sessionId].bBassInstantiated = LVM_TRUE;
+        GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBassInstantiated = LVM_TRUE;
 
         pContext->itfe       = &gLvmEffectInterface;
         pContext->EffectType = LVM_BASS_BOOST;
     } else if (memcmp(uuid, &gVirtualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Virtualizer
         LOGV("\tEffectCreate - Effect to be created is LVM_VIRTUALIZER");
-        GlobalSessionMemory[sessionId].bVirtualizerInstantiated = LVM_TRUE;
+        GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVirtualizerInstantiated=LVM_TRUE;
 
         pContext->itfe       = &gLvmEffectInterface;
         pContext->EffectType = LVM_VIRTUALIZER;
     } else if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Equalizer
         LOGV("\tEffectCreate - Effect to be created is LVM_EQUALIZER");
-        GlobalSessionMemory[sessionId].bEqualizerInstantiated = LVM_TRUE;
+        GlobalSessionMemory[pContext->pBundledContext->SessionNo].bEqualizerInstantiated = LVM_TRUE;
 
         pContext->itfe       = &gLvmEffectInterface;
         pContext->EffectType = LVM_EQUALIZER;
     } else if (memcmp(uuid, &gVolumeDescriptor.uuid, sizeof(effect_uuid_t)) == 0){
         // Create Volume
         LOGV("\tEffectCreate - Effect to be created is LVM_VOLUME");
-        GlobalSessionMemory[sessionId].bVolumeInstantiated = LVM_TRUE;
+        GlobalSessionMemory[pContext->pBundledContext->SessionNo].bVolumeInstantiated = LVM_TRUE;
 
         pContext->itfe       = &gLvmEffectInterface;
         pContext->EffectType = LVM_VOLUME;
@@ -316,6 +346,7 @@
     LOGV("\n\tEffectRelease start %p", interface);
     EffectContext * pContext = (EffectContext *)interface;
 
+    LOGV("\n\tEffectRelease start interface: %p, context %p", interface, pContext->pBundledContext);
     if (pContext == NULL){
         LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
         return -EINVAL;
@@ -349,13 +380,28 @@
         fclose(pContext->pBundledContext->PcmInPtr);
         fclose(pContext->pBundledContext->PcmOutPtr);
         #endif
+
+        LvmSessionsActive--;
+        LOGV("\tEffectRelease: There are %d LVM sessions remaining\n", LvmSessionsActive);
+
+        // Clear the SessionIndex
+        for(int i=0; i<LVM_MAX_SESSIONS; i++){
+            if(SessionIndex[i] == pContext->pBundledContext->SessionId){
+                SessionIndex[i] = -1;
+                LOGV("\tEffectRelease: Clearing SessionIndex SessionNo %d for SessionId %d\n",
+                        i, pContext->pBundledContext->SessionId);
+                break;
+            }
+        }
+
         LOGV("\tEffectRelease: All effects are no longer instantiated\n");
         GlobalSessionMemory[pContext->pBundledContext->SessionNo].bBundledEffectsEnabled =LVM_FALSE;
         GlobalSessionMemory[pContext->pBundledContext->SessionNo].pBundledContext = LVM_NULL;
         LOGV("\tEffectRelease: Freeing LVM Bundle memory\n");
         LvmEffect_free(pContext);
-        LOGV("\tEffectRelease: Deleting LVM Bundle context\n");
+        LOGV("\tEffectRelease: Deleting LVM Bundle context %p\n", pContext->pBundledContext);
         delete pContext->pBundledContext;
+        pContext->pBundledContext = LVM_NULL;
     }
     // free the effect context for current effect
     delete pContext;
@@ -374,6 +420,8 @@
         GlobalSessionMemory[i].bBassInstantiated        = LVM_FALSE;
         GlobalSessionMemory[i].bVirtualizerInstantiated = LVM_FALSE;
         GlobalSessionMemory[i].pBundledContext          = LVM_NULL;
+
+        SessionIndex[i] = -1;
     }
     return;
 }
@@ -505,6 +553,9 @@
     params.SpeakerType            = LVM_HEADPHONES;
 
     pContext->pBundledContext->SampleRate = LVM_FS_44100;
+    pContext->pBundledContext->SamplesToExitCountEq   = 44100*2*2; // 2 secs Stereo
+    pContext->pBundledContext->SamplesToExitCountBb   = 44100*2*2; // 2 secs Stereo
+    pContext->pBundledContext->SamplesToExitCountVirt = 44100*2*2; // 2 secs Stereo
 
     /* Concert Sound parameters */
     params.VirtualizerOperatingMode   = LVM_MODE_OFF;
@@ -842,21 +893,27 @@
     switch (pConfig->inputCfg.samplingRate) {
     case 8000:
         SampleRate = LVM_FS_8000;
+        pContext->pBundledContext->SamplesPerSecond = 8000*2; // 2 secs Stereo
         break;
     case 16000:
         SampleRate = LVM_FS_16000;
+        pContext->pBundledContext->SamplesPerSecond = 16000*2; // 2 secs Stereo
         break;
     case 22050:
         SampleRate = LVM_FS_22050;
+        pContext->pBundledContext->SamplesPerSecond = 22050*2; // 2 secs Stereo
         break;
     case 32000:
         SampleRate = LVM_FS_32000;
+        pContext->pBundledContext->SamplesPerSecond = 32000*2; // 2 secs Stereo
         break;
     case 44100:
         SampleRate = LVM_FS_44100;
+        pContext->pBundledContext->SamplesPerSecond = 44100*2; // 2 secs Stereo
         break;
     case 48000:
         SampleRate = LVM_FS_48000;
+        pContext->pBundledContext->SamplesPerSecond = 48000*2; // 2 secs Stereo
         break;
     default:
         LOGV("\tEffect_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate);
@@ -881,6 +938,7 @@
 
         LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_configure")
         LOGV("\tEffect_configure Succesfully called LVM_SetControlParameters\n");
+        pContext->pBundledContext->SampleRate = SampleRate;
 
     }else{
         //LOGV("\tEffect_configure keep sampling rate at %d", SampleRate);
@@ -1461,7 +1519,7 @@
     LVM_ReturnStatus_en     LvmStatus=LVM_SUCCESS;     /* Function call status */
     LVM_INT16               Balance = 0;
 
-    
+
 
     pContext->pBundledContext->positionSaved = position;
     Balance = VolumeConvertStereoPosition(pContext->pBundledContext->positionSaved);
@@ -1614,11 +1672,12 @@
 //----------------------------------------------------------------------------
 
 int BassBoost_getParameter(EffectContext     *pContext,
-                           int32_t           *pParam,
+                           void              *pParam,
                            size_t            *pValueSize,
                            void              *pValue){
     int status = 0;
-    int32_t param = *pParam++;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
     int32_t param2;
     char *name;
 
@@ -1685,13 +1744,14 @@
 //
 //----------------------------------------------------------------------------
 
-int BassBoost_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+int BassBoost_setParameter (EffectContext *pContext, void *pParam, void *pValue){
     int status = 0;
     int16_t strength;
+    int32_t *pParamTemp = (int32_t *)pParam;
 
     //LOGV("\tBassBoost_setParameter start");
 
-    switch (*pParam){
+    switch (*pParamTemp){
         case BASSBOOST_PARAM_STRENGTH:
             strength = *(int16_t *)pValue;
             //LOGV("\tBassBoost_setParameter() BASSBOOST_PARAM_STRENGTH value is %d", strength);
@@ -1700,7 +1760,7 @@
             //LOGV("\tBassBoost_setParameter() Called pBassBoost->BassSetStrength");
            break;
         default:
-            LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParam);
+            LOGV("\tLVM_ERROR : BassBoost_setParameter() invalid param %d", *pParamTemp);
             break;
     }
 
@@ -1730,11 +1790,12 @@
 //----------------------------------------------------------------------------
 
 int Virtualizer_getParameter(EffectContext        *pContext,
-                             int32_t              *pParam,
+                             void                 *pParam,
                              size_t               *pValueSize,
                              void                 *pValue){
     int status = 0;
-    int32_t param = *pParam++;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
     int32_t param2;
     char *name;
 
@@ -1802,13 +1863,15 @@
 //
 //----------------------------------------------------------------------------
 
-int Virtualizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+int Virtualizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){
     int status = 0;
     int16_t strength;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
 
     //LOGV("\tVirtualizer_setParameter start");
 
-    switch (*pParam){
+    switch (param){
         case VIRTUALIZER_PARAM_STRENGTH:
             strength = *(int16_t *)pValue;
             //LOGV("\tVirtualizer_setParameter() VIRTUALIZER_PARAM_STRENGTH value is %d", strength);
@@ -1817,7 +1880,7 @@
             //LOGV("\tVirtualizer_setParameter() Called pVirtualizer->setStrength");
            break;
         default:
-            LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", *pParam);
+            LOGV("\tLVM_ERROR : Virtualizer_setParameter() invalid param %d", param);
             break;
     }
 
@@ -1846,12 +1909,13 @@
 //
 //----------------------------------------------------------------------------
 int Equalizer_getParameter(EffectContext     *pContext,
-                           int32_t           *pParam,
+                           void              *pParam,
                            size_t            *pValueSize,
                            void              *pValue){
     int status = 0;
     int bMute = 0;
-    int32_t param = *pParam++;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
     int32_t param2;
     char *name;
 
@@ -1924,7 +1988,7 @@
         break;
 
     case EQ_PARAM_BAND_LEVEL:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -1935,7 +1999,7 @@
         break;
 
     case EQ_PARAM_CENTER_FREQ:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -1946,7 +2010,7 @@
         break;
 
     case EQ_PARAM_BAND_FREQ_RANGE:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= FIVEBAND_NUMBANDS) {
             status = -EINVAL;
             break;
@@ -1957,7 +2021,7 @@
         break;
 
     case EQ_PARAM_GET_BAND:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2);
         //LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
         //      param2, *(int32_t *)pValue);
@@ -1974,7 +2038,7 @@
         break;
 
     case EQ_PARAM_GET_PRESET_NAME:
-        param2 = *pParam;
+        param2 = *pParamTemp;
         if (param2 >= EqualizerGetNumPresets()) {
         //if (param2 >= 20) {     // AGO FIX
             status = -EINVAL;
@@ -2022,12 +2086,14 @@
 // Outputs:
 //
 //----------------------------------------------------------------------------
-int Equalizer_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+int Equalizer_setParameter (EffectContext *pContext, void *pParam, void *pValue){
     int status = 0;
     int32_t preset;
     int32_t band;
     int32_t level;
-    int32_t param = *pParam++;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
+
 
     //LOGV("\tEqualizer_setParameter start");
     switch (param) {
@@ -2042,7 +2108,7 @@
         EqualizerSetPreset(pContext, preset);
         break;
     case EQ_PARAM_BAND_LEVEL:
-        band =  *pParam;
+        band =  *pParamTemp;
         level = (int32_t)(*(int16_t *)pValue);
         //LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
         if (band >= FIVEBAND_NUMBANDS) {
@@ -2102,13 +2168,13 @@
 //----------------------------------------------------------------------------
 
 int Volume_getParameter(EffectContext     *pContext,
-                        int32_t           *pParam,
+                        void              *pParam,
                         size_t            *pValueSize,
                         void              *pValue){
     int status = 0;
     int bMute = 0;
-    int32_t param = *pParam++;
-    int32_t param2;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;;
     char *name;
 
     LOGV("\tVolume_getParameter start");
@@ -2195,16 +2261,18 @@
 //
 //----------------------------------------------------------------------------
 
-int Volume_setParameter (EffectContext *pContext, int32_t *pParam, void *pValue){
+int Volume_setParameter (EffectContext *pContext, void *pParam, void *pValue){
     int      status = 0;
     int16_t  level;
     int16_t  position;
     uint32_t mute;
     uint32_t positionEnabled;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
 
     LOGV("\tVolume_setParameter start");
 
-    switch (*pParam){
+    switch (param){
         case VOLUME_PARAM_LEVEL:
             level = *(int16_t *)pValue;
             LOGV("\tVolume_setParameter() VOLUME_PARAM_LEVEL value is %d", level);
@@ -2237,7 +2305,7 @@
             break;
 
         default:
-            LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", *pParam);
+            LOGV("\tLVM_ERROR : Volume_setParameter() invalid param %d", param);
             break;
     }
 
@@ -2299,13 +2367,27 @@
                               audio_buffer_t         *inBuffer,
                               audio_buffer_t         *outBuffer){
     EffectContext * pContext = (EffectContext *) self;
+    LVM_ControlParams_t     ActiveParams;                           /* Current control Parameters */
+    LVM_ReturnStatus_en     LvmStatus = LVM_SUCCESS;                /* Function call status */
     int    status = 0;
+    int    status2Sec = 0;
     int    lvmStatus = 0;
     LVM_INT16   *in  = (LVM_INT16 *)inBuffer->raw;
     LVM_INT16   *out = (LVM_INT16 *)outBuffer->raw;
 
     //LOGV("\tEffect_process Start : Enabled = %d     Called = %d",
     //pContext->pBundledContext->NumberEffectsEnabled,pContext->pBundledContext->NumberEffectsCalled);
+//    LOGV("\tEffect_process Start : Samples left %d %d %d",
+//    pContext->pBundledContext->SamplesToExitCountBb,
+//    pContext->pBundledContext->SamplesToExitCountVirt,
+//    pContext->pBundledContext->SamplesToExitCountEq);
+
+//    LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+//    LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetStereoPosition")
+//    if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+//    LOGV("\tEffect_process Internal Operating Modes: BB %d   VIRT %d    EQ %d",
+//        ActiveParams.BE_OperatingMode, ActiveParams.VirtualizerOperatingMode,
+//        ActiveParams.EQNB_OperatingMode);
 
     if (pContext == NULL){
         LOGV("\tLVM_ERROR : Effect_process() ERROR pContext == NULL");
@@ -2319,23 +2401,44 @@
     }
     if ((pContext->pBundledContext->bBassEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_BASS_BOOST)){
-        LOGV("\tEffect_process() ERROR LVM_BASS_BOOST Effect is not enabled");
+        //LOGV("\tEffect_process() LVM_BASS_BOOST Effect is not enabled");
+        if(pContext->pBundledContext->SamplesToExitCountBb > 0){
+            status2Sec = -ENODATA;
+            pContext->pBundledContext->SamplesToExitCountBb -= outBuffer->frameCount * 2; // STEREO
+            //LOGV("\tEffect_process: Waiting for 2 secs to turn off BASS_BOOST, %d samples left",
+            //    pContext->pBundledContext->SamplesToExitCountBb);
+        } else {
         status = -ENODATA;
+        }
     }
     if ((pContext->pBundledContext->bVolumeEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_VOLUME)){
-        LOGV("\tEffect_process() ERROR LVM_VOLUME Effect is not enabled");
+        //LOGV("\tEffect_process() LVM_VOLUME Effect is not enabled");
         status = -ENODATA;
     }
     if ((pContext->pBundledContext->bEqualizerEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_EQUALIZER)){
-        LOGV("\tEffect_process() ERROR LVM_EQUALIZER Effect is not enabled");
-        status = -ENODATA;
+        //LOGV("\tEffect_process() LVM_EQUALIZER Effect is not enabled");
+        if(pContext->pBundledContext->SamplesToExitCountEq > 0){
+            status2Sec = -ENODATA;
+            pContext->pBundledContext->SamplesToExitCountEq -= outBuffer->frameCount * 2; // STEREO
+            //LOGV("\tEffect_process: Waiting for 2 secs to turn off EQUALIZER, %d samples left",
+            //    pContext->pBundledContext->SamplesToExitCountEq);
+        } else {
+            status = -ENODATA;
+        }
     }
     if ((pContext->pBundledContext->bVirtualizerEnabled == LVM_FALSE)&&
         (pContext->EffectType == LVM_VIRTUALIZER)){
-        LOGV("\tEffect_process() ERROR LVM_VIRTUALIZER Effect is not enabled");
-        status = -ENODATA;
+        //LOGV("\tEffect_process() LVM_VIRTUALIZER Effect is not enabled");
+        if(pContext->pBundledContext->SamplesToExitCountVirt > 0){
+            status2Sec = -ENODATA;
+            pContext->pBundledContext->SamplesToExitCountVirt -= outBuffer->frameCount * 2;// STEREO
+            //LOGV("\tEffect_process: Waiting for 2 secs to turn off VIRTUALIZER, %d samples left",
+            //    pContext->pBundledContext->SamplesToExitCountVirt);
+        } else {
+            status = -ENODATA;
+        }
     }
 
     // If this is the last frame of an effect process its output with no effect
@@ -2352,7 +2455,7 @@
         }
     }
 
-    if(status != -ENODATA){
+    if((status2Sec != -ENODATA)&&(status != -ENODATA)){
         pContext->pBundledContext->NumberEffectsCalled++;
     }
 
@@ -2496,7 +2599,7 @@
                 int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
 
                 p->status = android::BassBoost_getParameter(pContext,
-                                                            (int32_t *)p->data,
+                                                            p->data,
                                                             (size_t  *)&p->vsize,
                                                             p->data + voffset);
 
@@ -2527,7 +2630,7 @@
                 int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
 
                 p->status = android::Virtualizer_getParameter(pContext,
-                                                             (int32_t *)p->data,
+                                                             (void *)p->data,
                                                              (size_t  *)&p->vsize,
                                                               p->data + voffset);
 
@@ -2558,8 +2661,10 @@
 
                 int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
 
-                p->status = android::Equalizer_getParameter(pContext, (int32_t *)p->data, &p->vsize,
-                        p->data + voffset);
+                p->status = android::Equalizer_getParameter(pContext,
+                                                            p->data,
+                                                            &p->vsize,
+                                                            p->data + voffset);
 
                 *replySize = sizeof(effect_param_t) + voffset + p->vsize;
 
@@ -2590,7 +2695,7 @@
                 int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
 
                 p->status = android::Volume_getParameter(pContext,
-                                                         (int32_t *)p->data,
+                                                         (void *)p->data,
                                                          (size_t  *)&p->vsize,
                                                          p->data + voffset);
 
@@ -2636,7 +2741,7 @@
                 //        cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
 
                 *(int *)pReplyData = android::BassBoost_setParameter(pContext,
-                                                                    (int32_t *)p->data,
+                                                                    (void *)p->data,
                                                                     p->data + p->psize);
             }
             if(pContext->EffectType == LVM_VIRTUALIZER){
@@ -2669,7 +2774,7 @@
                 //        cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
 
                 *(int *)pReplyData = android::Virtualizer_setParameter(pContext,
-                                                                      (int32_t *)p->data,
+                                                                      (void *)p->data,
                                                                        p->data + p->psize);
             }
             if(pContext->EffectType == LVM_EQUALIZER){
@@ -2689,7 +2794,7 @@
                 effect_param_t *p = (effect_param_t *) pCmdData;
 
                 *(int *)pReplyData = android::Equalizer_setParameter(pContext,
-                                                                    (int32_t *)p->data,
+                                                                    (void *)p->data,
                                                                      p->data + p->psize);
             }
             if(pContext->EffectType == LVM_VOLUME){
@@ -2711,14 +2816,14 @@
                 effect_param_t *p = (effect_param_t *) pCmdData;
 
                 *(int *)pReplyData = android::Volume_setParameter(pContext,
-                                                                 (int32_t *)p->data,
+                                                                 (void *)p->data,
                                                                  p->data + p->psize);
             }
             //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_SET_PARAM end");
         } break;
 
         case EFFECT_CMD_ENABLE:
-            //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
+            LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE start");
             if (pReplyData == NULL || *replySize != sizeof(int)){
                 LOGV("\tLVM_ERROR : Effect_command cmdCode Case: EFFECT_CMD_ENABLE: ERROR");
                 return -EINVAL;
@@ -2768,6 +2873,14 @@
             *(int *)pReplyData = 0;
             pContext->pBundledContext->NumberEffectsEnabled++;
             android::LvmEffect_enable(pContext);
+            pContext->pBundledContext->SamplesToExitCountEq =
+                 (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 0.1 secs Stereo
+            pContext->pBundledContext->SamplesToExitCountBb =
+                 (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*6); // 2 secs Stereo
+            pContext->pBundledContext->SamplesToExitCountVirt =
+                 (LVM_INT32)(pContext->pBundledContext->SamplesPerSecond*1); // 2 secs Stereo
+            LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE Samples to Exit = %d",
+                pContext->pBundledContext->SamplesToExitCountBb);
             //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE NumberEffectsEnabled = %d",
             //        pContext->pBundledContext->NumberEffectsEnabled);
             //LOGV("\tEffect_command cmdCode Case: EFFECT_CMD_ENABLE end");
@@ -2906,11 +3019,8 @@
         }
         case EFFECT_CMD_SET_VOLUME:
         {
-            int32_t channels = cmdSize/sizeof(int32_t);
             int32_t vol     = *(int32_t *)pCmdData;
-            int16_t vol_db;
             int16_t dB;
-            int16_t vol_db_rnd;
             int32_t vol_ret[2] = {1<<24,1<<24}; // Apply no volume
 
             // if pReplyData is NULL, VOL_CTRL is delegated to another effect
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
index d009bf9..1bee974 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -58,6 +58,7 @@
 struct BundledEffectContext{
     LVM_Handle_t                    hInstance;                /* Instance handle */
     int                             SessionNo;                /* Current session number */
+    int                             SessionId;                /* Current session id */
     bool                            bVolumeEnabled;           /* Flag for Volume */
     bool                            bEqualizerEnabled;        /* Flag for EQ */
     bool                            bBassEnabled;             /* Flag for Bass */
@@ -80,6 +81,10 @@
     bool                            bStereoPositionEnabled;
     int                             frameCount;
     LVM_Fs_en                       SampleRate;
+    int                             SamplesPerSecond;
+    int                             SamplesToExitCountEq;
+    int                             SamplesToExitCountBb;
+    int                             SamplesToExitCountVirt;
     #ifdef LVM_PCM
     FILE                            *PcmInPtr;
     FILE                            *PcmOutPtr;
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
new file mode 100755
index 0000000..2043e44
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -0,0 +1,1820 @@
+/*
+ * Copyright (C) 2010-2010 NXP Software
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Reverb"
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
+#define LOG_NDEBUG 0
+
+#include <cutils/log.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <new>
+#include <EffectReverb.h>
+#include <LVREV.h>
+
+#define MAX_NUM_BANDS           5
+#define MAX_CALL_SIZE           256
+#define LVREV_MAX_T60           7000
+#define LVREV_MAX_REVERB_LEVEL  2000
+
+//#define LVM_PCM
+
+// effect_interface_t interface implementation for reverb
+extern "C" const struct effect_interface_s gReverbInterface;
+
+#define LVM_ERROR_CHECK(LvmStatus, callingFunc, calledFunc){\
+        if (LvmStatus == LVREV_NULLADDRESS){\
+            LOGV("\tLVREV_ERROR : Parameter error - "\
+                    "null pointer returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+        }\
+        if (LvmStatus == LVREV_INVALIDNUMSAMPLES){\
+            LOGV("\tLVREV_ERROR : Parameter error - "\
+                    "bad number of samples returned by %s in %s\n\n\n\n", callingFunc, calledFunc);\
+        }\
+        if (LvmStatus == LVREV_OUTOFRANGE){\
+            LOGV("\tLVREV_ERROR : Parameter error - "\
+                    "out of range returned by %s in %s\n", callingFunc, calledFunc);\
+        }\
+    }
+
+// Namespaces
+namespace android {
+namespace {
+
+/************************************************************************************/
+/*                                                                                  */
+/* Preset definitions                                                               */
+/*                                                                                  */
+/************************************************************************************/
+LVM_UINT16 RevPreset_Level[]    = {  32,   32,   32,   32,   32,    32,   32,   32,   32,   32};
+LVM_UINT16 RevPreset_LPF[]      = {1298, 1000, 5012, 3542, 3400, 23999, 2536, 1000, 1000, 1000};
+LVM_UINT16 RevPreset_HPF[]      = {  50,   50,   50,   50,   50,    50,   50,   50,   50,   50};
+LVM_UINT16 RevPreset_T60[]      = {1490,  500, 2310, 4230, 3920,  2910, 7000, 1490, 1490,  170};
+LVM_UINT16 RevPreset_Density[]  = { 100,  100,  100,  100,  100,   100,  100,  100,  100,  100};
+LVM_UINT16 RevPreset_Damping[]  = {  54,   10,   64,   59,   70,   100,   33,   54,   21,   10};
+LVM_UINT16 RevPreset_RoomSize[] = { 100,  100,  100,  100,  100,   100,  100,  100,  100,  100};
+
+/************************************************************************************/
+/*                                                                                  */
+/* Preset definitions                                                               */
+/*                                                                                  */
+/************************************************************************************/
+#define REV_PRESET_BATHROOM         0
+#define REV_PRESET_LIVINGROOM       1
+#define REV_PRESET_STONEROOM        2
+#define REV_PRESET_AUDITORIUM       3
+#define REV_PRESET_CONCERTHALL      4
+#define REV_PRESET_CAVE             5
+#define REV_PRESET_ARENA            6
+#define REV_PRESET_FOREST           7
+#define REV_PRESET_MOUNTAINS        8
+#define REV_PRESET_PADDEDCELL       9
+
+// NXP SW Reverb UUID
+const effect_descriptor_t gReverbDescriptor = {
+        { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e } },
+        { 0x4a387fc0, 0x8ab3, 0x11df, 0x8bad, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } },
+        EFFECT_API_VERSION,
+        (EFFECT_FLAG_TYPE_AUXILIARY | EFFECT_FLAG_INSERT_LAST),
+        0, // TODO
+        1,
+        "Reverb",
+        "NXP Software Ltd.",
+};
+
+struct ReverbContext{
+    const struct effect_interface_s *itfe;
+    effect_config_t                 config;
+    LVREV_Handle_t                  hInstance;
+    int16_t                         SavedRoomLevel;
+    int16_t                         SavedHfLevel;
+    int16_t                         SavedDecayTime;
+    int16_t                         SavedDecayHfRatio;
+    int16_t                         SavedReverbLevel;
+    int16_t                         SavedDiffusion;
+    int16_t                         SavedDensity;
+    bool                            bEnabled;
+    #ifdef LVM_PCM
+    FILE                            *PcmInPtr;
+    FILE                            *PcmOutPtr;
+    #endif
+    LVM_Fs_en                       SampleRate;
+};
+
+//--- local function prototypes
+int  Reverb_init            (ReverbContext *pContext);
+void Reverb_free            (ReverbContext *pContext);
+int  Reverb_configure       (ReverbContext *pContext, effect_config_t *pConfig);
+int  Reverb_setParameter    (ReverbContext *pContext, void *pParam, void *pValue);
+int  Reverb_getParameter    (ReverbContext *pContext,
+                             void          *pParam,
+                             size_t        *pValueSize,
+                             void          *pValue);
+
+/* Effect Library Interface Implementation */
+extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects){
+    LOGV("\n\tEffectQueryNumberEffects start");
+    *pNumEffects = 1;
+    LOGV("\tEffectQueryNumberEffects creating %d effects", *pNumEffects);
+    LOGV("\tEffectQueryNumberEffects end\n");
+    return 0;
+}     /* end EffectQueryNumberEffects */
+
+extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor){
+    LOGV("\n\tEffectQueryEffect start");
+    LOGV("\tEffectQueryEffect processing index %d", index);
+    if (pDescriptor == NULL){
+        LOGV("\tLVM_ERROR : EffectQueryEffect was passed NULL pointer");
+        return -EINVAL;
+    }
+    if (index > 0){
+        LOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
+        return -ENOENT;
+    }
+    memcpy(pDescriptor, &gReverbDescriptor, sizeof(effect_descriptor_t));
+    LOGV("\tEffectQueryEffect end\n");
+    return 0;
+}     /* end EffectQueryEffect */
+
+extern "C" int EffectCreate(effect_uuid_t       *uuid,
+                            int32_t             sessionId,
+                            int32_t             ioId,
+                            effect_interface_t  *pInterface){
+    int ret;
+    int i;
+
+    LOGV("\t\nEffectCreate start");
+
+    if (pInterface == NULL || uuid == NULL){
+        LOGV("\tLVM_ERROR : EffectCreate() called with NULL pointer");
+        return -EINVAL;
+    }
+
+    if (memcmp(uuid, &gReverbDescriptor.uuid, sizeof(effect_uuid_t)) != 0){
+        LOGV("\tLVM_ERROR : EffectCreate() invalid UUID");
+        return -EINVAL;
+    }
+
+    ReverbContext *pContext = new ReverbContext;
+
+    pContext->itfe      = &gReverbInterface;
+    pContext->hInstance = NULL;
+
+    LOGV("\tEffectCreate - Calling Reverb_init");
+    ret = Reverb_init(pContext);
+
+    if (ret < 0){
+        LOGV("\tLVM_ERROR : EffectCreate() init failed");
+        delete pContext;
+        return ret;
+    }
+
+    *pInterface = (effect_interface_t)pContext;
+
+    #ifdef LVM_PCM
+    pContext->PcmInPtr = NULL;
+    pContext->PcmOutPtr = NULL;
+
+    pContext->PcmInPtr  = fopen("/data/tmp/reverb_pcm_in.pcm", "w");
+    pContext->PcmOutPtr = fopen("/data/tmp/reverb_pcm_out.pcm", "w");
+
+    if((pContext->PcmInPtr  == NULL)||
+       (pContext->PcmOutPtr == NULL)){
+       return -EINVAL;
+    }
+    #endif
+
+    LOGV("\tEffectCreate %p, size %d", pContext, sizeof(ReverbContext));
+    LOGV("\tEffectCreate end\n");
+    return 0;
+} /* end EffectCreate */
+
+extern "C" int EffectRelease(effect_interface_t interface){
+    ReverbContext * pContext = (ReverbContext *)interface;
+
+    LOGV("\tEffectRelease %p", interface);
+    if (pContext == NULL){
+        LOGV("\tLVM_ERROR : EffectRelease called with NULL pointer");
+        return -EINVAL;
+    }
+
+    #ifdef LVM_PCM
+    fclose(pContext->PcmInPtr);
+    fclose(pContext->PcmOutPtr);
+    #endif
+    Reverb_free(pContext);
+    delete pContext;
+    return 0;
+} /* end EffectRelease */
+
+/* local functions */
+#define CHECK_ARG(cond) {                     \
+    if (!(cond)) {                            \
+        LOGV("\tLVM_ERROR : Invalid argument: "#cond);      \
+        return -EINVAL;                       \
+    }                                         \
+}
+
+//----------------------------------------------------------------------------
+// MonoTo2I_32()
+//----------------------------------------------------------------------------
+// Purpose:
+//  Convert MONO to STEREO
+//
+//----------------------------------------------------------------------------
+
+void MonoTo2I_32( const LVM_INT32  *src,
+                        LVM_INT32  *dst,
+                        LVM_INT16 n)
+{
+   LVM_INT16 ii;
+   src += (n-1);
+   dst += ((n*2)-1);
+
+   for (ii = n; ii != 0; ii--)
+   {
+       *dst = *src;
+       dst--;
+
+       *dst = *src;
+       dst--;
+       src--;
+   }
+
+   return;
+}
+
+//----------------------------------------------------------------------------
+// From2iToMono_32()
+//----------------------------------------------------------------------------
+// Purpose:
+//  Convert STEREO to MONO
+//
+//----------------------------------------------------------------------------
+
+void From2iToMono_32( const LVM_INT32 *src,
+                            LVM_INT32 *dst,
+                            LVM_INT16 n)
+{
+   LVM_INT16 ii;
+   LVM_INT32 Temp;
+
+   for (ii = n; ii != 0; ii--)
+   {
+       Temp = (*src>>1);
+       src++;
+
+       Temp +=(*src>>1);
+       src++;
+
+       *dst = Temp;
+       dst++;
+   }
+
+   return;
+}
+//----------------------------------------------------------------------------
+// process()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the Reverb
+//
+// Inputs:
+//  pIn:        pointer to stereo/mono 16 bit input data
+//  pOut:       pointer to stereo 16 bit output data
+//  frameCount: Frames to process
+//  pContext:   effect engine context
+//  strength    strength to be applied
+//
+//  Outputs:
+//  pOut:       pointer to updated stereo 16 bit output data
+//
+//----------------------------------------------------------------------------
+
+int process( LVM_INT16     *pIn,
+             LVM_INT16     *pOut,
+             int           frameCount,
+             ReverbContext *pContext){
+
+    LVM_INT16               samplesPerFrame = 0;
+    LVREV_ReturnStatus_en   LvmStatus = LVREV_SUCCESS;              /* Function call status */
+
+    LVM_INT32 *InFrames32;
+    LVM_INT32 *OutFrames32;
+    LVM_INT16 *OutFrames16;
+
+
+    // Check that the input is either mono or stereo
+    if(pContext->config.inputCfg.channels == CHANNEL_STEREO){
+        samplesPerFrame = 2;
+    } else if (pContext->config.inputCfg.channels == CHANNEL_MONO){
+        samplesPerFrame = 1;
+    } else {
+        LOGV("\tLVREV_ERROR : process invalid PCM format");
+        return -EINVAL;
+    }
+
+    InFrames32  = (LVM_INT32 *)malloc(frameCount * sizeof(LVM_INT32) * 2);
+    OutFrames32 = (LVM_INT32 *)malloc(frameCount * sizeof(LVM_INT32) * 2);
+    OutFrames16 = (LVM_INT16 *)OutFrames32;
+
+    // Check for NULL pointers
+    if((InFrames32 == NULL)||(OutFrames32 == NULL)){
+        LOGV("\tLVREV_ERROR : process failed to allocate memory for temporary buffers ");
+        return -EINVAL;
+    }
+
+    #ifdef LVM_PCM
+    fwrite(pIn, frameCount*sizeof(LVM_INT16)*samplesPerFrame, 1, pContext->PcmInPtr);
+    fflush(pContext->PcmInPtr);
+    #endif
+
+    // Convert to Input 32 bits
+    for(int i=0; i<frameCount*samplesPerFrame; i++){
+        InFrames32[i] = (LVM_INT32)pIn[i]<<8;
+    }
+
+     // If the input was MONO, convert to STEREO
+    if(pContext->config.inputCfg.channels == CHANNEL_MONO){
+        //LOGV("\tConverting Output from MONO to STEREO");
+        MonoTo2I_32(InFrames32, InFrames32, frameCount);
+    }
+
+    //LOGV("\tProcess, frames: %d, InFormat: %d(MONO=%d), OutFormat: %d(STEREO=%d)",
+    //frameCount, pContext->config.inputCfg.channels, CHANNEL_MONO,
+    //pContext->config.outputCfg.channels, CHANNEL_STEREO);
+
+    /* Process the samples */
+    LvmStatus = LVREV_Process(pContext->hInstance,      /* Instance handle */
+                              InFrames32,               /* Input buffer */
+                              OutFrames32,              /* Output buffer */
+                              frameCount);              /* Number of samples to read */
+
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_Process", "process")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    // Convert to 16 bits
+    for(int i=0; i<frameCount*2; i++){  // Always stereo
+        OutFrames16[i] = (LVM_INT16)(OutFrames32[i]>>8);
+    }
+
+    #ifdef LVM_PCM
+    fwrite(OutFrames16, frameCount*sizeof(LVM_INT16)*samplesPerFrame, 1, pContext->PcmOutPtr);
+    fflush(pContext->PcmOutPtr);
+    #endif
+
+    // Accumulate if required
+    if (pContext->config.outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE){
+        //LOGV("\tBuffer access is ACCUMULATE");
+        for (int i=0; i<frameCount*2; i++){
+            pOut[i] +=  OutFrames16[i];
+        }
+    }else{
+        //LOGV("\tBuffer access is WRITE");
+        memcpy(pOut, OutFrames16, frameCount*sizeof(LVM_INT16)*2); // 2 is for stereo output
+    }
+
+    free(InFrames32);
+    free(OutFrames32);
+
+    return 0;
+}    /* end process */
+
+//----------------------------------------------------------------------------
+// Reverb_free()
+//----------------------------------------------------------------------------
+// Purpose: Free all memory associated with the Bundle.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+void Reverb_free(ReverbContext *pContext){
+
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;         /* Function call status */
+    LVREV_ControlParams_st    params;                        /* Control Parameters */
+    LVREV_MemoryTable_st      MemTab;
+
+    /* Free the algorithm memory */
+    LvmStatus = LVREV_GetMemoryTable(pContext->hInstance,
+                                   &MemTab,
+                                   LVM_NULL);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVM_GetMemoryTable", "Reverb_free")
+
+    for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+        if (MemTab.Region[i].Size != 0){
+            if (MemTab.Region[i].pBaseAddress != NULL){
+                LOGV("\tfree() - START freeing %ld bytes for region %u at %p\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+
+                free(MemTab.Region[i].pBaseAddress);
+
+                LOGV("\tfree() - END   freeing %ld bytes for region %u at %p\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+            }else{
+                LOGV("\tLVM_ERROR : free() - trying to free with NULL pointer %ld bytes "
+                        "for region %u at %p ERROR\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+            }
+        }
+    }
+}    /* end Reverb_free */
+
+//----------------------------------------------------------------------------
+// Reverb_configure()
+//----------------------------------------------------------------------------
+// Purpose: Set input and output audio configuration.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  pConfig:    pointer to effect_config_t structure holding input and output
+//      configuration parameters
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_configure(ReverbContext *pContext, effect_config_t *pConfig){
+    LVM_Fs_en   SampleRate;
+    //LOGV("\tReverb_configure start");
+
+    CHECK_ARG(pContext != NULL);
+    CHECK_ARG(pConfig != NULL);
+
+    CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
+    CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
+    CHECK_ARG(pConfig->outputCfg.channels == CHANNEL_STEREO);
+    CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
+              || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
+    CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
+
+    if(pConfig->inputCfg.samplingRate != 44100){
+        return -EINVAL;
+    }
+
+    //LOGV("\tReverb_configure calling memcpy");
+    memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+
+    switch (pConfig->inputCfg.samplingRate) {
+    case 8000:
+        SampleRate = LVM_FS_8000;
+        break;
+    case 16000:
+        SampleRate = LVM_FS_16000;
+        break;
+    case 22050:
+        SampleRate = LVM_FS_22050;
+        break;
+    case 32000:
+        SampleRate = LVM_FS_32000;
+        break;
+    case 44100:
+        SampleRate = LVM_FS_44100;
+        break;
+    case 48000:
+        SampleRate = LVM_FS_48000;
+        break;
+    default:
+        LOGV("\rReverb_Configure invalid sampling rate %d", pConfig->inputCfg.samplingRate);
+        return -EINVAL;
+    }
+
+    if(pContext->SampleRate != SampleRate){
+
+        LVREV_ControlParams_st    ActiveParams;
+        LVREV_ReturnStatus_en     LvmStatus = LVREV_SUCCESS;
+
+        //LOGV("\tReverb_configure change sampling rate to %d", SampleRate);
+
+        /* Get the current settings */
+        LvmStatus = LVREV_GetControlParameters(pContext->hInstance,
+                                         &ActiveParams);
+
+        LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "Reverb_configure")
+        if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+        LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+
+        LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_configure")
+        //LOGV("\tReverb_configure Succesfully called LVREV_SetControlParameters\n");
+
+    }else{
+        //LOGV("\tReverb_configure keep sampling rate at %d", SampleRate);
+    }
+
+    //LOGV("\tReverb_configure End");
+    return 0;
+}   /* end Reverb_configure */
+
+
+//----------------------------------------------------------------------------
+// Reverb_init()
+//----------------------------------------------------------------------------
+// Purpose: Initialize engine with default configuration
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_init(ReverbContext *pContext){
+    int status;
+    int channel_mode;
+
+    LOGV("\tReverb_init start %d", gReverbDescriptor.flags);
+
+    if((gReverbDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_INSERT){
+        LOGV("\tReverb_init EFFECT_FLAG_TYPE_INSERT");
+        channel_mode = CHANNEL_STEREO;
+    }
+    if((gReverbDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY ){
+        LOGV("\tReverb_init EFFECT_FLAG_TYPE_AUXILIARY");
+        channel_mode = CHANNEL_MONO;
+    }
+
+    CHECK_ARG(pContext != NULL);
+
+    if (pContext->hInstance != NULL){
+        Reverb_free(pContext);
+    }
+
+    pContext->config.inputCfg.accessMode                    = EFFECT_BUFFER_ACCESS_READ;
+    pContext->config.inputCfg.channels                      = channel_mode;
+    pContext->config.inputCfg.format                        = SAMPLE_FORMAT_PCM_S15;
+    pContext->config.inputCfg.samplingRate                  = 44100;
+    pContext->config.inputCfg.bufferProvider.getBuffer      = NULL;
+    pContext->config.inputCfg.bufferProvider.releaseBuffer  = NULL;
+    pContext->config.inputCfg.bufferProvider.cookie         = NULL;
+    pContext->config.inputCfg.mask                          = EFFECT_CONFIG_ALL;
+    pContext->config.outputCfg.accessMode                   = EFFECT_BUFFER_ACCESS_ACCUMULATE;
+    pContext->config.outputCfg.channels                     = CHANNEL_STEREO;
+    pContext->config.outputCfg.format                       = SAMPLE_FORMAT_PCM_S15;
+    pContext->config.outputCfg.samplingRate                 = 44100;
+    pContext->config.outputCfg.bufferProvider.getBuffer     = NULL;
+    pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
+    pContext->config.outputCfg.bufferProvider.cookie        = NULL;
+    pContext->config.outputCfg.mask                         = EFFECT_CONFIG_ALL;
+
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;        /* Function call status */
+    LVREV_ControlParams_st    params;                         /* Control Parameters */
+    LVREV_InstanceParams_st   InstParams;                     /* Instance parameters */
+    LVREV_MemoryTable_st      MemTab;                         /* Memory allocation table */
+    bool                      bMallocFailure = LVM_FALSE;
+
+    /* Set the capabilities */
+    InstParams.MaxBlockSize  = MAX_CALL_SIZE;
+    InstParams.SourceFormat  = LVM_STEREO;
+    InstParams.NumDelays     = LVREV_DELAYLINES_4;
+
+    /* Allocate memory, forcing alignment */
+    LvmStatus = LVREV_GetMemoryTable(LVM_NULL,
+                                  &MemTab,
+                                  &InstParams);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetMemoryTable", "Reverb_init")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    LOGV("\tCreateInstance Succesfully called LVM_GetMemoryTable\n");
+
+    /* Allocate memory */
+    for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+        if (MemTab.Region[i].Size != 0){
+            MemTab.Region[i].pBaseAddress = malloc(MemTab.Region[i].Size);
+
+            if (MemTab.Region[i].pBaseAddress == LVM_NULL){
+                LOGV("\tLVREV_ERROR :Reverb_init CreateInstance Failed to allocate %ld bytes for region %u\n",
+                        MemTab.Region[i].Size, i );
+                bMallocFailure = LVM_TRUE;
+            }else{
+                LOGV("\tReverb_init CreateInstance allocate %ld bytes for region %u at %p\n",
+                        MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+            }
+        }
+    }
+
+    /* If one or more of the memory regions failed to allocate, free the regions that were
+     * succesfully allocated and return with an error
+     */
+    if(bMallocFailure == LVM_TRUE){
+        for (int i=0; i<LVM_NR_MEMORY_REGIONS; i++){
+            if (MemTab.Region[i].pBaseAddress == LVM_NULL){
+                LOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed to allocate %ld bytes for region %u"
+                     " - Not freeing\n", MemTab.Region[i].Size, i );
+            }else{
+                LOGV("\tLVM_ERROR :Reverb_init CreateInstance Failed: but allocated %ld bytes for region %u "
+                       "at %p- free\n", MemTab.Region[i].Size, i, MemTab.Region[i].pBaseAddress);
+                free(MemTab.Region[i].pBaseAddress);
+            }
+        }
+        return -EINVAL;
+    }
+    LOGV("\tReverb_init CreateInstance Succesfully malloc'd memory\n");
+
+    /* Initialise */
+    pContext->hInstance = LVM_NULL;
+
+    /* Init sets the instance handle */
+    LvmStatus = LVREV_GetInstanceHandle(&pContext->hInstance,
+                                        &MemTab,
+                                        &InstParams);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVM_GetInstanceHandle", "Reverb_init")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    LOGV("\tReverb_init CreateInstance Succesfully called LVM_GetInstanceHandle\n");
+
+    /* Set the initial process parameters */
+    /* General parameters */
+    params.OperatingMode  = LVM_MODE_ON;
+    params.SampleRate     = LVM_FS_44100;
+    params.SourceFormat   = LVM_STEREO;
+
+    /* Reverb parameters */
+    params.Level          = 0;
+    params.LPF            = 23999;
+    params.HPF            = RevPreset_HPF[REV_PRESET_MOUNTAINS];
+    params.T60            = RevPreset_T60[REV_PRESET_MOUNTAINS];
+    params.Density        = RevPreset_Density[REV_PRESET_MOUNTAINS];
+    params.Damping        = RevPreset_Damping[REV_PRESET_MOUNTAINS];
+    params.RoomSize       = RevPreset_RoomSize[REV_PRESET_MOUNTAINS];
+
+    /* Saved strength is used to return the exact strength that was used in the set to the get
+     * because we map the original strength range of 0:1000 to 1:15, and this will avoid
+     * quantisation like effect when returning
+     */
+    pContext->SavedRoomLevel    = -6000;
+    pContext->SavedHfLevel      = 0;
+    pContext->bEnabled          = LVM_FALSE;
+    pContext->SavedDecayTime    = params.T60;
+    pContext->SavedDecayHfRatio = params.Damping*10;
+    pContext->SavedDensity      = params.RoomSize*10;
+    pContext->SavedDiffusion    = params.Density*10;
+    pContext->SavedReverbLevel  = -6000;
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance,
+                                         &params);
+
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "Reverb_init")
+    if(LvmStatus != LVREV_SUCCESS) return -EINVAL;
+
+    LOGV("\tReverb_init CreateInstance Succesfully called LVREV_SetControlParameters\n");
+    LOGV("\tReverb_init End");
+    return 0;
+}   /* end Reverb_init */
+
+//----------------------------------------------------------------------------
+// ReverbConvertLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Convert level from OpenSL ES format to LVM format
+//
+// Inputs:
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbConvertLevel(int16_t level){
+    static int16_t LevelArray[101] =
+    {
+       -12000, -4000,  -3398,  -3046,  -2796,  -2603,  -2444,  -2310,  -2194,  -2092,
+       -2000,  -1918,  -1842,  -1773,  -1708,  -1648,  -1592,  -1540,  -1490,  -1443,
+       -1398,  -1356,  -1316,  -1277,  -1240,  -1205,  -1171,  -1138,  -1106,  -1076,
+       -1046,  -1018,  -990,   -963,   -938,   -912,   -888,   -864,   -841,   -818,
+       -796,   -775,   -754,   -734,   -714,   -694,   -675,   -656,   -638,   -620,
+       -603,   -585,   -568,   -552,   -536,   -520,   -504,   -489,   -474,   -459,
+       -444,   -430,   -416,   -402,   -388,   -375,   -361,   -348,   -335,   -323,
+       -310,   -298,   -286,   -274,   -262,   -250,   -239,   -228,   -216,   -205,
+       -194,   -184,   -173,   -162,   -152,   -142,   -132,   -121,   -112,   -102,
+       -92,    -82,    -73,    -64,    -54,    -45,    -36,    -27,    -18,    -9,
+       0
+    };
+    int16_t i;
+
+    for(i = 0; i < 101; i++)
+    {
+       if(level <= LevelArray[i])
+           break;
+    }
+    return i;
+}
+
+//----------------------------------------------------------------------------
+// ReverbConvertHFLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Convert level from OpenSL ES format to LVM format
+//
+// Inputs:
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbConvertHfLevel(int16_t Hflevel){
+    int16_t i;
+
+    static LPFPair_t LPFArray[97] =
+    {   // Limit range to 50 for LVREV parameter range
+        {-10000, 50}, { -5000, 50 }, { -4000, 50},  { -3000, 158}, { -2000, 502},
+        {-1000, 1666},{ -900, 1897}, { -800, 2169}, { -700, 2496}, { -600, 2895},
+        {-500, 3400}, { -400, 4066}, { -300, 5011}, { -200, 6537}, { -100,  9826},
+        {-99, 9881 }, { -98, 9937 }, { -97, 9994 }, { -96, 10052}, { -95, 10111},
+        {-94, 10171}, { -93, 10231}, { -92, 10293}, { -91, 10356}, { -90, 10419},
+        {-89, 10484}, { -88, 10549}, { -87, 10616}, { -86, 10684}, { -85, 10753},
+        {-84, 10823}, { -83, 10895}, { -82, 10968}, { -81, 11042}, { -80, 11117},
+        {-79, 11194}, { -78, 11272}, { -77, 11352}, { -76, 11433}, { -75, 11516},
+        {-74, 11600}, { -73, 11686}, { -72, 11774}, { -71, 11864}, { -70, 11955},
+        {-69, 12049}, { -68, 12144}, { -67, 12242}, { -66, 12341}, { -65, 12443},
+        {-64, 12548}, { -63, 12654}, { -62, 12763}, { -61, 12875}, { -60, 12990},
+        {-59, 13107}, { -58, 13227}, { -57, 13351}, { -56, 13477}, { -55, 13607},
+        {-54, 13741}, { -53, 13878}, { -52, 14019}, { -51, 14164}, { -50, 14313},
+        {-49, 14467}, { -48, 14626}, { -47, 14789}, { -46, 14958}, { -45, 15132},
+        {-44, 15312}, { -43, 15498}, { -42, 15691}, { -41, 15890}, { -40, 16097},
+        {-39, 16311}, { -38, 16534}, { -37, 16766}, { -36, 17007}, { -35, 17259},
+        {-34, 17521}, { -33, 17795}, { -32, 18081}, { -31, 18381}, { -30, 18696},
+        {-29, 19027}, { -28, 19375}, { -27, 19742}, { -26, 20129}, { -25, 20540},
+        {-24, 20976}, { -23, 21439}, { -22, 21934}, { -21, 22463}, { -20, 23031},
+        {-19, 23643}, { -18, 23999}
+    };
+
+    for(i = 0; i < 96; i++)
+    {
+        if(Hflevel <= LPFArray[i].Room_HF)
+            break;
+    }
+    return LPFArray[i].LPF;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetRoomHfLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the HF level to the Reverb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetRoomHfLevel(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetRoomHfLevel start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetRoomHfLevel")
+    //LOGV("\tReverbSetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
+
+    ActiveParams.LPF = ReverbConvertHfLevel(level);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetRoomHfLevel")
+    //LOGV("\tReverbSetRoomhfLevel() just Set -> %d\n", ActiveParams.LPF);
+    pContext->SavedHfLevel = level;
+    //LOGV("\tReverbSetHfRoomLevel end.. saving %d", pContext->SavedHfLevel);
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetRoomHfLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the level applied to the Revervb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbGetRoomHfLevel(ReverbContext *pContext){
+    int16_t level;
+    //LOGV("\tReverbGetRoomHfLevel start, saved level is %d", pContext->SavedHfLevel);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetRoomHfLevel")
+    //LOGV("\tReverbGetRoomHfLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetRoomHfLevel() just Got -> %d\n", ActiveParams.LPF);
+
+    level = ReverbConvertHfLevel(pContext->SavedHfLevel);
+
+    //LOGV("\tReverbGetRoomHfLevel() ActiveParams.LPFL %d, pContext->SavedHfLevel: %d, "
+    //     "converted level: %d\n", ActiveParams.LPF, pContext->SavedHfLevel, level);
+
+    if(ActiveParams.LPF != level){
+        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomHfLevel() has wrong level -> %d %d\n",
+               ActiveParams.Level, level);
+    }
+
+    //LOGV("\tReverbGetRoomHfLevel end");
+    return pContext->SavedHfLevel;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetReverbLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the level to the Reverb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetReverbLevel(ReverbContext *pContext, int16_t level){
+    //LOGV("\n\tReverbSetReverbLevel start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetReverbLevel")
+    //LOGV("\tReverbSetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetReverbLevel just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (level + pContext->SavedRoomLevel)-LVREV_MAX_REVERB_LEVEL;
+    //LOGV("\tReverbSetReverbLevel() CombinedLevel is %d = %d + %d\n",
+    //      CombinedLevel, level, pContext->SavedRoomLevel);
+
+    ActiveParams.Level = ReverbConvertLevel(CombinedLevel);
+
+    //LOGV("\tReverbSetReverbLevel() Trying to set -> %d\n", ActiveParams.Level);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetReverbLevel")
+    //LOGV("\tReverbSetReverbLevel() just Set -> %d\n", ActiveParams.Level);
+
+    pContext->SavedReverbLevel = level;
+    //LOGV("\tReverbSetReverbLevel end pContext->SavedReverbLevel is %d\n\n",
+    //     pContext->SavedReverbLevel);
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetReverbLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the level applied to the Revervb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbGetReverbLevel(ReverbContext *pContext){
+    int16_t level;
+    //LOGV("\tReverbGetReverbLevel start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetReverbLevel")
+    //LOGV("\tReverbGetReverbLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetReverbLevel() just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (pContext->SavedReverbLevel + pContext->SavedRoomLevel)-LVREV_MAX_REVERB_LEVEL;
+
+    //LOGV("\tReverbGetReverbLevel() CombinedLevel is %d = %d + %d\n",
+    //CombinedLevel, pContext->SavedReverbLevel, pContext->SavedRoomLevel);
+    level = ReverbConvertLevel(CombinedLevel);
+
+    //LOGV("\tReverbGetReverbLevel(): ActiveParams.Level: %d, pContext->SavedReverbLevel: %d, "
+    //"pContext->SavedRoomLevel: %d, CombinedLevel: %d, converted level: %d\n",
+    //ActiveParams.Level, pContext->SavedReverbLevel,pContext->SavedRoomLevel, CombinedLevel,level);
+
+    if(ActiveParams.Level != level){
+        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetReverbLevel() has wrong level -> %d %d\n",
+                ActiveParams.Level, level);
+    }
+
+    //LOGV("\tReverbGetReverbLevel end\n");
+
+    return pContext->SavedReverbLevel;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetRoomLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the level to the Reverb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level       level to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetRoomLevel(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetRoomLevel start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetRoomLevel")
+    //LOGV("\tReverbSetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetRoomLevel() just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (level + pContext->SavedReverbLevel)-LVREV_MAX_REVERB_LEVEL;
+    ActiveParams.Level = ReverbConvertLevel(CombinedLevel);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetRoomLevel")
+    //LOGV("\tReverbSetRoomLevel() just Set -> %d\n", ActiveParams.Level);
+
+    pContext->SavedRoomLevel = level;
+    //LOGV("\tReverbSetRoomLevel end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetRoomLevel()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the level applied to the Revervb. Must first be converted to LVM format
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int16_t ReverbGetRoomLevel(ReverbContext *pContext){
+    int16_t level;
+    //LOGV("\tReverbGetRoomLevel start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT32                 CombinedLevel;             // Sum of room and reverb level controls
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetRoomLevel")
+    //LOGV("\tReverbGetRoomLevel Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetRoomLevel() just Got -> %d\n", ActiveParams.Level);
+
+    // needs to subtract max levels for both RoomLevel and ReverbLevel
+    CombinedLevel = (pContext->SavedRoomLevel + pContext->SavedReverbLevel-LVREV_MAX_REVERB_LEVEL);
+    level = ReverbConvertLevel(CombinedLevel);
+
+    //LOGV("\tReverbGetRoomLevel, Level = %d, pContext->SavedRoomLevel = %d, "
+    //     "pContext->SavedReverbLevel = %d, CombinedLevel = %d, level = %d",
+    //ActiveParams.Level, pContext->SavedRoomLevel, pContext->SavedReverbLevel, CombinedLevel, level);
+
+    if(ActiveParams.Level != level){
+        LOGV("\tLVM_ERROR : (ignore at start up) ReverbGetRoomLevel() has wrong level -> %d %d\n",
+              ActiveParams.Level, level);
+    }
+
+    //LOGV("\tReverbGetRoomLevel end");
+    return pContext->SavedRoomLevel;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDecayTime()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the decay time to the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  time        decay to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDecayTime(ReverbContext *pContext, uint32_t time){
+    //LOGV("\tReverbSetDecayTime start (%d)", time);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDecayTime")
+    //LOGV("\tReverbSetDecayTime Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDecayTime() just Got -> %d\n", ActiveParams.T60);
+
+    if (time <= LVREV_MAX_T60) {
+        ActiveParams.T60 = time;
+    }
+    else {
+        ActiveParams.T60 = LVREV_MAX_T60;
+    }
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayTime")
+    //LOGV("\tReverbSetDecayTime() just Set -> %d\n", ActiveParams.T60);
+
+    pContext->SavedDecayTime = time;
+    //LOGV("\tReverbSetDecayTime end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDecayTime()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the decay time applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDecayTime(ReverbContext *pContext){
+    //LOGV("\tReverbGetDecayTime start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDecayTime")
+    //LOGV("\tReverbGetDecayTime Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDecayTime() just Got -> %d\n", ActiveParams.T60);
+
+    if(ActiveParams.T60 != pContext->SavedDecayTime){
+        // This will fail if the decay time is set to more than 7000
+        LOGV("\tLVM_ERROR : ReverbGetDecayTime() has wrong level -> %d %d\n",
+         ActiveParams.T60, pContext->SavedDecayTime);
+    }
+
+    //LOGV("\tReverbGetDecayTime end");
+    return ActiveParams.T60;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDecayHfRatio()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the HF decay ratio to the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  ratio       ratio to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDecayHfRatio(ReverbContext *pContext, int16_t ratio){
+    //LOGV("\tReverbSetDecayHfRatioe start (%d)", ratio);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;   /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDecayHfRatio")
+    //LOGV("\tReverbSetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
+
+    ActiveParams.Damping = (LVM_INT16)(ratio/10);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDecayHfRatio")
+    //LOGV("\tReverbSetDecayHfRatio() just Set -> %d\n", ActiveParams.Damping);
+
+    pContext->SavedDecayHfRatio = ratio;
+    //LOGV("\tReverbSetDecayHfRatio end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDecayHfRatio()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the HF decay ratio applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDecayHfRatio(ReverbContext *pContext){
+    //LOGV("\tReverbGetDecayHfRatio start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;   /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDecayHfRatio")
+    //LOGV("\tReverbGetDecayHfRatio Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDecayHfRatio() just Got -> %d\n", ActiveParams.Damping);
+
+    if(ActiveParams.Damping != (LVM_INT16)(pContext->SavedDecayHfRatio / 10)){
+        LOGV("\tLVM_ERROR : ReverbGetDecayHfRatio() has wrong level -> %d %d\n",
+         ActiveParams.Damping, pContext->SavedDecayHfRatio);
+    }
+
+    //LOGV("\tReverbGetDecayHfRatio end");
+    return pContext->SavedDecayHfRatio;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDiffusion()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the diffusion to the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level        decay to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDiffusion(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetDiffusion start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDiffusion")
+    //LOGV("\tReverbSetDiffusion Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDiffusion() just Got -> %d\n", ActiveParams.Density);
+
+    ActiveParams.Density = (LVM_INT16)(level/10);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDiffusion")
+    //LOGV("\tReverbSetDiffusion() just Set -> %d\n", ActiveParams.Density);
+
+    pContext->SavedDiffusion = level;
+    //LOGV("\tReverbSetDiffusion end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDiffusion()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the decay time applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDiffusion(ReverbContext *pContext){
+    //LOGV("\tReverbGetDiffusion start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT16                 Temp;
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDiffusion")
+    //LOGV("\tReverbGetDiffusion Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDiffusion just Got -> %d\n", ActiveParams.Density);
+
+    Temp = (LVM_INT16)(pContext->SavedDiffusion/10);
+
+    if(ActiveParams.Density != Temp){
+        LOGV("\tLVM_ERROR : ReverbGetDiffusion invalid value %d %d", Temp, ActiveParams.Density);
+    }
+
+    //LOGV("\tReverbGetDiffusion end");
+    return pContext->SavedDiffusion;
+}
+
+//----------------------------------------------------------------------------
+// ReverbSetDensity()
+//----------------------------------------------------------------------------
+// Purpose:
+// Apply the density level the Reverb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//  level        decay to be applied
+//
+//----------------------------------------------------------------------------
+
+void ReverbSetDensity(ReverbContext *pContext, int16_t level){
+    //LOGV("\tReverbSetDensity start (%d)", level);
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbSetDensity")
+    //LOGV("\tReverbSetDensity Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbSetDensity just Got -> %d\n", ActiveParams.RoomSize);
+
+    ActiveParams.RoomSize = (LVM_INT16)(((level * 99) / 1000) + 1);
+
+    /* Activate the initial settings */
+    LvmStatus = LVREV_SetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_SetControlParameters", "ReverbSetDensity")
+    //LOGV("\tReverbSetDensity just Set -> %d\n", ActiveParams.RoomSize);
+
+    pContext->SavedDensity = level;
+    //LOGV("\tReverbSetDensity end");
+    return;
+}
+
+//----------------------------------------------------------------------------
+// ReverbGetDensity()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get the density level applied to the Revervb.
+//
+// Inputs:
+//  pContext:   effect engine context
+//
+//----------------------------------------------------------------------------
+
+int32_t ReverbGetDensity(ReverbContext *pContext){
+    //LOGV("\tReverbGetDensity start");
+
+    LVREV_ControlParams_st    ActiveParams;              /* Current control Parameters */
+    LVREV_ReturnStatus_en     LvmStatus=LVREV_SUCCESS;     /* Function call status */
+    LVM_INT16                 Temp;
+    /* Get the current settings */
+    LvmStatus = LVREV_GetControlParameters(pContext->hInstance, &ActiveParams);
+    LVM_ERROR_CHECK(LvmStatus, "LVREV_GetControlParameters", "ReverbGetDensity")
+    //LOGV("\tReverbGetDensity Succesfully returned from LVM_GetControlParameters\n");
+    //LOGV("\tReverbGetDensity() just Got -> %d\n", ActiveParams.RoomSize);
+
+
+    Temp = (LVM_INT16)(((pContext->SavedDensity * 99) / 1000) + 1);
+
+    if(Temp != ActiveParams.RoomSize){
+        LOGV("\tLVM_ERROR : ReverbGetDensity invalid value %d %d", Temp, ActiveParams.RoomSize);
+    }
+
+    //LOGV("\tReverbGetDensity end");
+    return pContext->SavedDensity;
+}
+
+//----------------------------------------------------------------------------
+// Reverb_getParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Get a Reverb parameter
+//
+// Inputs:
+//  pContext         - handle to instance data
+//  pParam           - pointer to parameter
+//  pValue           - pointer to variable to hold retrieved value
+//  pValueSize       - pointer to value size: maximum size as input
+//
+// Outputs:
+//  *pValue updated with parameter value
+//  *pValueSize updated with actual value size
+//
+//
+// Side Effects:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_getParameter(ReverbContext *pContext,
+                        void          *pParam,
+                        size_t        *pValueSize,
+                        void          *pValue){
+    int status = 0;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
+    char *name;
+    t_reverb_settings *pProperties;
+
+    //LOGV("\tReverb_getParameter start");
+
+    switch (param){
+        case REVERB_PARAM_ROOM_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize1 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_ROOM_HF_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize12 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_DECAY_TIME:
+            if (*pValueSize != sizeof(uint32_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize3 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(uint32_t);
+            break;
+        case REVERB_PARAM_DECAY_HF_RATIO:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize4 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_REFLECTIONS_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize5 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_REFLECTIONS_DELAY:
+            if (*pValueSize != sizeof(uint32_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize6 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(uint32_t);
+            break;
+        case REVERB_PARAM_REVERB_LEVEL:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize7 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_REVERB_DELAY:
+            if (*pValueSize != sizeof(uint32_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize8 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(uint32_t);
+            break;
+        case REVERB_PARAM_DIFFUSION:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize9 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_DENSITY:
+            if (*pValueSize != sizeof(int16_t)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize10 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(int16_t);
+            break;
+        case REVERB_PARAM_PROPERTIES:
+            if (*pValueSize != sizeof(t_reverb_settings)){
+                LOGV("\tLVM_ERROR : Reverb_getParameter() invalid pValueSize11 %d", *pValueSize);
+                return -EINVAL;
+            }
+            *pValueSize = sizeof(t_reverb_settings);
+            break;
+
+        default:
+            LOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
+            return -EINVAL;
+    }
+
+    pProperties = (t_reverb_settings *) pValue;
+
+    switch (param){
+        case REVERB_PARAM_PROPERTIES:
+            pProperties->roomLevel = ReverbGetRoomLevel(pContext);
+            pProperties->roomHFLevel = ReverbGetRoomHfLevel(pContext);
+            pProperties->decayTime = ReverbGetDecayTime(pContext);
+            pProperties->decayHFRatio = ReverbGetDecayHfRatio(pContext);
+            pProperties->reflectionsLevel = 0;
+            pProperties->reflectionsDelay = 0;
+            pProperties->reverbDelay = 0;
+            pProperties->reverbLevel = ReverbGetReverbLevel(pContext);
+            pProperties->diffusion = ReverbGetDiffusion(pContext);
+            pProperties->density = ReverbGetDensity(pContext);
+
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomLevel        %d",
+                pProperties->roomLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is roomHFLevel      %d",
+                pProperties->roomHFLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayTime        %d",
+                pProperties->decayTime);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is decayHFRatio     %d",
+                pProperties->decayHFRatio);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsLevel %d",
+                pProperties->reflectionsLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reflectionsDelay %d",
+                pProperties->reflectionsDelay);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbDelay      %d",
+                pProperties->reverbDelay);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is reverbLevel      %d",
+                pProperties->reverbLevel);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is diffusion        %d",
+                pProperties->diffusion);
+            LOGV("\tReverb_getParameter() REVERB_PARAM_PROPERTIES Value is density          %d",
+                pProperties->density);
+            break;
+
+        case REVERB_PARAM_ROOM_LEVEL:
+            *(int16_t *)pValue = ReverbGetRoomLevel(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_LEVEL Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_ROOM_HF_LEVEL:
+            *(int16_t *)pValue = ReverbGetRoomHfLevel(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_ROOM_HF_LEVEL Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_DECAY_TIME:
+            *(int32_t *)pValue = ReverbGetDecayTime(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_TIME Value is %d",
+            //        *(int32_t *)pValue);
+            break;
+        case REVERB_PARAM_DECAY_HF_RATIO:
+            *(int16_t *)pValue = ReverbGetDecayHfRatio(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_HF_RATION Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_REVERB_LEVEL:
+             *(int16_t *)pValue = ReverbGetReverbLevel(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_REVERB_LEVEL Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_DIFFUSION:
+            *(int16_t *)pValue = ReverbGetDiffusion(pContext);
+
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DECAY_DIFFUSION Value is %d",
+            //        *(int16_t *)pValue);
+            break;
+        case REVERB_PARAM_DENSITY:
+            *(uint16_t *)pValue = 0;
+            *(int16_t *)pValue = ReverbGetDensity(pContext);
+            //LOGV("\tReverb_getParameter() REVERB_PARAM_DENSITY Value is %d",
+            //        *(uint32_t *)pValue);
+            break;
+        case REVERB_PARAM_REFLECTIONS_LEVEL:
+            *(uint16_t *)pValue = 0;
+        case REVERB_PARAM_REFLECTIONS_DELAY:
+            *(uint32_t *)pValue = 0;
+        case REVERB_PARAM_REVERB_DELAY:
+            *(uint32_t *)pValue = 0;
+            break;
+
+        default:
+            LOGV("\tLVM_ERROR : Reverb_getParameter() invalid param %d", param);
+            status = -EINVAL;
+            break;
+    }
+
+    //LOGV("\tReverb_getParameter end");
+    return status;
+} /* end Reverb_getParameter */
+
+//----------------------------------------------------------------------------
+// Reverb_setParameter()
+//----------------------------------------------------------------------------
+// Purpose:
+// Set a Reverb parameter
+//
+// Inputs:
+//  pContext         - handle to instance data
+//  pParam           - pointer to parameter
+//  pValue           - pointer to value
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+
+int Reverb_setParameter (ReverbContext *pContext, void *pParam, void *pValue){
+    int status = 0;
+    int16_t level;
+    uint32_t time;
+    t_reverb_settings *pProperties;
+    int32_t *pParamTemp = (int32_t *)pParam;
+    int32_t param = *pParamTemp++;
+
+    //LOGV("\tReverb_setParameter start");
+
+    switch (param){
+        case REVERB_PARAM_PROPERTIES:
+            LOGV("\tReverb_setParameter() REVERB_PARAM_PROPERTIES");
+            pProperties = (t_reverb_settings *) pValue;
+            ReverbSetRoomLevel(pContext, pProperties->roomLevel);
+            ReverbSetRoomHfLevel(pContext, pProperties->roomHFLevel);
+            ReverbSetDecayTime(pContext, pProperties->decayTime);
+            ReverbSetDecayHfRatio(pContext, pProperties->decayHFRatio);
+            ReverbSetReverbLevel(pContext, pProperties->reverbLevel);
+            ReverbSetDiffusion(pContext, pProperties->diffusion);
+            ReverbSetDensity(pContext, pProperties->density);
+            break;
+        case REVERB_PARAM_ROOM_LEVEL:
+            level = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_LEVEL value is %d", level);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetRoomLevel");
+            ReverbSetRoomLevel(pContext, level);
+            //LOGV("\tReverb_setParameter() Called ReverbSetRoomLevel");
+           break;
+        case REVERB_PARAM_ROOM_HF_LEVEL:
+            level = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_ROOM_HF_LEVEL value is %d", level);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetRoomHfLevel");
+            ReverbSetRoomHfLevel(pContext, level);
+            //LOGV("\tReverb_setParameter() Called ReverbSetRoomHfLevel");
+           break;
+        case REVERB_PARAM_DECAY_TIME:
+            time = *(uint32_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_TIME value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDecayTime");
+            ReverbSetDecayTime(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDecayTime");
+           break;
+        case REVERB_PARAM_DECAY_HF_RATIO:
+            time = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_HF_RATIO value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDecayHfRatio");
+            ReverbSetDecayHfRatio(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDecayHfRatio");
+            break;
+         case REVERB_PARAM_REVERB_LEVEL:
+            level = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_REVERB_LEVEL value is %d", level);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetReverbLevel");
+            ReverbSetReverbLevel(pContext, level);
+            //LOGV("\tReverb_setParameter() Called ReverbSetReverbLevel");
+           break;
+        case REVERB_PARAM_DIFFUSION:
+            time = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DIFFUSION value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDiffusion");
+            ReverbSetDiffusion(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDiffusion");
+            break;
+        case REVERB_PARAM_DENSITY:
+            time = *(int16_t *)pValue;
+            //LOGV("\tReverb_setParameter() REVERB_PARAM_DECAY_DENSITY value is %d", time);
+            //LOGV("\tReverb_setParameter() Calling ReverbSetDensity");
+            ReverbSetDensity(pContext, time);
+            //LOGV("\tReverb_setParameter() Called ReverbSetDensity");
+            break;
+           break;
+        case REVERB_PARAM_REFLECTIONS_LEVEL:
+        case REVERB_PARAM_REFLECTIONS_DELAY:
+        case REVERB_PARAM_REVERB_DELAY:
+            break;
+        default:
+            LOGV("\tLVM_ERROR : Reverb_setParameter() invalid param %d", param);
+            break;
+    }
+
+    //LOGV("\tReverb_setParameter end");
+    return status;
+} /* end Reverb_setParameter */
+
+} // namespace
+} // namespace
+
+/* Effect Control Interface Implementation: Process */
+extern "C" int Reverb_process(effect_interface_t   self,
+                                 audio_buffer_t         *inBuffer,
+                                 audio_buffer_t         *outBuffer){
+    android::ReverbContext * pContext = (android::ReverbContext *) self;
+    int    status = 0;
+
+    if (pContext == NULL){
+        LOGV("\tLVM_ERROR : Reverb_process() ERROR pContext == NULL");
+        return -EINVAL;
+    }
+    if (inBuffer == NULL  || inBuffer->raw == NULL  ||
+            outBuffer == NULL || outBuffer->raw == NULL ||
+            inBuffer->frameCount != outBuffer->frameCount){
+        LOGV("\tLVM_ERROR : Reverb_process() ERROR NULL INPUT POINTER OR FRAME COUNT IS WRONG");
+        return -EINVAL;
+    }
+    if (pContext->bEnabled == LVM_FALSE){
+        LOGV("\tReverb_process() ERROR Effect is not enabled");
+        return -ENODATA;
+    }
+    //LOGV("\tReverb_process() Calling process with %d frames", outBuffer->frameCount);
+    /* Process all the available frames, block processing is handled internalLY by the LVM bundle */
+    status = process(    (LVM_INT16 *)inBuffer->raw,
+                         (LVM_INT16 *)outBuffer->raw,
+                                      outBuffer->frameCount,
+                                      pContext);
+
+    return status;
+}   /* end Reverb_process */
+
+/* Effect Control Interface Implementation: Command */
+extern "C" int Reverb_command(effect_interface_t  self,
+                              uint32_t            cmdCode,
+                              uint32_t            cmdSize,
+                              void                *pCmdData,
+                              uint32_t            *replySize,
+                              void                *pReplyData){
+    android::ReverbContext * pContext = (android::ReverbContext *) self;
+    int retsize;
+
+    if (pContext == NULL){
+        LOGV("\tLVM_ERROR : Reverb_command ERROR pContext == NULL");
+        return -EINVAL;
+    }
+
+    //LOGV("\tReverb_command INPUTS are: command %d cmdSize %d",cmdCode, cmdSize);
+
+    switch (cmdCode){
+        case EFFECT_CMD_INIT:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_INIT start");
+
+            if (pReplyData == NULL || *replySize != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_INIT: ERROR");
+                return -EINVAL;
+            }
+            *(int *) pReplyData = 0;
+            break;
+
+        case EFFECT_CMD_CONFIGURE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_CONFIGURE start");
+            if (pCmdData    == NULL||
+                cmdSize     != sizeof(effect_config_t)||
+                pReplyData  == NULL||
+                *replySize  != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_CONFIGURE: ERROR");
+                return -EINVAL;
+            }
+            *(int *) pReplyData = Reverb_configure(pContext, (effect_config_t *) pCmdData);
+            break;
+
+        case EFFECT_CMD_RESET:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_RESET start");
+            Reverb_configure(pContext, &pContext->config);
+            break;
+
+        case EFFECT_CMD_GET_PARAM:{
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_GET_PARAM start");
+            if (pCmdData == NULL ||
+                    cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
+                    pReplyData == NULL ||
+                    *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_GET_PARAM: ERROR");
+                return -EINVAL;
+            }
+            effect_param_t *p = (effect_param_t *)pCmdData;
+
+            memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
+
+            p = (effect_param_t *)pReplyData;
+
+            int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
+
+            p->status = android::Reverb_getParameter(pContext,
+                                                         (void *)p->data,
+                                                         (size_t  *)&p->vsize,
+                                                          p->data + voffset);
+
+            *replySize = sizeof(effect_param_t) + voffset + p->vsize;
+
+            //LOGV("\tReverb_command EFFECT_CMD_GET_PARAM "
+            //        "*pCmdData %d, *replySize %d, *pReplyData %d ",
+            //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+            //        *replySize,
+            //        *(int16_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset));
+
+        } break;
+        case EFFECT_CMD_SET_PARAM:{
+
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_SET_PARAM start");
+            //LOGV("\tReverb_command EFFECT_CMD_SET_PARAM param %d, *replySize %d, value %d ",
+            //        *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)),
+            //        *replySize,
+            //        *(int16_t *)((char *)pCmdData + sizeof(effect_param_t) + sizeof(int32_t)));
+
+            if (pCmdData == NULL || (cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)))
+                    || pReplyData == NULL || *replySize != (int)sizeof(int32_t)) {
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_SET_PARAM: ERROR");
+                return -EINVAL;
+            }
+
+            effect_param_t *p = (effect_param_t *) pCmdData;
+
+            if (p->psize != sizeof(int32_t)){
+                LOGV("\t4LVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_SET_PARAM: ERROR, psize is not sizeof(int32_t)");
+                return -EINVAL;
+            }
+
+            //LOGV("\tn5Reverb_command cmdSize is %d\n"
+            //        "\tsizeof(effect_param_t) is  %d\n"
+            //        "\tp->psize is %d\n"
+            //        "\tp->vsize is %d"
+            //        "\n",
+            //        cmdSize, sizeof(effect_param_t), p->psize, p->vsize );
+
+            *(int *)pReplyData = android::Reverb_setParameter(pContext,
+                                                             (void *)p->data,
+                                                              p->data + p->psize);
+        } break;
+
+        case EFFECT_CMD_ENABLE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_ENABLE start");
+
+            if (pReplyData == NULL || *replySize != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_ENABLE: ERROR");
+                return -EINVAL;
+            }
+            if(pContext->bEnabled == LVM_TRUE){
+                 LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                         "EFFECT_CMD_ENABLE: ERROR-Effect is already enabled");
+                 return -EINVAL;
+             }
+            *(int *)pReplyData = 0;
+            pContext->bEnabled = LVM_TRUE;
+            break;
+        case EFFECT_CMD_DISABLE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_DISABLE start");
+
+            if (pReplyData == NULL || *replySize != sizeof(int)){
+                LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                        "EFFECT_CMD_DISABLE: ERROR");
+                return -EINVAL;
+            }
+            if(pContext->bEnabled == LVM_FALSE){
+                 LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                         "EFFECT_CMD_DISABLE: ERROR-Effect is not yet enabled");
+                 return -EINVAL;
+             }
+            *(int *)pReplyData = 0;
+            pContext->bEnabled = LVM_FALSE;
+            break;
+
+        case EFFECT_CMD_SET_DEVICE:
+        case EFFECT_CMD_SET_VOLUME:
+        case EFFECT_CMD_SET_AUDIO_MODE:
+            //LOGV("\tReverb_command cmdCode Case: "
+            //        "EFFECT_CMD_SET_DEVICE/EFFECT_CMD_SET_VOLUME/EFFECT_CMD_SET_AUDIO_MODE start");
+            break;
+
+        default:
+            LOGV("\tLVM_ERROR : Reverb_command cmdCode Case: "
+                    "DEFAULT start %d ERROR",cmdCode);
+            return -EINVAL;
+    }
+
+    //LOGV("\tReverb_command end\n\n");
+    return 0;
+}    /* end Reverb_command */
+
+// effect_interface_t interface implementation for Reverb effect
+const struct effect_interface_s gReverbInterface = {
+    Reverb_process,
+    Reverb_command
+};    /* end gReverbInterface */
+
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
new file mode 100755
index 0000000..1ab423f
--- /dev/null
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECTREVERB_H_
+#define ANDROID_EFFECTREVERB_H_
+
+#include <media/EffectEnvironmentalReverbApi.h>
+#include <media/EffectPresetReverbApi.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct _LPFPair_t
+{
+    int16_t Room_HF;
+    int16_t LPF;
+} LPFPair_t;
+#if __cplusplus
+}  // extern "C"
+#endif
+
+
+#endif /*ANDROID_EFFECTREVERB_H_*/