javauis/amms_qt/jni/src/equalizercontrol.cpp
changeset 23 98ccebc37403
child 26 dc7c549001d5
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2002 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 
       
    19 //#include <jutils.h>
       
    20 
       
    21 #include "com_nokia_amms_control_audioeffect_EqualizerControl.h"
       
    22 #include <mmafunctionserver.h>
       
    23 #include "cammsequalizercontrolgroup.h"
       
    24 
       
    25 /**
       
    26  * wrapper for CAMMSEqualizerControlGroup::GetBandLevelL()
       
    27  */
       
    28 static void GetBandLevelL(
       
    29     CAMMSEqualizerControlGroup *aControl,
       
    30     TInt aBand,
       
    31     TInt *aLevel)
       
    32 {
       
    33     aControl->GetBandLevelL(aBand, *aLevel);
       
    34 }
       
    35 
       
    36 /**
       
    37  * wrapper for CAMMSEqualizerControlGroup::CenterFreqL()
       
    38  */
       
    39 static void GetCenterFreqL(
       
    40     CAMMSEqualizerControlGroup *aControl,
       
    41     TInt aBand,
       
    42     TInt *aFrequency)
       
    43 {
       
    44     aControl->GetCenterFreqL(aBand, *aFrequency);
       
    45 }
       
    46 
       
    47 /**
       
    48  * wrapper for CAMMSEqualizerControlGroup::SetBandLevelL()
       
    49  */
       
    50 static void SetBandLevelL(
       
    51     CAMMSEqualizerControlGroup *aControl,
       
    52     TInt aLevel,
       
    53     TInt aBand)
       
    54 {
       
    55     aControl->SetBandLevelL(aLevel, aBand);
       
    56 }
       
    57 
       
    58 /**
       
    59  * wrapper for CAMMSEqualizerControlGroup::SetBassL()
       
    60  */
       
    61 static void SetBassL(CAMMSEqualizerControlGroup *aControl, TInt *aLevel, TInt *aSetLevel)
       
    62 {
       
    63     aControl->SetBassL(*aLevel, *aSetLevel);
       
    64 }
       
    65 
       
    66 /**
       
    67  * wrapper for CAMMSEqualizerControlGroup::SetTrebleL()
       
    68  */
       
    69 static void SetTrebleL(CAMMSEqualizerControlGroup *aControl, TInt *aLevel, TInt *aSetLevel)
       
    70 {
       
    71     aControl->SetTrebleL(*aLevel, *aSetLevel);
       
    72 }
       
    73 
       
    74 /*
       
    75  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
    76  * Method:    _getBand
       
    77  * Signature: (III)I
       
    78  */
       
    79 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getBand(
       
    80     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aFrequency)
       
    81 {
       
    82     CAMMSEqualizerControlGroup* control =
       
    83         static_cast<CAMMSEqualizerControlGroup*>(
       
    84             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
    85 
       
    86     return control->Band(aFrequency);
       
    87 }
       
    88 
       
    89 /*
       
    90  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
    91  * Method:    _getTreble
       
    92  * Signature: (II)I
       
    93  */
       
    94 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getTreble(
       
    95     JNIEnv*, jclass, jint aEventSource, jint aControl)
       
    96 {
       
    97     CAMMSEqualizerControlGroup* control =
       
    98         static_cast<CAMMSEqualizerControlGroup*>(
       
    99             reinterpret_cast< CAMMSControlGroup *>(aControl));
       
   100 
       
   101     return control->Treble();
       
   102 }
       
   103 
       
   104 /*
       
   105  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   106  * Method:    _setBass
       
   107  * Signature: (III)I
       
   108  */
       
   109 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1setBass(
       
   110     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aLevel)
       
   111 {
       
   112     MMAFunctionServer* eventSource =
       
   113         reinterpret_cast< MMAFunctionServer *>(aEventSource);
       
   114 
       
   115     CAMMSEqualizerControlGroup* control =
       
   116         static_cast<CAMMSEqualizerControlGroup*>(
       
   117             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   118 
       
   119     TInt error;
       
   120     TInt level = aLevel;
       
   121     TInt setLevel;
       
   122 
       
   123     error = eventSource->ExecuteTrap(SetBassL, control, &level, &setLevel);
       
   124     return (error < KErrNone) ? error : setLevel;
       
   125 }
       
   126 
       
   127 /*
       
   128  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   129  * Method:    _getCenterFreq
       
   130  * Signature: (III)I
       
   131  */
       
   132 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getCenterFreq(
       
   133     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aBand)
       
   134 {
       
   135     MMAFunctionServer* eventSource =
       
   136         reinterpret_cast< MMAFunctionServer* >(aEventSource);
       
   137 
       
   138     CAMMSEqualizerControlGroup* control =
       
   139         static_cast<CAMMSEqualizerControlGroup*>(
       
   140             reinterpret_cast< CAMMSControlGroup *>(aControl));
       
   141 
       
   142     TInt error;
       
   143     TInt freq;
       
   144 
       
   145     error = eventSource->ExecuteTrap(
       
   146                 GetCenterFreqL,
       
   147                 control,
       
   148                 (TInt) aBand,
       
   149                 &freq);
       
   150 
       
   151     return (error < KErrNone) ? error : freq;
       
   152 }
       
   153 
       
   154 /*
       
   155  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   156  * Method:    _setBandLevel
       
   157  * Signature: (IIII)I
       
   158  */
       
   159 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1setBandLevel(
       
   160     JNIEnv*,
       
   161     jclass,
       
   162     jint aEventSource,
       
   163     jint aControl,
       
   164     jint aLevel,
       
   165     jint aBand)
       
   166 {
       
   167     MMAFunctionServer* eventSource =
       
   168         reinterpret_cast< MMAFunctionServer *>(aEventSource);
       
   169 
       
   170     CAMMSEqualizerControlGroup* control =
       
   171         static_cast<CAMMSEqualizerControlGroup*>(
       
   172             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   173 
       
   174     TInt error;
       
   175     error = eventSource->ExecuteTrap(
       
   176                 SetBandLevelL,
       
   177                 control,
       
   178                 (TInt) aLevel,
       
   179                 (TInt) aBand);
       
   180 
       
   181     return error;
       
   182 }
       
   183 
       
   184 /*
       
   185  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   186  * Method:    _setTreble
       
   187  * Signature: (III)I
       
   188  */
       
   189 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1setTreble(
       
   190     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aLevel)
       
   191 {
       
   192     MMAFunctionServer* eventSource =
       
   193             reinterpret_cast< MMAFunctionServer* >(aEventSource);
       
   194 
       
   195     CAMMSEqualizerControlGroup* control =
       
   196         static_cast<CAMMSEqualizerControlGroup*>(
       
   197             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   198 
       
   199     TInt error;
       
   200     TInt level = aLevel;
       
   201     TInt setLevel;
       
   202 
       
   203     error = eventSource->ExecuteTrap(SetTrebleL, control, &level, &setLevel);
       
   204     return (error < KErrNone) ? error : setLevel;
       
   205 }
       
   206 
       
   207 /*
       
   208  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   209  * Method:    _getNumberOfBands
       
   210  * Signature: (II)I
       
   211  */
       
   212 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getNumberOfBands(
       
   213     JNIEnv*,
       
   214     jclass,
       
   215     jint aEventSource,
       
   216     jint aControl)
       
   217 {
       
   218     CAMMSEqualizerControlGroup* control =
       
   219         static_cast<CAMMSEqualizerControlGroup*>(
       
   220             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   221 
       
   222     return control->NumberOfBands();
       
   223 }
       
   224 
       
   225 /*
       
   226  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   227  * Method:    _getMinBandLevel
       
   228  * Signature: (IILI)I
       
   229  */
       
   230 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getMinBandLevel(
       
   231     JNIEnv*,
       
   232     jclass,
       
   233     jint aEventSource,
       
   234     jint aControl)
       
   235 {
       
   236     CAMMSEqualizerControlGroup* control =
       
   237         static_cast<CAMMSEqualizerControlGroup*>(
       
   238             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   239 
       
   240 
       
   241     return control->MinBandLevel();
       
   242 }
       
   243 
       
   244 /*
       
   245  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   246  * Method:    _getBass
       
   247  * Signature: (II)I
       
   248  */
       
   249 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getBass(
       
   250     JNIEnv*, jclass, jint aEventSource, jint aControl)
       
   251 {
       
   252     CAMMSEqualizerControlGroup* control =
       
   253         static_cast<CAMMSEqualizerControlGroup*>(
       
   254             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   255 
       
   256     return control->Bass();
       
   257 }
       
   258 
       
   259 /*
       
   260  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   261  * Method:    _getMaxBandLevel
       
   262  * Signature: (IILI)I
       
   263  */
       
   264 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getMaxBandLevel(
       
   265     JNIEnv*, jclass, jint aEventSource, jint aControl)
       
   266 {
       
   267     CAMMSEqualizerControlGroup* control =
       
   268         static_cast<CAMMSEqualizerControlGroup*>(
       
   269             reinterpret_cast< CAMMSControlGroup *>(aControl));
       
   270 
       
   271     return control->MaxBandLevel();
       
   272 }
       
   273 
       
   274 /*
       
   275  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   276  * Method:    _getBandLevel
       
   277  * Signature: (IIILI)I
       
   278  */
       
   279 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getBandLevel(
       
   280     JNIEnv* aJni,
       
   281     jclass,
       
   282     jint aEventSource,
       
   283     jint aControl,
       
   284     jint aBand,
       
   285     jintArray aLevel)
       
   286 {
       
   287     MMAFunctionServer* eventSource =
       
   288         reinterpret_cast< MMAFunctionServer *>(aEventSource);
       
   289 
       
   290     CAMMSEqualizerControlGroup* control =
       
   291         static_cast<CAMMSEqualizerControlGroup*>(
       
   292             reinterpret_cast< CAMMSControlGroup* >(aControl));
       
   293 
       
   294     TInt error;
       
   295     TInt level;
       
   296 
       
   297     error = eventSource->ExecuteTrap(
       
   298                 GetBandLevelL,
       
   299                 control,
       
   300                 (TInt) aBand,
       
   301                 &level);
       
   302 
       
   303     if (error == KErrNone)
       
   304     {
       
   305         // aLevel is an array of 1 element allocated at the java side
       
   306         aJni->SetIntArrayRegion(
       
   307             /*destination*/ aLevel,
       
   308             /*first*/ 0,
       
   309             /*count*/ 1,
       
   310             /*source*/ &level);
       
   311     }
       
   312     return error;
       
   313 }
       
   314 
       
   315 
       
   316 //  End of File