LVM_API_Specials.c revision 2c8e5cab3faa6d360e222b7a6c40a80083d021ac
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     $Author: beq07716 $
21     $Revision: 1002 $
22     $Date: 2010-06-28 13:40:09 +0200 (Mon, 28 Jun 2010) $
23
24*****************************************************************************************/
25
26
27/****************************************************************************************/
28/*                                                                                      */
29/*    Includes                                                                          */
30/*                                                                                      */
31/****************************************************************************************/
32
33#include "LVM_Private.h"
34#include "LVM_Tables.h"
35
36/****************************************************************************************/
37/*                                                                                      */
38/* FUNCTION:                LVM_GetSpectrum                                             */
39/*                                                                                      */
40/* DESCRIPTION:                                                                         */
41/* This function is used to retrieve Spectral information at a given Audio time         */
42/* for display usage                                                                    */
43/*                                                                                      */
44/* PARAMETERS:                                                                          */
45/*  hInstance               Instance Handle                                             */
46/*  pCurrentPeaks           Pointer to location where currents peaks are to be saved    */
47/*  pPastPeaks              Pointer to location where past peaks are to be saved        */
48/*  AudioTime               Audio time at which the spectral information is needed      */
49/*                                                                                      */
50/* RETURNS:                                                                             */
51/*  LVM_SUCCESS             Succeeded                                                   */
52/*  LVM_NULLADDRESS         If any of input addresses are NULL                          */
53/*  LVM_WRONGAUDIOTIME      Failure due to audio time error                             */
54/*                                                                                      */
55/* NOTES:                                                                               */
56/*  1. This function may be interrupted by the LVM_Process function                     */
57/*                                                                                      */
58/****************************************************************************************/
59LVM_ReturnStatus_en LVM_GetSpectrum(
60                                    LVM_Handle_t            hInstance,
61                                    LVM_UINT8               *pCurrentPeaks,
62                                    LVM_UINT8               *pPastPeaks,
63                                    LVM_INT32               AudioTime
64                                    )
65{
66    LVM_Instance_t           *pInstance   = (LVM_Instance_t  *)hInstance;
67
68    pLVPSA_Handle_t        *hPSAInstance;
69    LVPSA_RETURN           LVPSA_Status;
70
71
72    if(pInstance == LVM_NULL)
73    {
74        return LVM_NULLADDRESS;
75    }
76
77    /*If PSA is not included at the time of instance creation, return without any processing*/
78    if(pInstance->InstParams.PSA_Included!=LVM_PSA_ON)
79    {
80        return LVM_SUCCESS;
81    }
82
83    hPSAInstance = pInstance->hPSAInstance;
84
85    if((pCurrentPeaks == LVM_NULL) ||
86        (pPastPeaks == LVM_NULL))
87    {
88        return LVM_NULLADDRESS;
89    }
90
91
92    /*
93     * Update new parameters if necessary
94     */
95    if (pInstance->ControlPending == LVM_TRUE)
96    {
97        LVM_ApplyNewSettings(hInstance);
98    }
99
100    /* If PSA module is disabled, do nothing */
101    if(pInstance->Params.PSA_Enable==LVM_PSA_OFF)
102    {
103        return LVM_ALGORITHMDISABLED;
104    }
105
106    LVPSA_Status = LVPSA_GetSpectrum(hPSAInstance,
107                            (LVPSA_Time) (AudioTime),
108                            (LVM_UINT8*) pCurrentPeaks,
109                            (LVM_UINT8*) pPastPeaks );
110
111    if(LVPSA_Status != LVPSA_OK)
112    {
113        if(LVPSA_Status == LVPSA_ERROR_WRONGTIME)
114        {
115            return (LVM_ReturnStatus_en) LVM_WRONGAUDIOTIME;
116        }
117        else
118        {
119            return (LVM_ReturnStatus_en) LVM_NULLADDRESS;
120        }
121    }
122
123    return(LVM_SUCCESS);
124}
125
126
127/****************************************************************************************/
128/*                                                                                      */
129/* FUNCTION:                LVM_SetVolumeNoSmoothing                                    */
130/*                                                                                      */
131/* DESCRIPTION:                                                                         */
132/* This function is used to set output volume without any smoothing                     */
133/*                                                                                      */
134/* PARAMETERS:                                                                          */
135/*  hInstance               Instance Handle                                             */
136/*  pParams                 Control Parameters, only volume value is used here          */
137/*                                                                                      */
138/* RETURNS:                                                                             */
139/*  LVM_SUCCESS             Succeeded                                                   */
140/*  LVM_NULLADDRESS         If any of input addresses are NULL                          */
141/*  LVM_OUTOFRANGE          When any of the control parameters are out of range         */
142/*                                                                                      */
143/* NOTES:                                                                               */
144/*  1. This function may be interrupted by the LVM_Process function                     */
145/*                                                                                      */
146/****************************************************************************************/
147LVM_ReturnStatus_en LVM_SetVolumeNoSmoothing( LVM_Handle_t           hInstance,
148                                              LVM_ControlParams_t    *pParams)
149{
150    LVM_Instance_t      *pInstance =(LVM_Instance_t  *)hInstance;
151    LVM_ReturnStatus_en Error;
152
153    /*Apply new controls*/
154    Error = LVM_SetControlParameters(hInstance,pParams);
155    pInstance->NoSmoothVolume = LVM_TRUE;
156    return Error;
157}
158
159