OSDN Git Service

Fix headroom management in equalizer
authorEric Laurent <elaurent@google.com>
Fri, 7 Sep 2012 22:09:57 +0000 (15:09 -0700)
committerEric Laurent <elaurent@google.com>
Fri, 7 Sep 2012 22:09:57 +0000 (15:09 -0700)
Fix a bug resetting the headroom parameters when
calling the bundle process function for the first time.

Change-Id: Ie05f97606f415954340ff2a4e48cd7b0a97a063b

media/libeffects/lvm/lib/Bundle/src/LVM_Init.c

index dd34fb5..542c3c8 100644 (file)
@@ -557,9 +557,7 @@ LVM_ReturnStatus_en LVM_GetInstanceHandle(LVM_Handle_t           *phInstance,
      */
     pInstance->Params.OperatingMode    = LVM_MODE_OFF;
     pInstance->Params.SampleRate       = LVM_FS_8000;
-//  FIXME: Workaround to avoid reset of headroom parameters on first call to LVM_Process.
-//    pInstance->Params.SourceFormat     = LVM_MONO;
-    pInstance->Params.SourceFormat     = LVM_STEREO;
+    pInstance->Params.SourceFormat     = LVM_MONO;
     pInstance->Params.SpeakerType      = LVM_HEADPHONES;
     pInstance->Params.VC_EffectLevel   = 0;
     pInstance->Params.VC_Balance       = 0;
@@ -963,6 +961,7 @@ LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t  hInstance)
     LVM_InstParams_t        InstParams;                                 /* Instance parameters */
     LVM_ControlParams_t     Params;                                     /* Control Parameters */
     LVM_Instance_t          *pInstance  = (LVM_Instance_t  *)hInstance; /* Pointer to Instance */
+    LVM_HeadroomParams_t    HeadroomParams;
 
 
     if(hInstance == LVM_NULL){
@@ -972,6 +971,9 @@ LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t  hInstance)
     /* Save the control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
     LVM_GetControlParameters(hInstance, &Params);
 
+    /*Save the headroom parameters*/
+    LVM_GetHeadroomParams(hInstance, &HeadroomParams);
+
     /*  Retrieve allocated buffers in memtab */
     LVM_GetMemoryTable(hInstance, &MemTab,  LVM_NULL);
 
@@ -986,6 +988,9 @@ LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t  hInstance)
     /* Restore control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
     LVM_SetControlParameters(hInstance, &Params);
 
+    /*Restore the headroom parameters*/
+    LVM_SetHeadroomParams(hInstance, &HeadroomParams);
+
     /* DC removal filter */
     DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance);