khronosfws/openmax_al/src/common/xaequalizeritf.c
changeset 42 1fa3fb47b1e3
parent 32 94fc26b6e006
child 47 c2e43643db4c
equal deleted inserted replaced
32:94fc26b6e006 42:1fa3fb47b1e3
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <stdio.h>
       
    19 #include <stdlib.h>
       
    20 #include <assert.h>
       
    21 #include "xaequalizeritf.h"
       
    22 
       
    23 #include "xaequalizeritfadaptation.h"
       
    24 
       
    25 static const XAuint16 equalizerNumOfPresets = 0;
       
    26 
       
    27 /**
       
    28  * XAEqualizerItfImpl* GetImpl(XAEqualizerItf self)
       
    29  * Description: Validated interface pointer and cast it to implementations pointer.
       
    30  **/
       
    31 static XAEqualizerItfImpl* GetImpl(XAEqualizerItf self)
       
    32 {
       
    33     if(self)
       
    34     {
       
    35         XAEqualizerItfImpl *impl = (XAEqualizerItfImpl*)(*self);
       
    36         if(impl && impl == impl->self)
       
    37         {
       
    38             return impl;
       
    39         }
       
    40     }
       
    41     return NULL;
       
    42 }
       
    43 
       
    44 /**
       
    45  * Base interface XAEqualizerItf implementation
       
    46  */
       
    47 
       
    48 /**
       
    49  * XAresult XAEqualizerItfImpl_SetEnabled(XAEqualizerItf self,XAboolean enabled)
       
    50  * Description: Enables the effect.
       
    51  **/
       
    52 XAresult XAEqualizerItfImpl_SetEnabled(XAEqualizerItf self,XAboolean enabled)
       
    53 {
       
    54     XAresult ret = XA_RESULT_SUCCESS;
       
    55     XAEqualizerItfImpl* impl = GetImpl(self);
       
    56     XAuint16 index = 0;
       
    57     DEBUG_API("->XAEqualizerItfImpl_SetEnabled");
       
    58 
       
    59     if(!impl)
       
    60     {
       
    61         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    62         DEBUG_API("<-XAEqualizerItfImpl_SetEnabled");
       
    63         /* invalid parameter */
       
    64         return XA_RESULT_PARAMETER_INVALID;
       
    65     }
       
    66 
       
    67 
       
    68     if(enabled && !(impl->enabled))
       
    69     {
       
    70         for(index = 0; index < EQUALIZER_NUM_OF_BANDS; index++)
       
    71         {
       
    72             if(impl->changeLevel[index])
       
    73             {
       
    74                 ret = XAEqualizerItfAdapt_SetBandLevel((XAAdaptationGstCtx*)impl->adapCtx, index, impl->levels[index]);
       
    75 
       
    76                 if(XA_RESULT_SUCCESS == ret)
       
    77                 {
       
    78                     impl->changeLevel[index] = XA_BOOLEAN_FALSE;
       
    79                 }
       
    80             }
       
    81         }
       
    82     }
       
    83     else if(!enabled && impl->enabled)
       
    84     {
       
    85         for(index = 0; index < EQUALIZER_NUM_OF_BANDS; index++)
       
    86         {
       
    87             ret = XAEqualizerItfAdapt_SetBandLevel((XAAdaptationGstCtx*)impl->adapCtx, index, EQUALIZER_DEFAULT_BAND_LEVEL);
       
    88 
       
    89             if(XA_RESULT_SUCCESS == ret)
       
    90             {
       
    91                 impl->changeLevel[index] = XA_BOOLEAN_FALSE;
       
    92             }
       
    93         }
       
    94     }
       
    95     else
       
    96     {
       
    97         /* do nothing */
       
    98     }
       
    99 
       
   100     if(ret == XA_RESULT_SUCCESS)
       
   101     {
       
   102         impl->enabled = enabled;
       
   103     }
       
   104 
       
   105     DEBUG_API("<-XAEqualizerItfImpl_SetEnabled");
       
   106     return ret;
       
   107 }
       
   108 
       
   109 /**
       
   110  * XAresult XAEqualizerItfImpl_IsEnabled(XAEqualizerItf self, XAboolean *pEnabled)
       
   111  * Description: Gets the enabled status of the effect.
       
   112  **/
       
   113 XAresult XAEqualizerItfImpl_IsEnabled(XAEqualizerItf self, XAboolean *pEnabled)
       
   114 {
       
   115     XAresult ret = XA_RESULT_SUCCESS;
       
   116 
       
   117     XAEqualizerItfImpl* impl = GetImpl(self);
       
   118     DEBUG_API("->XAEqualizerItfImpl_IsEnabled");
       
   119 
       
   120     if(!impl || !pEnabled)
       
   121     {
       
   122         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   123         DEBUG_API("<-XAEqualizerItfImpl_IsEnabled");
       
   124         /* invalid parameter */
       
   125         return XA_RESULT_PARAMETER_INVALID;
       
   126     }
       
   127 
       
   128     *pEnabled = impl->enabled;
       
   129 
       
   130     DEBUG_API("<-XAEqualizerItfImpl_IsEnabled");
       
   131     return ret;
       
   132 }
       
   133 
       
   134 /**
       
   135  * XAresult XAEqualizerItfImpl_GetNumberOfBands(XAEqualizerItf self,
       
   136  *                                              XAuint16 *pNumBands)
       
   137  * Description: Gets the number of frequency bands that the equalizer supports.
       
   138  * A valid equalizer must have at least two bands.
       
   139  **/
       
   140 XAresult XAEqualizerItfImpl_GetNumberOfBands(XAEqualizerItf self,
       
   141                                              XAuint16 *pNumBands)
       
   142 {
       
   143     XAresult ret = XA_RESULT_SUCCESS;
       
   144 
       
   145     XAEqualizerItfImpl* impl = GetImpl(self);
       
   146     DEBUG_API("->XAEqualizerItfImpl_GetNumberOfBands");
       
   147 
       
   148     if(!impl || !pNumBands)
       
   149     {
       
   150         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   151         DEBUG_API("<-XAEqualizerItfImpl_GetNumberOfBands");
       
   152         /* invalid parameter */
       
   153         return XA_RESULT_PARAMETER_INVALID;
       
   154     }
       
   155 
       
   156     *pNumBands = EQUALIZER_NUM_OF_BANDS;
       
   157 
       
   158     DEBUG_API("<-XAEqualizerItfImpl_GetNumberOfBands");
       
   159     return ret;
       
   160 }
       
   161 
       
   162 /**
       
   163  * XAresult XAEqualizerItfImpl_GetBandLevelRange(XAEqualizerItf self,
       
   164  *                                               XAmillibel *pMin,
       
   165  *                                               XAmillibel *pMax)
       
   166  * Description: Returns the minimun and maximun band levels supported.
       
   167  **/
       
   168 XAresult XAEqualizerItfImpl_GetBandLevelRange(XAEqualizerItf self,
       
   169                                               XAmillibel *pMin,
       
   170                                               XAmillibel *pMax)
       
   171 {
       
   172     XAresult ret = XA_RESULT_SUCCESS;
       
   173     XAEqualizerItfImpl* impl = GetImpl(self);
       
   174     DEBUG_API("->XAEqualizerItfImpl_GetBandLevelRange");
       
   175 
       
   176     if(!impl || (!pMin && !pMax)) /* other may be NULL */
       
   177     {
       
   178         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   179         DEBUG_API("<-XAEqualizerItfImpl_GetBandLevelRange");
       
   180         /* invalid parameter */
       
   181         return XA_RESULT_PARAMETER_INVALID;
       
   182     }
       
   183 
       
   184     ret = XAAdaptationBase_ThreadEntry(impl->adapCtx);
       
   185     if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED )
       
   186     {
       
   187         DEBUG_API("<-XAEqualizerItfImpl_GetBandLevelRange");
       
   188         return ret;
       
   189     }
       
   190     ret = XAEqualizerItfAdapt_GetBandLevelRange((XAAdaptationGstCtx*)impl->adapCtx, pMin, pMax);
       
   191     XAAdaptationBase_ThreadExit(impl->adapCtx);
       
   192 
       
   193     DEBUG_API("<-XAEqualizerItfImpl_GetBandLevelRange");
       
   194     return ret;
       
   195 }
       
   196 
       
   197 /**
       
   198  * XAresult XAEqualizerItfImpl_SetBandLevel(XAEqualizerItf self, XAuint16 band,
       
   199  *                                          XAmillibel level)
       
   200  * Description: Sets the given equalizer band to the given gain value.
       
   201  **/
       
   202 XAresult XAEqualizerItfImpl_SetBandLevel(XAEqualizerItf self, XAuint16 band,
       
   203                                          XAmillibel level)
       
   204 {
       
   205     XAresult ret = XA_RESULT_SUCCESS;
       
   206     XAuint16 numOfBands = 0;
       
   207     XAmillibel minLevel = 0;
       
   208     XAmillibel maxLevel = 0;
       
   209     XAEqualizerItfImpl* impl = NULL;
       
   210 
       
   211     DEBUG_API("->XAEqualizerItfImpl_SetBandLevel");
       
   212     impl = GetImpl(self);
       
   213 
       
   214     /* Get number of bands */
       
   215     if(XA_RESULT_SUCCESS != XAEqualizerItfImpl_GetNumberOfBands(self, &numOfBands))
       
   216     {
       
   217         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   218         DEBUG_API("<-XAEqualizerItfImpl_SetBandLevel");
       
   219         /* invalid parameter */
       
   220         return XA_RESULT_PARAMETER_INVALID;
       
   221     }
       
   222 
       
   223     /* Get minimum and maximum level */
       
   224     if(XA_RESULT_SUCCESS != XAEqualizerItfImpl_GetBandLevelRange(self, &minLevel, &maxLevel))
       
   225     {
       
   226         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   227         DEBUG_API("<-XAEqualizerItfImpl_SetBandLevel");
       
   228         /* invalid parameter */
       
   229         return XA_RESULT_PARAMETER_INVALID;
       
   230     }
       
   231 
       
   232     if(!impl || band > (numOfBands-1) || level < minLevel || level > maxLevel)
       
   233     {
       
   234         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   235         DEBUG_API("<-XAEqualizerItfImpl_SetBandLevel");
       
   236         /* invalid parameter */
       
   237         return XA_RESULT_PARAMETER_INVALID;
       
   238     }
       
   239  
       
   240     ret = XAAdaptationBase_ThreadEntry(impl->adapCtx);
       
   241     if( ret == XA_RESULT_PARAMETER_INVALID  || ret == XA_RESULT_PRECONDITIONS_VIOLATED )
       
   242     {
       
   243         DEBUG_API("<-XAEqualizerItfImpl_SetBandLevel");
       
   244         return ret;
       
   245     }
       
   246 
       
   247     if(impl->enabled)
       
   248     {
       
   249         ret = XAEqualizerItfAdapt_SetBandLevel((XAAdaptationGstCtx*)impl->adapCtx, band, level);
       
   250         if(XA_RESULT_SUCCESS == ret)
       
   251         {
       
   252             impl->levels[band] = level;
       
   253         }
       
   254     }
       
   255     else
       
   256     {
       
   257         impl->changeLevel[band] = XA_BOOLEAN_TRUE;
       
   258         impl->levels[band] = level;
       
   259     }
       
   260 
       
   261     XAAdaptationBase_ThreadExit(impl->adapCtx);
       
   262 
       
   263     DEBUG_API("<-XAEqualizerItfImpl_SetBandLevel");
       
   264     return ret;
       
   265 }
       
   266 
       
   267 /**
       
   268  * XAresult XAEqualizerItfImpl_GetBandLevel(XAEqualizerItf self, XAuint16 band,
       
   269  *                                          XAmillibel *pLevel)
       
   270  * Description: Gets the gain set for the given equalizer band.
       
   271  **/
       
   272 XAresult XAEqualizerItfImpl_GetBandLevel(XAEqualizerItf self, XAuint16 band,
       
   273                                          XAmillibel *pLevel)
       
   274 {
       
   275     XAresult ret = XA_RESULT_SUCCESS;
       
   276     
       
   277     XAEqualizerItfImpl* impl = GetImpl(self);
       
   278     DEBUG_API("->XAEqualizerItfImpl_GetBandLevel");
       
   279 
       
   280     if(!impl || !pLevel ||  band >= EQUALIZER_NUM_OF_BANDS)
       
   281     {
       
   282         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   283         DEBUG_API("<-XAEqualizerItfImpl_GetBandLevel");
       
   284         /* invalid parameter */
       
   285         return XA_RESULT_PARAMETER_INVALID;
       
   286     }
       
   287 
       
   288     *pLevel = impl->levels[band];
       
   289     DEBUG_API("<-XAEqualizerItfImpl_GetBandLevel");
       
   290     return ret;
       
   291 }
       
   292 
       
   293 /**
       
   294  * XAresult XAEqualizerItfImpl_GetCenterFreq(XAEqualizerItf self, XAuint16 band,
       
   295  *                                           XAmilliHertz *pCenter)
       
   296  * Description: Gets the center frequency of the given band.
       
   297  **/
       
   298 XAresult XAEqualizerItfImpl_GetCenterFreq(XAEqualizerItf self, XAuint16 band,
       
   299                                           XAmilliHertz *pCenter)
       
   300 {
       
   301     XAresult ret = XA_RESULT_SUCCESS;
       
   302     XAEqualizerItfImpl* impl = GetImpl(self);
       
   303     DEBUG_API("->XAEqualizerItfImpl_GetCenterFreq");
       
   304 
       
   305     if(!impl || !pCenter)
       
   306     {
       
   307         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   308         DEBUG_API("<-XAEqualizerItfImpl_GetCenterFreq");
       
   309         /* invalid parameter */
       
   310         return XA_RESULT_PARAMETER_INVALID;
       
   311     }
       
   312 
       
   313     ret = XAAdaptationBase_ThreadEntry(impl->adapCtx);
       
   314     if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED )
       
   315     {
       
   316         DEBUG_API("<-XAEqualizerItfImpl_GetCenterFreq");
       
   317         return ret;
       
   318     }
       
   319     ret = XAEqualizerItfAdapt_GetCenterFreq((XAAdaptationGstCtx*)impl->adapCtx, band, pCenter);
       
   320 
       
   321     XAAdaptationBase_ThreadExit(impl->adapCtx);
       
   322 
       
   323     DEBUG_API("<-XAEqualizerItfImpl_GetCenterFreq");
       
   324     return ret;
       
   325 }
       
   326 
       
   327 /**
       
   328  * XAresult XAEqualizerItfImpl_GetBandFreqRange(XAEqualizerItf self, XAuint16 band,
       
   329  *                                              XAmilliHertz *pMin,
       
   330  *                                              XAmilliHertz *pMax)
       
   331  * Description: Gets the frequency range of the given frequency band.
       
   332  **/
       
   333 XAresult XAEqualizerItfImpl_GetBandFreqRange(XAEqualizerItf self, XAuint16 band,
       
   334                                              XAmilliHertz *pMin,
       
   335                                              XAmilliHertz *pMax)
       
   336 {
       
   337     XAresult ret = XA_RESULT_SUCCESS;
       
   338     XAuint16 numOfBands = 0;
       
   339     XAEqualizerItfImpl* impl = GetImpl(self);
       
   340     DEBUG_API("->XAEqualizerItfImpl_GetBandFreqRange");
       
   341 
       
   342     /* Get number of bands */
       
   343     if(XA_RESULT_SUCCESS != XAEqualizerItfImpl_GetNumberOfBands(self, &numOfBands))
       
   344     {
       
   345         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   346         DEBUG_API("<-XAEqualizerItfImpl_GetBandFreqRange");
       
   347         /* invalid parameter */
       
   348         return XA_RESULT_PARAMETER_INVALID;
       
   349     }
       
   350 
       
   351     if(!impl || (!pMin && !pMax) || band > numOfBands) /* pMin or pMax may be NULL */
       
   352     {
       
   353         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   354         DEBUG_API("<-XAEqualizerItfImpl_GetBandFreqRange");
       
   355         /* invalid parameter */
       
   356         return XA_RESULT_PARAMETER_INVALID;
       
   357     }
       
   358 
       
   359  
       
   360     ret = XAAdaptationBase_ThreadEntry(impl->adapCtx);
       
   361     if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED )
       
   362     {
       
   363         DEBUG_API("<-XAEqualizerItfImpl_GetBandFreqRange");
       
   364         return ret;
       
   365     }
       
   366     ret = XAEqualizerItfAdapt_GetBandFreqRange((XAAdaptationGstCtx*)impl->adapCtx, band, pMin, pMax);
       
   367 
       
   368     XAAdaptationBase_ThreadExit(impl->adapCtx);
       
   369   
       
   370     DEBUG_API("<-XAEqualizerItfImpl_GetBandFreqRange");
       
   371     return ret;
       
   372 }
       
   373 
       
   374 /**
       
   375  * XAresult XAEqualizerItfImpl_GetBand(XAEqualizerItf self, XAmilliHertz frequency,
       
   376  *                                     XAuint16 *pBand)
       
   377  *
       
   378  * Description: Gets the band that has the most effect on the given frequency.
       
   379  * If no band has an effect on the given frequency, XA_EQUALIZER_UNDEFINED is returned.
       
   380  **/
       
   381 XAresult XAEqualizerItfImpl_GetBand(XAEqualizerItf self, XAmilliHertz frequency,
       
   382                                     XAuint16 *pBand)
       
   383 {
       
   384     XAresult ret = XA_RESULT_SUCCESS;
       
   385     XAEqualizerItfImpl* impl = GetImpl(self);
       
   386     DEBUG_API("->XAEqualizerItfImpl_GetBand");
       
   387 
       
   388     if(!impl || !pBand)
       
   389     {
       
   390         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   391         DEBUG_API("<-XAEqualizerItfImpl_GetBand");
       
   392         /* invalid parameter */
       
   393         return XA_RESULT_PARAMETER_INVALID;
       
   394     }
       
   395   
       
   396     ret = XAAdaptationBase_ThreadEntry(impl->adapCtx);
       
   397     if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED )
       
   398     {
       
   399         DEBUG_API("<-XAEqualizerItfImpl_GetBand");
       
   400         return ret;
       
   401     }
       
   402     ret = XAEqualizerItfAdapt_GetBand((XAAdaptationGstCtx*)impl->adapCtx, frequency, pBand);
       
   403 
       
   404     XAAdaptationBase_ThreadExit(impl->adapCtx);
       
   405 
       
   406     DEBUG_API("<-XAEqualizerItfImpl_GetBand");
       
   407     return ret;
       
   408 }
       
   409 
       
   410 /**
       
   411  * XAresult XAEqualizerItfImpl_GetCurrentPreset(XAEqualizerItf self,
       
   412  *                                              XAuint16 *pPreset)
       
   413  * Description: Gets the current preset.
       
   414  **/
       
   415 XAresult XAEqualizerItfImpl_GetCurrentPreset(XAEqualizerItf self,
       
   416                                              XAuint16 *pPreset)
       
   417 {
       
   418     XAresult ret = XA_RESULT_SUCCESS;
       
   419     XAEqualizerItfImpl* impl = GetImpl(self);
       
   420     DEBUG_API("->XAEqualizerItfImpl_GetCurrentPreset");
       
   421 
       
   422     if(!impl || !pPreset)
       
   423     {
       
   424         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   425         DEBUG_API("<-XAEqualizerItfImpl_GetCurrentPreset");
       
   426         /* invalid parameter */
       
   427         return XA_RESULT_PARAMETER_INVALID;
       
   428     }
       
   429 
       
   430     /* no presets defined */
       
   431 
       
   432     if(ret == XA_RESULT_SUCCESS)
       
   433     {
       
   434         *pPreset = impl->preset;
       
   435     }
       
   436 
       
   437     DEBUG_API("<-XAEqualizerItfImpl_GetCurrentPreset");
       
   438     return ret;
       
   439 }
       
   440 
       
   441 /**
       
   442  * XAresult XAEqualizerItfImpl_UsePreset(XAEqualizerItf self, XAuint16 index)
       
   443  * Description: Sets the equalizer according to the given preset
       
   444  **/
       
   445 XAresult XAEqualizerItfImpl_UsePreset(XAEqualizerItf self, XAuint16 index)
       
   446 {
       
   447     XAresult ret = XA_RESULT_SUCCESS;
       
   448     XAuint16 numOfPresets = 0;
       
   449     XAEqualizerItfImpl* impl = GetImpl(self);
       
   450 
       
   451     DEBUG_API("->XAEqualizerItfImpl_UsePreset");
       
   452 
       
   453     /* get number of presets */
       
   454     if( XA_RESULT_SUCCESS != XAEqualizerItfImpl_GetNumberOfPresets(self, &numOfPresets))
       
   455     {
       
   456         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   457         DEBUG_API("<-XAEqualizerItfImpl_UsePreset");
       
   458         /* invalid parameter */
       
   459         return XA_RESULT_PARAMETER_INVALID;
       
   460     }
       
   461 
       
   462     if(!impl || index >= numOfPresets )
       
   463     {
       
   464         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   465         DEBUG_API("<-XAEqualizerItfImpl_UsePreset");
       
   466         /* invalid parameter */
       
   467         return XA_RESULT_PARAMETER_INVALID;
       
   468     }
       
   469 
       
   470     impl->preset = index;
       
   471 
       
   472     DEBUG_API("<-XAEqualizerItfImpl_UsePreset");
       
   473     return ret;
       
   474 }
       
   475 
       
   476 /**
       
   477  * XAresult XAEqualizerItfImpl_GetNumberOfPresets(XAEqualizerItf self,
       
   478  *                                                XAuint16 *pNumPresets)
       
   479  * Description: Gets the total number of presets the equalizer supports.
       
   480  **/
       
   481 XAresult XAEqualizerItfImpl_GetNumberOfPresets(XAEqualizerItf self,
       
   482                                                XAuint16 *pNumPresets)
       
   483 {
       
   484     XAresult ret = XA_RESULT_SUCCESS;
       
   485     XAEqualizerItfImpl* impl = GetImpl(self);
       
   486     DEBUG_API("->XAEqualizerItfImpl_GetNumberOfPresets");
       
   487 
       
   488     if(!impl || !pNumPresets)
       
   489     {
       
   490         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   491         DEBUG_API("<-XAEqualizerItfImpl_GetNumberOfPresets");
       
   492         /* invalid parameter */
       
   493         return XA_RESULT_PARAMETER_INVALID;
       
   494     }
       
   495 
       
   496     /* No presets defined. */
       
   497     *pNumPresets = equalizerNumOfPresets;
       
   498 
       
   499     DEBUG_API("<-XAEqualizerItfImpl_GetNumberOfPresets");
       
   500     return ret;
       
   501 }
       
   502 
       
   503 /**
       
   504  * XAresult XAEqualizerItfImpl_GetPresetName(XAEqualizerItf self, XAuint16 index,
       
   505  *                                           const XAchar **ppName)
       
   506  * Description: Gets the preset name based on the index.
       
   507  **/
       
   508 XAresult XAEqualizerItfImpl_GetPresetName(XAEqualizerItf self, XAuint16 index,
       
   509                                           const XAchar **ppName)
       
   510 {
       
   511     XAresult ret = XA_RESULT_SUCCESS;
       
   512     XAuint16 numOfPresets = 0;
       
   513     XAEqualizerItfImpl* impl = GetImpl(self);
       
   514 
       
   515     DEBUG_API("->XAEqualizerItfImpl_GetPresetName");
       
   516 
       
   517     /* get number of presets */
       
   518     if( XA_RESULT_SUCCESS != XAEqualizerItfImpl_GetNumberOfPresets(self, &numOfPresets))
       
   519     {
       
   520         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   521         DEBUG_API("<-XAEqualizerItfImpl_GetPresetName");
       
   522         /* invalid parameter */
       
   523         return XA_RESULT_PARAMETER_INVALID;
       
   524     }
       
   525 
       
   526     if(!impl || !ppName || index > (numOfPresets-1))
       
   527     {
       
   528         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   529         DEBUG_API("<-XAEqualizerItfImpl_GetPresetName");
       
   530         /* invalid parameter */
       
   531         return XA_RESULT_PARAMETER_INVALID;
       
   532     }
       
   533 
       
   534     /* Implementation placeholder here for presets when defined.
       
   535        Currently always return XA_RESULT_PARAMETER_INVALID */
       
   536 
       
   537     DEBUG_API("<-XAEqualizerItfImpl_GetPresetName");
       
   538     return ret;
       
   539 }
       
   540 
       
   541 /**
       
   542  * XAEqualizerItfImpl -specific methods
       
   543  **/
       
   544  
       
   545 
       
   546 /**
       
   547  * XAEqualizerItfImplImpl* XAEqualizerItfImpl_Create()
       
   548  * @return  XAEqualizerItfImplImpl* - Pointer to  EqualizerItf interface implementation
       
   549  **/
       
   550 XAEqualizerItfImpl* XAEqualizerItfImpl_Create(XAAdaptationBaseCtx *adapCtx)
       
   551 {
       
   552     XAuint16 index = 0;
       
   553 
       
   554     XAEqualizerItfImpl *self = (XAEqualizerItfImpl*)
       
   555         calloc(1,sizeof(XAEqualizerItfImpl));
       
   556 
       
   557     DEBUG_API("->XAEqualizerItfImpl_Create");
       
   558 
       
   559     if(self)
       
   560     {
       
   561         /* init itf default implementation */
       
   562         self->itf.GetBand = XAEqualizerItfImpl_GetBand;
       
   563         self->itf.GetBandFreqRange = XAEqualizerItfImpl_GetBandFreqRange;
       
   564         self->itf.GetBandLevel = XAEqualizerItfImpl_GetBandLevel;
       
   565         self->itf.GetBandLevelRange = XAEqualizerItfImpl_GetBandLevelRange;
       
   566         self->itf.GetCenterFreq = XAEqualizerItfImpl_GetCenterFreq;
       
   567         self->itf.GetCurrentPreset = XAEqualizerItfImpl_GetCurrentPreset;
       
   568         self->itf.GetNumberOfBands = XAEqualizerItfImpl_GetNumberOfBands;
       
   569         self->itf.GetNumberOfPresets = XAEqualizerItfImpl_GetNumberOfPresets;
       
   570         self->itf.GetPresetName = XAEqualizerItfImpl_GetPresetName;
       
   571         self->itf.IsEnabled = XAEqualizerItfImpl_IsEnabled;
       
   572         self->itf.SetBandLevel = XAEqualizerItfImpl_SetBandLevel;
       
   573         self->itf.SetEnabled = XAEqualizerItfImpl_SetEnabled;
       
   574         self->itf.UsePreset = XAEqualizerItfImpl_UsePreset;
       
   575 
       
   576         /* init variables */
       
   577         self->enabled = XA_BOOLEAN_FALSE;
       
   578         self->preset = XA_EQUALIZER_UNDEFINED;
       
   579 
       
   580         for(index = 0; index < EQUALIZER_NUM_OF_BANDS; index++)
       
   581         {
       
   582             self->levels[index] = EQUALIZER_DEFAULT_BAND_LEVEL;
       
   583             self->changeLevel[index] = XA_BOOLEAN_FALSE;
       
   584         }
       
   585 
       
   586         self->adapCtx = adapCtx;
       
   587 
       
   588         self->self = self;
       
   589     }
       
   590 
       
   591     DEBUG_API("<-XAEqualizerItfImpl_Create");
       
   592     return self;
       
   593 }
       
   594 
       
   595 /**
       
   596  * void XAEqualizerItfImpl_Free(XAEqualizerItfImpl* self)
       
   597  * @param  XAEqualizerItfImpl* self -
       
   598  **/
       
   599 void XAEqualizerItfImpl_Free(XAEqualizerItfImpl* self)
       
   600 {
       
   601     DEBUG_API("->XAEqualizerItfImpl_Free");
       
   602     assert(self==self->self);
       
   603     free(self);
       
   604     DEBUG_API("<-XAEqualizerItfImpl_Free");
       
   605 }