javauis/amms_akn/jni/src/equalizercontrol.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     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 <cmmaeventsource.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     CMMAEventSource* eventSource =
       
    83         JavaUnhand< CMMAEventSource >(aEventSource);
       
    84 
       
    85     CAMMSEqualizerControlGroup* control =
       
    86         static_cast<CAMMSEqualizerControlGroup*>(
       
    87             JavaUnhand< CAMMSControlGroup >(aControl));
       
    88 
       
    89     return control->Band(aFrequency);
       
    90 }
       
    91 
       
    92 /*
       
    93  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
    94  * Method:    _getTreble
       
    95  * Signature: (II)I
       
    96  */
       
    97 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getTreble(
       
    98     JNIEnv*, jclass, jint aEventSource, jint aControl)
       
    99 {
       
   100     CMMAEventSource* eventSource =
       
   101         JavaUnhand< CMMAEventSource >(aEventSource);
       
   102 
       
   103     CAMMSEqualizerControlGroup* control =
       
   104         static_cast<CAMMSEqualizerControlGroup*>(
       
   105             JavaUnhand< CAMMSControlGroup >(aControl));
       
   106 
       
   107     return control->Treble();
       
   108 }
       
   109 
       
   110 /*
       
   111  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   112  * Method:    _setBass
       
   113  * Signature: (III)I
       
   114  */
       
   115 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1setBass(
       
   116     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aLevel)
       
   117 {
       
   118     CMMAEventSource* eventSource =
       
   119         JavaUnhand< CMMAEventSource >(aEventSource);
       
   120 
       
   121     CAMMSEqualizerControlGroup* control =
       
   122         static_cast<CAMMSEqualizerControlGroup*>(
       
   123             JavaUnhand< CAMMSControlGroup >(aControl));
       
   124 
       
   125     TInt error;
       
   126     TInt level = aLevel;
       
   127     TInt setLevel;
       
   128 
       
   129     error = eventSource->ExecuteTrap(SetBassL, control, &level, &setLevel);
       
   130     return (error < KErrNone) ? error : setLevel;
       
   131 }
       
   132 
       
   133 /*
       
   134  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   135  * Method:    _getCenterFreq
       
   136  * Signature: (III)I
       
   137  */
       
   138 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getCenterFreq(
       
   139     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aBand)
       
   140 {
       
   141     CMMAEventSource* eventSource =
       
   142         JavaUnhand< CMMAEventSource >(aEventSource);
       
   143 
       
   144     CAMMSEqualizerControlGroup* control =
       
   145         static_cast<CAMMSEqualizerControlGroup*>(
       
   146             JavaUnhand< CAMMSControlGroup >(aControl));
       
   147 
       
   148     TInt error;
       
   149     TInt freq;
       
   150 
       
   151     error = eventSource->ExecuteTrap(
       
   152                 GetCenterFreqL,
       
   153                 control,
       
   154                 (TInt) aBand,
       
   155                 &freq);
       
   156 
       
   157     return (error < KErrNone) ? error : freq;
       
   158 }
       
   159 
       
   160 /*
       
   161  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   162  * Method:    _setBandLevel
       
   163  * Signature: (IIII)I
       
   164  */
       
   165 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1setBandLevel(
       
   166     JNIEnv*,
       
   167     jclass,
       
   168     jint aEventSource,
       
   169     jint aControl,
       
   170     jint aLevel,
       
   171     jint aBand)
       
   172 {
       
   173     CMMAEventSource* eventSource =
       
   174         JavaUnhand< CMMAEventSource >(aEventSource);
       
   175 
       
   176     CAMMSEqualizerControlGroup* control =
       
   177         static_cast<CAMMSEqualizerControlGroup*>(
       
   178             JavaUnhand< CAMMSControlGroup >(aControl));
       
   179 
       
   180     TInt error;
       
   181     error = eventSource->ExecuteTrap(
       
   182                 SetBandLevelL,
       
   183                 control,
       
   184                 (TInt) aLevel,
       
   185                 (TInt) aBand);
       
   186 
       
   187     return error;
       
   188 }
       
   189 
       
   190 /*
       
   191  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   192  * Method:    _setTreble
       
   193  * Signature: (III)I
       
   194  */
       
   195 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1setTreble(
       
   196     JNIEnv*, jclass, jint aEventSource, jint aControl, jint aLevel)
       
   197 {
       
   198     CMMAEventSource* eventSource =
       
   199         JavaUnhand< CMMAEventSource >(aEventSource);
       
   200 
       
   201     CAMMSEqualizerControlGroup* control =
       
   202         static_cast<CAMMSEqualizerControlGroup*>(
       
   203             JavaUnhand< CAMMSControlGroup >(aControl));
       
   204 
       
   205     TInt error;
       
   206     TInt level = aLevel;
       
   207     TInt setLevel;
       
   208 
       
   209     error = eventSource->ExecuteTrap(SetTrebleL, control, &level, &setLevel);
       
   210     return (error < KErrNone) ? error : setLevel;
       
   211 }
       
   212 
       
   213 /*
       
   214  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   215  * Method:    _getNumberOfBands
       
   216  * Signature: (II)I
       
   217  */
       
   218 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getNumberOfBands(
       
   219     JNIEnv*,
       
   220     jclass,
       
   221     jint aEventSource,
       
   222     jint aControl)
       
   223 {
       
   224     CMMAEventSource* eventSource =
       
   225         JavaUnhand< CMMAEventSource >(aEventSource);
       
   226 
       
   227     CAMMSEqualizerControlGroup* control =
       
   228         static_cast<CAMMSEqualizerControlGroup*>(
       
   229             JavaUnhand< CAMMSControlGroup >(aControl));
       
   230 
       
   231     return control->NumberOfBands();
       
   232 }
       
   233 
       
   234 /*
       
   235  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   236  * Method:    _getMinBandLevel
       
   237  * Signature: (IILI)I
       
   238  */
       
   239 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getMinBandLevel(
       
   240     JNIEnv*,
       
   241     jclass,
       
   242     jint aEventSource,
       
   243     jint aControl)
       
   244 {
       
   245     CMMAEventSource* eventSource =
       
   246         JavaUnhand< CMMAEventSource >(aEventSource);
       
   247 
       
   248     CAMMSEqualizerControlGroup* control =
       
   249         static_cast<CAMMSEqualizerControlGroup*>(
       
   250             JavaUnhand< CAMMSControlGroup >(aControl));
       
   251 
       
   252 
       
   253     return control->MinBandLevel();
       
   254 }
       
   255 
       
   256 /*
       
   257  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   258  * Method:    _getBass
       
   259  * Signature: (II)I
       
   260  */
       
   261 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getBass(
       
   262     JNIEnv*, jclass, jint aEventSource, jint aControl)
       
   263 {
       
   264     CMMAEventSource* eventSource =
       
   265         JavaUnhand< CMMAEventSource >(aEventSource);
       
   266 
       
   267     CAMMSEqualizerControlGroup* control =
       
   268         static_cast<CAMMSEqualizerControlGroup*>(
       
   269             JavaUnhand< CAMMSControlGroup >(aControl));
       
   270 
       
   271     return control->Bass();
       
   272 }
       
   273 
       
   274 /*
       
   275  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   276  * Method:    _getMaxBandLevel
       
   277  * Signature: (IILI)I
       
   278  */
       
   279 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getMaxBandLevel(
       
   280     JNIEnv*, jclass, jint aEventSource, jint aControl)
       
   281 {
       
   282     CMMAEventSource* eventSource =
       
   283         JavaUnhand< CMMAEventSource >(aEventSource);
       
   284 
       
   285     CAMMSEqualizerControlGroup* control =
       
   286         static_cast<CAMMSEqualizerControlGroup*>(
       
   287             JavaUnhand< CAMMSControlGroup >(aControl));
       
   288 
       
   289     return control->MaxBandLevel();
       
   290 }
       
   291 
       
   292 /*
       
   293  * Class:     com_nokia_amms_control_audioeffect_EqualizerControl
       
   294  * Method:    _getBandLevel
       
   295  * Signature: (IIILI)I
       
   296  */
       
   297 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_audioeffect_EqualizerControl__1getBandLevel(
       
   298     JNIEnv* aJni,
       
   299     jclass,
       
   300     jint aEventSource,
       
   301     jint aControl,
       
   302     jint aBand,
       
   303     jintArray aLevel)
       
   304 {
       
   305     CMMAEventSource* eventSource =
       
   306         JavaUnhand< CMMAEventSource >(aEventSource);
       
   307 
       
   308     CAMMSEqualizerControlGroup* control =
       
   309         static_cast<CAMMSEqualizerControlGroup*>(
       
   310             JavaUnhand< CAMMSControlGroup >(aControl));
       
   311 
       
   312     TInt error;
       
   313     TInt level;
       
   314 
       
   315     error = eventSource->ExecuteTrap(
       
   316                 GetBandLevelL,
       
   317                 control,
       
   318                 (TInt) aBand,
       
   319                 &level);
       
   320 
       
   321     if (error == KErrNone)
       
   322     {
       
   323         // aLevel is an array of 1 element allocated at the java side
       
   324         aJni->SetIntArrayRegion(
       
   325             /*destination*/ aLevel,
       
   326             /*first*/ 0,
       
   327             /*count*/ 1,
       
   328             /*source*/ &level);
       
   329     }
       
   330     return error;
       
   331 }
       
   332 
       
   333 
       
   334 //  End of File