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: This class has JNI wrappers for CMMAPitchControl |
|
15 * |
|
16 */ |
|
17 |
|
18 //#include <jutils.h> |
|
19 //#include "mmapiutils.h" |
|
20 |
|
21 #include "com_nokia_microedition_media_control_PitchControl.h" |
|
22 #include "mmafunctionserver.h" |
|
23 #include "cmmamidipitchcontrol.h" |
|
24 #include <logger.h> |
|
25 |
|
26 static const int KPitchOffset = 1000000; |
|
27 |
|
28 /** |
|
29 * Local function which can be used to call CMMAPitchControl class methods. |
|
30 * Type of of the function pointer must be |
|
31 * TInt CMMAPitchControl::aFunc( TInt aData ) |
|
32 * |
|
33 * @param aPitchControl CMMAPitchControl pointer. |
|
34 * @param aFunc Pointer to the CMMAPitchControl method. |
|
35 * @param aData Parameter to passed to the aFunc method |
|
36 * @param aReturnValue The return value of the aFunc will |
|
37 * be assigned to this parameter. |
|
38 */ |
|
39 LOCAL_C void ReturnIntParamIntFuncL(CMMAMIDIPitchControl* aPitchControl, |
|
40 TInt(CMMAMIDIPitchControl::*aFuncL)(TInt), |
|
41 TInt aData, |
|
42 TInt* aReturnValue) |
|
43 { |
|
44 // call TInt CMMAPitchControl::aFunc( TInt aData ) method. |
|
45 *aReturnValue = (aPitchControl->*aFuncL)(aData); |
|
46 } |
|
47 |
|
48 /** |
|
49 * Local function which can be used to call CMMAPitchControl class methods. |
|
50 * Type of of the function pointer must be |
|
51 * TInt CMMAPitchControl::aFunc() |
|
52 * |
|
53 * @param aPitchControl CMMAPitchControl pointer. |
|
54 * @param aFunc Pointer to the CMMAPitchControl method. |
|
55 * @param aReturnValue The return value of the aFunc will |
|
56 * be assigned to this parameter. |
|
57 */ |
|
58 LOCAL_C void ReturnIntFuncL(CMMAMIDIPitchControl* aPitchControl, |
|
59 TInt(CMMAMIDIPitchControl::*aFuncL)(), |
|
60 TInt* aReturnValue) |
|
61 { |
|
62 // call TInt CMMAPitchControl::aFunc() method. |
|
63 *aReturnValue = (aPitchControl->*aFuncL)(); |
|
64 } |
|
65 |
|
66 // |
|
67 // JNI functions. Prototypes are generated and commented in Java class |
|
68 // com_nokia_microedition_media_control_PitchControl |
|
69 // |
|
70 |
|
71 /** |
|
72 * JNI function from com.nokia.microedition.media.control.PitchControl |
|
73 */ |
|
74 JNIEXPORT jint JNICALL |
|
75 Java_com_nokia_microedition_media_control_PitchControl__1setPitch |
|
76 (JNIEnv*, |
|
77 jobject, |
|
78 jint aControlHandle, |
|
79 jint aEventSourceHandle, |
|
80 jint aPitch) // parameter boundary is checked in Java side. |
|
81 { |
|
82 // Get pointer to native event source. |
|
83 MMAFunctionServer* eventSource = |
|
84 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
85 |
|
86 CMMAMIDIPitchControl* PitchControl = |
|
87 reinterpret_cast< CMMAMIDIPitchControl *>(aControlHandle); |
|
88 |
|
89 // Value returned from SetPitch method will be assigned to returnValue. |
|
90 TInt returnValue = 0; |
|
91 |
|
92 // Setting Pitch will not leave, it just assigns default |
|
93 // value to the returnValue variable. |
|
94 TInt error; |
|
95 error = eventSource->ExecuteTrap(&ReturnIntParamIntFuncL, |
|
96 PitchControl, |
|
97 &CMMAMIDIPitchControl::SetPitchL, |
|
98 aPitch, |
|
99 &returnValue); |
|
100 |
|
101 LOG1( EJavaMMAPI, EInfo, "PitchControl__1setPitch return value %d", returnValue); |
|
102 |
|
103 return (error == KErrNone) ? (returnValue+KPitchOffset) : error; |
|
104 } |
|
105 |
|
106 /** |
|
107 * JNI function from com.nokia.microedition.media.control.PitchControl |
|
108 */ |
|
109 JNIEXPORT jint JNICALL |
|
110 Java_com_nokia_microedition_media_control_PitchControl__1getMinPitch |
|
111 (JNIEnv*, |
|
112 jobject, |
|
113 jint aControlHandle, |
|
114 jint aEventSourceHandle) |
|
115 { |
|
116 // Get pointer to native event source. |
|
117 MMAFunctionServer* eventSource = |
|
118 reinterpret_cast< MMAFunctionServer *>(aEventSourceHandle); |
|
119 |
|
120 CMMAMIDIPitchControl* PitchControl = |
|
121 reinterpret_cast< CMMAMIDIPitchControl* >(aControlHandle); |
|
122 |
|
123 TInt returnValue = 0; |
|
124 |
|
125 // Get value or the default. |
|
126 TInt error; |
|
127 error = eventSource->ExecuteTrap(&ReturnIntFuncL, |
|
128 PitchControl, |
|
129 &CMMAMIDIPitchControl::MinPitchL, |
|
130 &returnValue); |
|
131 |
|
132 LOG1( EJavaMMAPI, EInfo, "PitchControl__1setPitch return value %d", returnValue); |
|
133 |
|
134 return (error == KErrNone) ? (returnValue+KPitchOffset) : error; |
|
135 } |
|
136 |
|
137 |
|
138 /** |
|
139 * JNI function from com.nokia.microedition.media.control.PitchControl |
|
140 */ |
|
141 JNIEXPORT jint JNICALL |
|
142 Java_com_nokia_microedition_media_control_PitchControl__1getMaxPitch |
|
143 (JNIEnv*, |
|
144 jobject, |
|
145 jint aControlHandle, |
|
146 jint aEventSourceHandle) |
|
147 { |
|
148 // Get pointer to native event source. |
|
149 MMAFunctionServer* eventSource = |
|
150 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
151 |
|
152 CMMAMIDIPitchControl* PitchControl = |
|
153 reinterpret_cast< CMMAMIDIPitchControl* >(aControlHandle); |
|
154 |
|
155 TInt returnValue = 0; |
|
156 TInt error; |
|
157 |
|
158 error = eventSource->ExecuteTrap(&ReturnIntFuncL, |
|
159 PitchControl, |
|
160 &CMMAMIDIPitchControl::MaxPitchL, |
|
161 &returnValue); |
|
162 LOG1( EJavaMMAPI, EInfo, "PitchControl__1getMaxRate return value %d", returnValue); |
|
163 |
|
164 return (error == KErrNone) ? (returnValue+KPitchOffset) : error; |
|
165 } |
|
166 |
|
167 /** |
|
168 * JNI function from com.nokia.microedition.media.control.PitchControl |
|
169 */ |
|
170 JNIEXPORT jint JNICALL |
|
171 Java_com_nokia_microedition_media_control_PitchControl__1getPitch |
|
172 (JNIEnv*, |
|
173 jobject, |
|
174 jint aControlHandle, |
|
175 jint aEventSourceHandle) |
|
176 { |
|
177 // Get pointer to native event source. |
|
178 MMAFunctionServer* eventSource = |
|
179 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
180 |
|
181 CMMAMIDIPitchControl* PitchControl = |
|
182 reinterpret_cast< CMMAMIDIPitchControl* >(aControlHandle); |
|
183 |
|
184 TInt returnValue = 0; |
|
185 TInt error; |
|
186 |
|
187 error = eventSource->ExecuteTrap(&ReturnIntFuncL, |
|
188 PitchControl, |
|
189 &CMMAMIDIPitchControl::PitchL, |
|
190 &returnValue); |
|
191 |
|
192 LOG1( EJavaMMAPI, EInfo, "PitchControl__1getPitch return value %d", returnValue); |
|
193 |
|
194 return (error == KErrNone) ? (returnValue+KPitchOffset) : error; |
|
195 } |
|
196 // END OF FILE |
|