• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /****************************************************************************************/
19 /*                                                                                      */
20 /*    Includes                                                                          */
21 /*                                                                                      */
22 /****************************************************************************************/
23 
24 #include "LVM_Private.h"
25 #include "LVM_Tables.h"
26 
27 /****************************************************************************************/
28 /*                                                                                      */
29 /* FUNCTION:                LVM_GetSpectrum                                             */
30 /*                                                                                      */
31 /* DESCRIPTION:                                                                         */
32 /* This function is used to retrieve Spectral information at a given Audio time         */
33 /* for display usage                                                                    */
34 /*                                                                                      */
35 /* PARAMETERS:                                                                          */
36 /*  hInstance               Instance Handle                                             */
37 /*  pCurrentPeaks           Pointer to location where currents peaks are to be saved    */
38 /*  pPastPeaks              Pointer to location where past peaks are to be saved        */
39 /*  AudioTime               Audio time at which the spectral information is needed      */
40 /*                                                                                      */
41 /* RETURNS:                                                                             */
42 /*  LVM_SUCCESS             Succeeded                                                   */
43 /*  LVM_NULLADDRESS         If any of input addresses are NULL                          */
44 /*  LVM_WRONGAUDIOTIME      Failure due to audio time error                             */
45 /*                                                                                      */
46 /* NOTES:                                                                               */
47 /*  1. This function may be interrupted by the LVM_Process function                     */
48 /*                                                                                      */
49 /****************************************************************************************/
LVM_GetSpectrum(LVM_Handle_t hInstance,LVM_UINT8 * pCurrentPeaks,LVM_UINT8 * pPastPeaks,LVM_INT32 AudioTime)50 LVM_ReturnStatus_en LVM_GetSpectrum(LVM_Handle_t hInstance, LVM_UINT8* pCurrentPeaks,
51                                     LVM_UINT8* pPastPeaks, LVM_INT32 AudioTime) {
52     LVM_Instance_t* pInstance = (LVM_Instance_t*)hInstance;
53 
54     pLVPSA_Handle_t* hPSAInstance;
55     LVPSA_RETURN LVPSA_Status;
56 
57     if (pInstance == LVM_NULL) {
58         return LVM_NULLADDRESS;
59     }
60 
61     /*If PSA is not included at the time of instance creation, return without any processing*/
62     if (pInstance->InstParams.PSA_Included != LVM_PSA_ON) {
63         return LVM_SUCCESS;
64     }
65 
66     hPSAInstance = (pLVPSA_Handle_t*)pInstance->hPSAInstance;
67 
68     if ((pCurrentPeaks == LVM_NULL) || (pPastPeaks == LVM_NULL)) {
69         return LVM_NULLADDRESS;
70     }
71 
72     /*
73      * Update new parameters if necessary
74      */
75     if (pInstance->ControlPending == LVM_TRUE) {
76         LVM_ApplyNewSettings(hInstance);
77     }
78 
79     /* If PSA module is disabled, do nothing */
80     if (pInstance->Params.PSA_Enable == LVM_PSA_OFF) {
81         return LVM_ALGORITHMDISABLED;
82     }
83 
84     LVPSA_Status = LVPSA_GetSpectrum(hPSAInstance, (LVPSA_Time)(AudioTime),
85                                      (LVM_UINT8*)pCurrentPeaks, (LVM_UINT8*)pPastPeaks);
86 
87     if (LVPSA_Status != LVPSA_OK) {
88         if (LVPSA_Status == LVPSA_ERROR_WRONGTIME) {
89             return (LVM_ReturnStatus_en)LVM_WRONGAUDIOTIME;
90         } else {
91             return (LVM_ReturnStatus_en)LVM_NULLADDRESS;
92         }
93     }
94 
95     return (LVM_SUCCESS);
96 }
97 
98 /****************************************************************************************/
99 /*                                                                                      */
100 /* FUNCTION:                LVM_SetVolumeNoSmoothing                                    */
101 /*                                                                                      */
102 /* DESCRIPTION:                                                                         */
103 /* This function is used to set output volume without any smoothing                     */
104 /*                                                                                      */
105 /* PARAMETERS:                                                                          */
106 /*  hInstance               Instance Handle                                             */
107 /*  pParams                 Control Parameters, only volume value is used here          */
108 /*                                                                                      */
109 /* RETURNS:                                                                             */
110 /*  LVM_SUCCESS             Succeeded                                                   */
111 /*  LVM_NULLADDRESS         If any of input addresses are NULL                          */
112 /*  LVM_OUTOFRANGE          When any of the control parameters are out of range         */
113 /*                                                                                      */
114 /* NOTES:                                                                               */
115 /*  1. This function may be interrupted by the LVM_Process function                     */
116 /*                                                                                      */
117 /****************************************************************************************/
LVM_SetVolumeNoSmoothing(LVM_Handle_t hInstance,LVM_ControlParams_t * pParams)118 LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing(LVM_Handle_t hInstance, LVM_ControlParams_t* pParams) {
119     LVM_Instance_t* pInstance = (LVM_Instance_t*)hInstance;
120     LVM_ReturnStatus_en Error;
121 
122     /*Apply new controls*/
123     Error = LVM_SetControlParameters(hInstance, pParams);
124     pInstance->NoSmoothVolume = LVM_TRUE;
125     return Error;
126 }
127