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