|
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: Creates cammsaudiooutputcontrol. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <jutils.h> |
|
20 #include <jdebug.h> |
|
21 #include "com_nokia_mid_impl_media_AudioOutputControl.h" |
|
22 #include <cmmaeventsource.h> |
|
23 #include "cammsaudiooutputcontrol.h" |
|
24 |
|
25 /** |
|
26 * wrapper for CAMMSAudioOutputControl::GetPreference() |
|
27 */ |
|
28 static TInt GetPreference(CAMMSAudioOutputControl* aControl) |
|
29 { |
|
30 TInt val = aControl->GetAudioOutput(); |
|
31 return val; |
|
32 } |
|
33 |
|
34 /** |
|
35 * wrapper for CAMMSAudioOutputControl::SetPreferenceL() |
|
36 */ |
|
37 static TInt SetPreference(CAMMSAudioOutputControl* aControl, TInt aPreference) |
|
38 { |
|
39 return aControl->SetAudioOutput(aPreference); |
|
40 } |
|
41 |
|
42 /** |
|
43 * wrapper for CAMMSAudioOutputControl::GetCurrent() |
|
44 */ |
|
45 static void GetCurrent(CAMMSAudioOutputControl* aControl) |
|
46 { |
|
47 aControl->GetCurrentPreference(); |
|
48 } |
|
49 |
|
50 /** |
|
51 * wrapper for CAMMSAudioOutputControl::SetJavaAudioOutputObj() |
|
52 */ |
|
53 static void SetJavaAudioOutputObj(CAMMSAudioOutputControl* aControl,jobject obj) |
|
54 { |
|
55 aControl->SetJavaAudioOutputObject(obj); |
|
56 } |
|
57 |
|
58 /* |
|
59 * Class: Java_com_nokia_mj_impl_media_AudioOutputControl |
|
60 * Method: _getOutputMode |
|
61 * |
|
62 */ |
|
63 |
|
64 JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1getOutputMode( |
|
65 JNIEnv*, |
|
66 jclass, |
|
67 jint aEventSource, |
|
68 jint aControl) |
|
69 { |
|
70 CMMAEventSource* eventSource = |
|
71 JavaUnhand< CMMAEventSource >(aEventSource); |
|
72 CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( |
|
73 JavaUnhand< CAMMSControl >(aControl)); |
|
74 __ASSERT_DEBUG(control, User::Invariant()); |
|
75 return eventSource->Execute(GetPreference, control); |
|
76 } |
|
77 |
|
78 /* |
|
79 * Class: Java_com_nokia_mj_impl_media_AudioOutputControl |
|
80 * Method: _setOutputMode |
|
81 * |
|
82 */ |
|
83 JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1setOutputMode( |
|
84 JNIEnv*, |
|
85 jclass, |
|
86 jint aEventSource, |
|
87 jint aControl, |
|
88 jint aPreference) |
|
89 { |
|
90 CMMAEventSource* eventSource = |
|
91 JavaUnhand< CMMAEventSource >(aEventSource); |
|
92 |
|
93 CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( |
|
94 JavaUnhand< CAMMSControl >(aControl)); |
|
95 __ASSERT_DEBUG(control, User::Invariant()); |
|
96 TInt error = eventSource->Execute( |
|
97 &SetPreference, control, (TInt) aPreference); |
|
98 DEBUG_INT("AMMS::AudioOutputControl_JNI::setOutputMode = %d", error); |
|
99 return error; |
|
100 } |
|
101 |
|
102 |
|
103 /* |
|
104 * Class: Java_com_nokia_mj_impl_media_AudioOutputControl |
|
105 * Method: _getCurrent |
|
106 * |
|
107 */ |
|
108 |
|
109 JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1getCurrent( |
|
110 JNIEnv*, |
|
111 jclass, |
|
112 jint aEventSource, |
|
113 jint aControl) |
|
114 { |
|
115 CMMAEventSource* eventSource = |
|
116 JavaUnhand< CMMAEventSource >(aEventSource); |
|
117 |
|
118 CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( |
|
119 JavaUnhand< CAMMSControl >(aControl)); |
|
120 __ASSERT_DEBUG(control, User::Invariant()); |
|
121 TInt err = eventSource->ExecuteTrap(GetCurrent, control); |
|
122 DEBUG_INT("AMMS::AudioOutputControl_JNI::getCurrent = %d", err); |
|
123 return err; |
|
124 } |
|
125 |
|
126 |
|
127 /* |
|
128 * Class: com_nokia_mj_impl_media_AudioOutputControl |
|
129 * Method: _setAudioOutputObject |
|
130 * Signature: (IILjava/lang/Object;)I |
|
131 */ |
|
132 JNIEXPORT jint JNICALL Java_com_nokia_mid_impl_media_AudioOutputControl__1setAudioOutputObject |
|
133 (JNIEnv *jni, jclass, jint aEventSource, jint aControl, jobject audioOutputObj) |
|
134 { |
|
135 CMMAEventSource* eventSource = |
|
136 JavaUnhand< CMMAEventSource >(aEventSource); |
|
137 CAMMSAudioOutputControl* control = static_cast< CAMMSAudioOutputControl* >( |
|
138 JavaUnhand< CAMMSControl >(aControl)); |
|
139 __ASSERT_DEBUG(control, User::Invariant()); |
|
140 jobject obj = jni->NewWeakGlobalRef(audioOutputObj); |
|
141 TInt err = eventSource->ExecuteTrap(SetJavaAudioOutputObj,control ,obj); |
|
142 DEBUG_INT("AMMS::AudioOutputControl_JNI::setAudioOutputObject = %d", err); |
|
143 return err; |
|
144 } |
|
145 |
|
146 |
|
147 |
|
148 // End of File |