Glenn Kasten | b3db213 | 2012-01-19 08:59:58 -0800 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** |
| 3 | ** Copyright 2006, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 18 | //#define LOG_NDEBUG 0 |
| 19 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 20 | #define LOG_TAG "AudioSystem-JNI" |
Glenn Kasten | c81d31c | 2012-03-13 14:46:23 -0700 | [diff] [blame] | 21 | #include <utils/Log.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | |
Glenn Kasten | c81d31c | 2012-03-13 14:46:23 -0700 | [diff] [blame] | 23 | #include <jni.h> |
| 24 | #include <JNIHelp.h> |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 25 | #include "core_jni_helpers.h" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
| 27 | #include <media/AudioSystem.h> |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 28 | #include <media/AudioPolicy.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
Dima Zavin | 34bb419 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 30 | #include <system/audio.h> |
Dima Zavin | 290029d | 2011-06-13 18:16:26 -0700 | [diff] [blame] | 31 | #include <system/audio_policy.h> |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 32 | #include "android_media_AudioFormat.h" |
| 33 | #include "android_media_AudioErrors.h" |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 34 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | // ---------------------------------------------------------------------------- |
| 36 | |
| 37 | using namespace android; |
| 38 | |
Glenn Kasten | ed0079d | 2011-04-04 10:50:50 -0700 | [diff] [blame] | 39 | static const char* const kClassPathName = "android/media/AudioSystem"; |
| 40 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 41 | static jclass gArrayListClass; |
| 42 | static struct { |
| 43 | jmethodID add; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 44 | jmethodID toArray; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 45 | } gArrayListMethods; |
| 46 | |
| 47 | static jclass gAudioHandleClass; |
| 48 | static jmethodID gAudioHandleCstor; |
| 49 | static struct { |
| 50 | jfieldID mId; |
| 51 | } gAudioHandleFields; |
| 52 | |
| 53 | static jclass gAudioPortClass; |
| 54 | static jmethodID gAudioPortCstor; |
| 55 | static struct { |
| 56 | jfieldID mHandle; |
| 57 | jfieldID mRole; |
| 58 | jfieldID mGains; |
| 59 | jfieldID mActiveConfig; |
| 60 | // other fields unused by JNI |
| 61 | } gAudioPortFields; |
| 62 | |
| 63 | static jclass gAudioPortConfigClass; |
| 64 | static jmethodID gAudioPortConfigCstor; |
| 65 | static struct { |
| 66 | jfieldID mPort; |
| 67 | jfieldID mSamplingRate; |
| 68 | jfieldID mChannelMask; |
| 69 | jfieldID mFormat; |
| 70 | jfieldID mGain; |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 71 | jfieldID mConfigMask; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 72 | } gAudioPortConfigFields; |
| 73 | |
| 74 | static jclass gAudioDevicePortClass; |
| 75 | static jmethodID gAudioDevicePortCstor; |
| 76 | |
| 77 | static jclass gAudioDevicePortConfigClass; |
| 78 | static jmethodID gAudioDevicePortConfigCstor; |
| 79 | |
| 80 | static jclass gAudioMixPortClass; |
| 81 | static jmethodID gAudioMixPortCstor; |
| 82 | |
| 83 | static jclass gAudioMixPortConfigClass; |
| 84 | static jmethodID gAudioMixPortConfigCstor; |
| 85 | |
| 86 | static jclass gAudioGainClass; |
| 87 | static jmethodID gAudioGainCstor; |
| 88 | |
| 89 | static jclass gAudioGainConfigClass; |
| 90 | static jmethodID gAudioGainConfigCstor; |
| 91 | static struct { |
| 92 | jfieldID mIndex; |
| 93 | jfieldID mMode; |
| 94 | jfieldID mChannelMask; |
| 95 | jfieldID mValues; |
| 96 | jfieldID mRampDurationMs; |
| 97 | // other fields unused by JNI |
| 98 | } gAudioGainConfigFields; |
| 99 | |
| 100 | static jclass gAudioPatchClass; |
| 101 | static jmethodID gAudioPatchCstor; |
| 102 | static struct { |
| 103 | jfieldID mHandle; |
| 104 | // other fields unused by JNI |
| 105 | } gAudioPatchFields; |
| 106 | |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 107 | static jclass gAudioMixClass; |
| 108 | static struct { |
| 109 | jfieldID mRule; |
| 110 | jfieldID mFormat; |
| 111 | jfieldID mRouteFlags; |
Jean-Michel Trivi | 4ad3988 | 2016-03-14 18:46:41 -0700 | [diff] [blame^] | 112 | jfieldID mDeviceType; |
| 113 | jfieldID mDeviceAddress; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 114 | jfieldID mMixType; |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 115 | jfieldID mCallbackFlags; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 116 | } gAudioMixFields; |
| 117 | |
| 118 | static jclass gAudioFormatClass; |
| 119 | static struct { |
| 120 | jfieldID mEncoding; |
| 121 | jfieldID mSampleRate; |
| 122 | jfieldID mChannelMask; |
| 123 | // other fields unused by JNI |
| 124 | } gAudioFormatFields; |
| 125 | |
| 126 | static jclass gAudioMixingRuleClass; |
| 127 | static struct { |
| 128 | jfieldID mCriteria; |
| 129 | // other fields unused by JNI |
| 130 | } gAudioMixingRuleFields; |
| 131 | |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 132 | static jclass gAudioMixMatchCriterionClass; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 133 | static struct { |
| 134 | jfieldID mAttr; |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 135 | jfieldID mIntProp; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 136 | jfieldID mRule; |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 137 | } gAudioMixMatchCriterionFields; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 138 | |
| 139 | static jclass gAudioAttributesClass; |
| 140 | static struct { |
| 141 | jfieldID mUsage; |
| 142 | jfieldID mSource; |
| 143 | } gAudioAttributesFields; |
| 144 | |
| 145 | |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 146 | static const char* const kEventHandlerClassPathName = |
| 147 | "android/media/AudioPortEventHandler"; |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 148 | static struct { |
| 149 | jfieldID mJniCallback; |
| 150 | } gEventHandlerFields; |
| 151 | static struct { |
| 152 | jmethodID postEventFromNative; |
| 153 | } gAudioPortEventHandlerMethods; |
| 154 | |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 155 | static struct { |
| 156 | jmethodID postDynPolicyEventFromNative; |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 157 | jmethodID postRecordConfigEventFromNative; |
| 158 | } gAudioPolicyEventHandlerMethods; |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 159 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 160 | static Mutex gLock; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 161 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | enum AudioError { |
| 163 | kAudioStatusOk = 0, |
| 164 | kAudioStatusError = 1, |
| 165 | kAudioStatusMediaServerDied = 100 |
| 166 | }; |
| 167 | |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 168 | enum { |
| 169 | AUDIOPORT_EVENT_PORT_LIST_UPDATED = 1, |
| 170 | AUDIOPORT_EVENT_PATCH_LIST_UPDATED = 2, |
| 171 | AUDIOPORT_EVENT_SERVICE_DIED = 3, |
| 172 | }; |
| 173 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 174 | #define MAX_PORT_GENERATION_SYNC_ATTEMPTS 5 |
| 175 | |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 176 | // ---------------------------------------------------------------------------- |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 177 | // ref-counted object for audio port callbacks |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 178 | class JNIAudioPortCallback: public AudioSystem::AudioPortCallback |
| 179 | { |
| 180 | public: |
| 181 | JNIAudioPortCallback(JNIEnv* env, jobject thiz, jobject weak_thiz); |
| 182 | ~JNIAudioPortCallback(); |
| 183 | |
| 184 | virtual void onAudioPortListUpdate(); |
| 185 | virtual void onAudioPatchListUpdate(); |
| 186 | virtual void onServiceDied(); |
| 187 | |
| 188 | private: |
| 189 | void sendEvent(int event); |
| 190 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 191 | jclass mClass; // Reference to AudioPortEventHandler class |
| 192 | jobject mObject; // Weak ref to AudioPortEventHandler Java object to call on |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | JNIAudioPortCallback::JNIAudioPortCallback(JNIEnv* env, jobject thiz, jobject weak_thiz) |
| 196 | { |
| 197 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 198 | // Hold onto the AudioPortEventHandler class for use in calling the static method |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 199 | // that posts events to the application thread. |
| 200 | jclass clazz = env->GetObjectClass(thiz); |
| 201 | if (clazz == NULL) { |
| 202 | ALOGE("Can't find class %s", kEventHandlerClassPathName); |
| 203 | return; |
| 204 | } |
| 205 | mClass = (jclass)env->NewGlobalRef(clazz); |
| 206 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 207 | // We use a weak reference so the AudioPortEventHandler object can be garbage collected. |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 208 | // The reference is only used as a proxy for callbacks. |
| 209 | mObject = env->NewGlobalRef(weak_thiz); |
| 210 | } |
| 211 | |
| 212 | JNIAudioPortCallback::~JNIAudioPortCallback() |
| 213 | { |
| 214 | // remove global references |
| 215 | JNIEnv *env = AndroidRuntime::getJNIEnv(); |
Eric Laurent | 449c588 | 2014-11-12 11:07:48 -0800 | [diff] [blame] | 216 | if (env == NULL) { |
| 217 | return; |
| 218 | } |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 219 | env->DeleteGlobalRef(mObject); |
| 220 | env->DeleteGlobalRef(mClass); |
| 221 | } |
| 222 | |
| 223 | void JNIAudioPortCallback::sendEvent(int event) |
| 224 | { |
| 225 | JNIEnv *env = AndroidRuntime::getJNIEnv(); |
Eric Laurent | 449c588 | 2014-11-12 11:07:48 -0800 | [diff] [blame] | 226 | if (env == NULL) { |
| 227 | return; |
| 228 | } |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 229 | env->CallStaticVoidMethod(mClass, gAudioPortEventHandlerMethods.postEventFromNative, mObject, |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 230 | event, 0, 0, NULL); |
| 231 | if (env->ExceptionCheck()) { |
| 232 | ALOGW("An exception occurred while notifying an event."); |
| 233 | env->ExceptionClear(); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | void JNIAudioPortCallback::onAudioPortListUpdate() |
| 238 | { |
| 239 | sendEvent(AUDIOPORT_EVENT_PORT_LIST_UPDATED); |
| 240 | } |
| 241 | |
| 242 | void JNIAudioPortCallback::onAudioPatchListUpdate() |
| 243 | { |
| 244 | sendEvent(AUDIOPORT_EVENT_PATCH_LIST_UPDATED); |
| 245 | } |
| 246 | |
| 247 | void JNIAudioPortCallback::onServiceDied() |
| 248 | { |
| 249 | sendEvent(AUDIOPORT_EVENT_SERVICE_DIED); |
| 250 | } |
| 251 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 252 | static sp<JNIAudioPortCallback> setJniCallback(JNIEnv* env, |
| 253 | jobject thiz, |
| 254 | const sp<JNIAudioPortCallback>& callback) |
| 255 | { |
| 256 | Mutex::Autolock l(gLock); |
| 257 | sp<JNIAudioPortCallback> old = |
| 258 | (JNIAudioPortCallback*)env->GetLongField(thiz, gEventHandlerFields.mJniCallback); |
| 259 | if (callback.get()) { |
| 260 | callback->incStrong((void*)setJniCallback); |
| 261 | } |
| 262 | if (old != 0) { |
| 263 | old->decStrong((void*)setJniCallback); |
| 264 | } |
| 265 | env->SetLongField(thiz, gEventHandlerFields.mJniCallback, (jlong)callback.get()); |
| 266 | return old; |
| 267 | } |
| 268 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 269 | static int check_AudioSystem_Command(status_t status) |
| 270 | { |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 271 | switch (status) { |
| 272 | case DEAD_OBJECT: |
| 273 | return kAudioStatusMediaServerDied; |
| 274 | case NO_ERROR: |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | return kAudioStatusOk; |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 276 | default: |
| 277 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 278 | } |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 279 | return kAudioStatusError; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 282 | static jint |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 283 | android_media_AudioSystem_muteMicrophone(JNIEnv *env, jobject thiz, jboolean on) |
| 284 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 285 | return (jint) check_AudioSystem_Command(AudioSystem::muteMicrophone(on)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static jboolean |
| 289 | android_media_AudioSystem_isMicrophoneMuted(JNIEnv *env, jobject thiz) |
| 290 | { |
| 291 | bool state = false; |
| 292 | AudioSystem::isMicrophoneMuted(&state); |
| 293 | return state; |
| 294 | } |
| 295 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 296 | static jboolean |
Eric Laurent | 25101b0 | 2011-02-02 09:33:30 -0800 | [diff] [blame] | 297 | android_media_AudioSystem_isStreamActive(JNIEnv *env, jobject thiz, jint stream, jint inPastMs) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | { |
| 299 | bool state = false; |
Glenn Kasten | bc1d77b | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 300 | AudioSystem::isStreamActive((audio_stream_type_t) stream, &state, inPastMs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 301 | return state; |
| 302 | } |
| 303 | |
Jean-Michel Trivi | d677054 | 2012-10-10 12:03:41 -0700 | [diff] [blame] | 304 | static jboolean |
Jean-Michel Trivi | 679d504 | 2013-02-04 16:24:09 -0800 | [diff] [blame] | 305 | android_media_AudioSystem_isStreamActiveRemotely(JNIEnv *env, jobject thiz, jint stream, |
| 306 | jint inPastMs) |
| 307 | { |
| 308 | bool state = false; |
| 309 | AudioSystem::isStreamActiveRemotely((audio_stream_type_t) stream, &state, inPastMs); |
| 310 | return state; |
| 311 | } |
| 312 | |
| 313 | static jboolean |
Jean-Michel Trivi | d677054 | 2012-10-10 12:03:41 -0700 | [diff] [blame] | 314 | android_media_AudioSystem_isSourceActive(JNIEnv *env, jobject thiz, jint source) |
| 315 | { |
| 316 | bool state = false; |
| 317 | AudioSystem::isSourceActive((audio_source_t) source, &state); |
| 318 | return state; |
| 319 | } |
| 320 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 321 | static jint |
Jean-Michel Trivi | 8a21f5d | 2014-06-05 15:03:52 -0700 | [diff] [blame] | 322 | android_media_AudioSystem_newAudioSessionId(JNIEnv *env, jobject thiz) |
| 323 | { |
Glenn Kasten | 211d905 | 2016-02-26 16:22:40 -0800 | [diff] [blame] | 324 | return AudioSystem::newAudioUniqueId(AUDIO_UNIQUE_ID_USE_SESSION); |
Jean-Michel Trivi | 8a21f5d | 2014-06-05 15:03:52 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | static jint |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 328 | android_media_AudioSystem_setParameters(JNIEnv *env, jobject thiz, jstring keyValuePairs) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | { |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 330 | const jchar* c_keyValuePairs = env->GetStringCritical(keyValuePairs, 0); |
| 331 | String8 c_keyValuePairs8; |
| 332 | if (keyValuePairs) { |
Dan Albert | 6698749 | 2014-11-20 11:41:21 -0800 | [diff] [blame] | 333 | c_keyValuePairs8 = String8( |
| 334 | reinterpret_cast<const char16_t*>(c_keyValuePairs), |
| 335 | env->GetStringLength(keyValuePairs)); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 336 | env->ReleaseStringCritical(keyValuePairs, c_keyValuePairs); |
| 337 | } |
Glenn Kasten | c94752a | 2013-12-19 12:40:33 -0800 | [diff] [blame] | 338 | int status = check_AudioSystem_Command(AudioSystem::setParameters(c_keyValuePairs8)); |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 339 | return (jint) status; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | static jstring |
| 343 | android_media_AudioSystem_getParameters(JNIEnv *env, jobject thiz, jstring keys) |
| 344 | { |
| 345 | const jchar* c_keys = env->GetStringCritical(keys, 0); |
| 346 | String8 c_keys8; |
| 347 | if (keys) { |
Dan Albert | 6698749 | 2014-11-20 11:41:21 -0800 | [diff] [blame] | 348 | c_keys8 = String8(reinterpret_cast<const char16_t*>(c_keys), |
| 349 | env->GetStringLength(keys)); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 350 | env->ReleaseStringCritical(keys, c_keys); |
| 351 | } |
Glenn Kasten | c94752a | 2013-12-19 12:40:33 -0800 | [diff] [blame] | 352 | return env->NewStringUTF(AudioSystem::getParameters(c_keys8).string()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | } |
| 354 | |
Glenn Kasten | ed0079d | 2011-04-04 10:50:50 -0700 | [diff] [blame] | 355 | static void |
| 356 | android_media_AudioSystem_error_callback(status_t err) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 357 | { |
Eric Laurent | 539719a | 2013-07-18 14:08:00 -0700 | [diff] [blame] | 358 | JNIEnv *env = AndroidRuntime::getJNIEnv(); |
Eric Laurent | 0e7a4d9 | 2010-10-15 12:33:16 -0700 | [diff] [blame] | 359 | if (env == NULL) { |
| 360 | return; |
| 361 | } |
| 362 | |
Glenn Kasten | ed0079d | 2011-04-04 10:50:50 -0700 | [diff] [blame] | 363 | jclass clazz = env->FindClass(kClassPathName); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 364 | |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 365 | env->CallStaticVoidMethod(clazz, env->GetStaticMethodID(clazz, |
| 366 | "errorCallbackFromNative","(I)V"), |
| 367 | check_AudioSystem_Command(err)); |
Viorel Suman | b637ccf | 2014-05-30 16:51:07 +0300 | [diff] [blame] | 368 | |
| 369 | env->DeleteLocalRef(clazz); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | } |
| 371 | |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 372 | static void |
| 373 | android_media_AudioSystem_dyn_policy_callback(int event, String8 regId, int val) |
| 374 | { |
| 375 | JNIEnv *env = AndroidRuntime::getJNIEnv(); |
| 376 | if (env == NULL) { |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | jclass clazz = env->FindClass(kClassPathName); |
| 381 | const char* zechars = regId.string(); |
| 382 | jstring zestring = env->NewStringUTF(zechars); |
| 383 | |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 384 | env->CallStaticVoidMethod(clazz, gAudioPolicyEventHandlerMethods.postDynPolicyEventFromNative, |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 385 | event, zestring, val); |
| 386 | |
| 387 | env->ReleaseStringUTFChars(zestring, zechars); |
| 388 | env->DeleteLocalRef(clazz); |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 389 | } |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 390 | |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 391 | static void |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 392 | android_media_AudioSystem_recording_callback(int event, int session, int source, |
Jean-Michel Trivi | 8ab7280 | 2016-02-25 16:31:45 -0800 | [diff] [blame] | 393 | const audio_config_base_t *clientConfig, const audio_config_base_t *deviceConfig, |
| 394 | audio_patch_handle_t patchHandle) |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 395 | { |
| 396 | JNIEnv *env = AndroidRuntime::getJNIEnv(); |
| 397 | if (env == NULL) { |
| 398 | return; |
| 399 | } |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 400 | if (clientConfig == NULL || deviceConfig == NULL) { |
| 401 | ALOGE("Unexpected null client/device configurations in recording callback"); |
| 402 | return; |
| 403 | } |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 404 | |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 405 | // create an array for 2*3 integers to store the record configurations (client + device) |
Jean-Michel Trivi | 8ab7280 | 2016-02-25 16:31:45 -0800 | [diff] [blame] | 406 | // plus 1 integer for the patch handle |
| 407 | const int REC_PARAM_SIZE = 7; |
| 408 | jintArray recParamArray = env->NewIntArray(REC_PARAM_SIZE); |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 409 | if (recParamArray == NULL) { |
| 410 | ALOGE("recording callback: Couldn't allocate int array for configuration data"); |
| 411 | return; |
| 412 | } |
Jean-Michel Trivi | 8ab7280 | 2016-02-25 16:31:45 -0800 | [diff] [blame] | 413 | jint recParamData[REC_PARAM_SIZE]; |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 414 | recParamData[0] = (jint) audioFormatFromNative(clientConfig->format); |
| 415 | // FIXME this doesn't support index-based masks |
| 416 | recParamData[1] = (jint) inChannelMaskFromNative(clientConfig->channel_mask); |
| 417 | recParamData[2] = (jint) clientConfig->sample_rate; |
| 418 | recParamData[3] = (jint) audioFormatFromNative(deviceConfig->format); |
| 419 | // FIXME this doesn't support index-based masks |
| 420 | recParamData[4] = (jint) inChannelMaskFromNative(deviceConfig->channel_mask); |
| 421 | recParamData[5] = (jint) deviceConfig->sample_rate; |
Jean-Michel Trivi | 8ab7280 | 2016-02-25 16:31:45 -0800 | [diff] [blame] | 422 | recParamData[6] = (jint) patchHandle; |
| 423 | env->SetIntArrayRegion(recParamArray, 0, REC_PARAM_SIZE, recParamData); |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 424 | |
| 425 | // callback into java |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 426 | jclass clazz = env->FindClass(kClassPathName); |
| 427 | env->CallStaticVoidMethod(clazz, |
| 428 | gAudioPolicyEventHandlerMethods.postRecordConfigEventFromNative, |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 429 | event, session, source, recParamArray); |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 430 | env->DeleteLocalRef(clazz); |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 431 | |
| 432 | env->DeleteLocalRef(recParamArray); |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 435 | static jint |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 436 | android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address, jstring device_name) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 437 | { |
| 438 | const char *c_address = env->GetStringUTFChars(device_address, NULL); |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 439 | const char *c_name = env->GetStringUTFChars(device_name, NULL); |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 440 | int status = check_AudioSystem_Command(AudioSystem::setDeviceConnectionState(static_cast <audio_devices_t>(device), |
| 441 | static_cast <audio_policy_dev_state_t>(state), |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 442 | c_address, c_name)); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 443 | env->ReleaseStringUTFChars(device_address, c_address); |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 444 | env->ReleaseStringUTFChars(device_name, c_name); |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 445 | return (jint) status; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 446 | } |
| 447 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 448 | static jint |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 449 | android_media_AudioSystem_getDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jstring device_address) |
| 450 | { |
| 451 | const char *c_address = env->GetStringUTFChars(device_address, NULL); |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 452 | int state = static_cast <int>(AudioSystem::getDeviceConnectionState(static_cast <audio_devices_t>(device), |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 453 | c_address)); |
| 454 | env->ReleaseStringUTFChars(device_address, c_address); |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 455 | return (jint) state; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 458 | static jint |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 459 | android_media_AudioSystem_setPhoneState(JNIEnv *env, jobject thiz, jint state) |
| 460 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 461 | return (jint) check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state)); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 464 | static jint |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 465 | android_media_AudioSystem_setForceUse(JNIEnv *env, jobject thiz, jint usage, jint config) |
| 466 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 467 | return (jint) check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage), |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 468 | static_cast <audio_policy_forced_cfg_t>(config))); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 471 | static jint |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 472 | android_media_AudioSystem_getForceUse(JNIEnv *env, jobject thiz, jint usage) |
| 473 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 474 | return static_cast <jint>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage))); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 475 | } |
| 476 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 477 | static jint |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 478 | android_media_AudioSystem_initStreamVolume(JNIEnv *env, jobject thiz, jint stream, jint indexMin, jint indexMax) |
| 479 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 480 | return (jint) check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream), |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 481 | indexMin, |
| 482 | indexMax)); |
| 483 | } |
| 484 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 485 | static jint |
Eric Laurent | 9bc8358d | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 486 | android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, |
| 487 | jobject thiz, |
| 488 | jint stream, |
| 489 | jint index, |
| 490 | jint device) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 491 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 492 | return (jint) check_AudioSystem_Command( |
Eric Laurent | 9bc8358d | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 493 | AudioSystem::setStreamVolumeIndex(static_cast <audio_stream_type_t>(stream), |
| 494 | index, |
| 495 | (audio_devices_t)device)); |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 496 | } |
| 497 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 498 | static jint |
Eric Laurent | 9bc8358d | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 499 | android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, |
| 500 | jobject thiz, |
| 501 | jint stream, |
| 502 | jint device) |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 503 | { |
| 504 | int index; |
Eric Laurent | 9bc8358d | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 505 | if (AudioSystem::getStreamVolumeIndex(static_cast <audio_stream_type_t>(stream), |
| 506 | &index, |
| 507 | (audio_devices_t)device) |
| 508 | != NO_ERROR) { |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 509 | index = -1; |
| 510 | } |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 511 | return (jint) index; |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 514 | static jint |
Mike Lockwood | cbdb49d | 2011-10-20 12:54:05 -0400 | [diff] [blame] | 515 | android_media_AudioSystem_setMasterVolume(JNIEnv *env, jobject thiz, jfloat value) |
| 516 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 517 | return (jint) check_AudioSystem_Command(AudioSystem::setMasterVolume(value)); |
Mike Lockwood | cbdb49d | 2011-10-20 12:54:05 -0400 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | static jfloat |
| 521 | android_media_AudioSystem_getMasterVolume(JNIEnv *env, jobject thiz) |
| 522 | { |
| 523 | float value; |
| 524 | if (AudioSystem::getMasterVolume(&value) != NO_ERROR) { |
| 525 | value = -1.0; |
| 526 | } |
| 527 | return value; |
| 528 | } |
| 529 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 530 | static jint |
Mike Lockwood | cbdb49d | 2011-10-20 12:54:05 -0400 | [diff] [blame] | 531 | android_media_AudioSystem_setMasterMute(JNIEnv *env, jobject thiz, jboolean mute) |
| 532 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 533 | return (jint) check_AudioSystem_Command(AudioSystem::setMasterMute(mute)); |
Mike Lockwood | cbdb49d | 2011-10-20 12:54:05 -0400 | [diff] [blame] | 534 | } |
| 535 | |
Vladimir Marko | c1bcdbb | 2014-10-29 20:34:15 +0000 | [diff] [blame] | 536 | static jboolean |
Mike Lockwood | cbdb49d | 2011-10-20 12:54:05 -0400 | [diff] [blame] | 537 | android_media_AudioSystem_getMasterMute(JNIEnv *env, jobject thiz) |
| 538 | { |
| 539 | bool mute; |
| 540 | if (AudioSystem::getMasterMute(&mute) != NO_ERROR) { |
| 541 | mute = false; |
| 542 | } |
| 543 | return mute; |
| 544 | } |
| 545 | |
Glenn Kasten | 8b4b97a | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 546 | static jint |
Andy Hung | f04b84d | 2015-12-18 17:33:27 -0800 | [diff] [blame] | 547 | android_media_AudioSystem_setMasterMono(JNIEnv *env, jobject thiz, jboolean mono) |
| 548 | { |
| 549 | return (jint) check_AudioSystem_Command(AudioSystem::setMasterMono(mono)); |
| 550 | } |
| 551 | |
| 552 | static jboolean |
| 553 | android_media_AudioSystem_getMasterMono(JNIEnv *env, jobject thiz) |
| 554 | { |
| 555 | bool mono; |
| 556 | if (AudioSystem::getMasterMono(&mono) != NO_ERROR) { |
| 557 | mono = false; |
| 558 | } |
| 559 | return mono; |
| 560 | } |
| 561 | |
| 562 | static jint |
Glenn Kasten | 8b4b97a | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 563 | android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint stream) |
| 564 | { |
Dima Zavin | 24fc2fb | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 565 | return (jint) AudioSystem::getDevicesForStream(static_cast <audio_stream_type_t>(stream)); |
Glenn Kasten | 8b4b97a | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 566 | } |
| 567 | |
Glenn Kasten | c6c4365 | 2012-09-24 17:32:30 -0700 | [diff] [blame] | 568 | static jint |
| 569 | android_media_AudioSystem_getPrimaryOutputSamplingRate(JNIEnv *env, jobject clazz) |
| 570 | { |
| 571 | return (jint) AudioSystem::getPrimaryOutputSamplingRate(); |
| 572 | } |
| 573 | |
| 574 | static jint |
| 575 | android_media_AudioSystem_getPrimaryOutputFrameCount(JNIEnv *env, jobject clazz) |
| 576 | { |
| 577 | return (jint) AudioSystem::getPrimaryOutputFrameCount(); |
| 578 | } |
| 579 | |
Oliver Woodman | 61dcdf3 | 2013-06-26 12:43:36 +0100 | [diff] [blame] | 580 | static jint |
| 581 | android_media_AudioSystem_getOutputLatency(JNIEnv *env, jobject clazz, jint stream) |
| 582 | { |
| 583 | uint32_t afLatency; |
| 584 | if (AudioSystem::getOutputLatency(&afLatency, static_cast <audio_stream_type_t>(stream)) |
| 585 | != NO_ERROR) { |
| 586 | afLatency = -1; |
| 587 | } |
| 588 | return (jint) afLatency; |
| 589 | } |
| 590 | |
Glenn Kasten | fd116ad | 2013-07-12 17:10:39 -0700 | [diff] [blame] | 591 | static jint |
| 592 | android_media_AudioSystem_setLowRamDevice(JNIEnv *env, jobject clazz, jboolean isLowRamDevice) |
| 593 | { |
| 594 | return (jint) AudioSystem::setLowRamDevice((bool) isLowRamDevice); |
| 595 | } |
| 596 | |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 597 | static jint |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 598 | android_media_AudioSystem_checkAudioFlinger(JNIEnv *env, jobject clazz) |
| 599 | { |
Ashok Bhat | 075e9a1 | 2014-01-06 13:45:09 +0000 | [diff] [blame] | 600 | return (jint) check_AudioSystem_Command(AudioSystem::checkAudioFlinger()); |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 603 | |
| 604 | static bool useInChannelMask(audio_port_type_t type, audio_port_role_t role) |
| 605 | { |
| 606 | return ((type == AUDIO_PORT_TYPE_DEVICE) && (role == AUDIO_PORT_ROLE_SOURCE)) || |
| 607 | ((type == AUDIO_PORT_TYPE_MIX) && (role == AUDIO_PORT_ROLE_SINK)); |
| 608 | } |
| 609 | |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 610 | static void convertAudioGainConfigToNative(JNIEnv *env, |
| 611 | struct audio_gain_config *nAudioGainConfig, |
| 612 | const jobject jAudioGainConfig, |
| 613 | bool useInMask) |
| 614 | { |
| 615 | nAudioGainConfig->index = env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mIndex); |
| 616 | nAudioGainConfig->mode = env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mMode); |
| 617 | ALOGV("convertAudioGainConfigToNative got gain index %d", nAudioGainConfig->index); |
| 618 | jint jMask = env->GetIntField(jAudioGainConfig, gAudioGainConfigFields.mChannelMask); |
| 619 | audio_channel_mask_t nMask; |
| 620 | if (useInMask) { |
| 621 | nMask = inChannelMaskToNative(jMask); |
| 622 | ALOGV("convertAudioGainConfigToNative IN mask java %x native %x", jMask, nMask); |
| 623 | } else { |
| 624 | nMask = outChannelMaskToNative(jMask); |
| 625 | ALOGV("convertAudioGainConfigToNative OUT mask java %x native %x", jMask, nMask); |
| 626 | } |
| 627 | nAudioGainConfig->channel_mask = nMask; |
| 628 | nAudioGainConfig->ramp_duration_ms = env->GetIntField(jAudioGainConfig, |
| 629 | gAudioGainConfigFields.mRampDurationMs); |
| 630 | jintArray jValues = (jintArray)env->GetObjectField(jAudioGainConfig, |
| 631 | gAudioGainConfigFields.mValues); |
| 632 | int *nValues = env->GetIntArrayElements(jValues, NULL); |
| 633 | size_t size = env->GetArrayLength(jValues); |
| 634 | memcpy(nAudioGainConfig->values, nValues, size * sizeof(int)); |
| 635 | env->DeleteLocalRef(jValues); |
| 636 | } |
| 637 | |
| 638 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 639 | static jint convertAudioPortConfigToNative(JNIEnv *env, |
| 640 | struct audio_port_config *nAudioPortConfig, |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 641 | const jobject jAudioPortConfig, |
| 642 | bool useConfigMask) |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 643 | { |
| 644 | jobject jAudioPort = env->GetObjectField(jAudioPortConfig, gAudioPortConfigFields.mPort); |
| 645 | jobject jHandle = env->GetObjectField(jAudioPort, gAudioPortFields.mHandle); |
| 646 | nAudioPortConfig->id = env->GetIntField(jHandle, gAudioHandleFields.mId); |
| 647 | nAudioPortConfig->role = (audio_port_role_t)env->GetIntField(jAudioPort, |
| 648 | gAudioPortFields.mRole); |
| 649 | if (env->IsInstanceOf(jAudioPort, gAudioDevicePortClass)) { |
| 650 | nAudioPortConfig->type = AUDIO_PORT_TYPE_DEVICE; |
| 651 | } else if (env->IsInstanceOf(jAudioPort, gAudioMixPortClass)) { |
| 652 | nAudioPortConfig->type = AUDIO_PORT_TYPE_MIX; |
| 653 | } else { |
| 654 | env->DeleteLocalRef(jAudioPort); |
| 655 | env->DeleteLocalRef(jHandle); |
| 656 | return (jint)AUDIO_JAVA_ERROR; |
| 657 | } |
| 658 | ALOGV("convertAudioPortConfigToNative handle %d role %d type %d", |
| 659 | nAudioPortConfig->id, nAudioPortConfig->role, nAudioPortConfig->type); |
| 660 | |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 661 | unsigned int configMask = 0; |
| 662 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 663 | nAudioPortConfig->sample_rate = env->GetIntField(jAudioPortConfig, |
| 664 | gAudioPortConfigFields.mSamplingRate); |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 665 | if (nAudioPortConfig->sample_rate != 0) { |
| 666 | configMask |= AUDIO_PORT_CONFIG_SAMPLE_RATE; |
| 667 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 668 | |
| 669 | bool useInMask = useInChannelMask(nAudioPortConfig->type, nAudioPortConfig->role); |
| 670 | audio_channel_mask_t nMask; |
| 671 | jint jMask = env->GetIntField(jAudioPortConfig, |
| 672 | gAudioPortConfigFields.mChannelMask); |
| 673 | if (useInMask) { |
| 674 | nMask = inChannelMaskToNative(jMask); |
| 675 | ALOGV("convertAudioPortConfigToNative IN mask java %x native %x", jMask, nMask); |
| 676 | } else { |
| 677 | nMask = outChannelMaskToNative(jMask); |
| 678 | ALOGV("convertAudioPortConfigToNative OUT mask java %x native %x", jMask, nMask); |
| 679 | } |
| 680 | nAudioPortConfig->channel_mask = nMask; |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 681 | if (nAudioPortConfig->channel_mask != AUDIO_CHANNEL_NONE) { |
| 682 | configMask |= AUDIO_PORT_CONFIG_CHANNEL_MASK; |
| 683 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 684 | |
| 685 | jint jFormat = env->GetIntField(jAudioPortConfig, gAudioPortConfigFields.mFormat); |
| 686 | audio_format_t nFormat = audioFormatToNative(jFormat); |
| 687 | ALOGV("convertAudioPortConfigToNative format %d native %d", jFormat, nFormat); |
| 688 | nAudioPortConfig->format = nFormat; |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 689 | if (nAudioPortConfig->format != AUDIO_FORMAT_DEFAULT && |
| 690 | nAudioPortConfig->format != AUDIO_FORMAT_INVALID) { |
| 691 | configMask |= AUDIO_PORT_CONFIG_FORMAT; |
| 692 | } |
| 693 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 694 | jobject jGain = env->GetObjectField(jAudioPortConfig, gAudioPortConfigFields.mGain); |
| 695 | if (jGain != NULL) { |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 696 | convertAudioGainConfigToNative(env, &nAudioPortConfig->gain, jGain, useInMask); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 697 | env->DeleteLocalRef(jGain); |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 698 | configMask |= AUDIO_PORT_CONFIG_GAIN; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 699 | } else { |
| 700 | ALOGV("convertAudioPortConfigToNative no gain"); |
| 701 | nAudioPortConfig->gain.index = -1; |
| 702 | } |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 703 | if (useConfigMask) { |
| 704 | nAudioPortConfig->config_mask = env->GetIntField(jAudioPortConfig, |
| 705 | gAudioPortConfigFields.mConfigMask); |
| 706 | } else { |
| 707 | nAudioPortConfig->config_mask = configMask; |
| 708 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 709 | env->DeleteLocalRef(jAudioPort); |
| 710 | env->DeleteLocalRef(jHandle); |
| 711 | return (jint)AUDIO_JAVA_SUCCESS; |
| 712 | } |
| 713 | |
| 714 | static jint convertAudioPortConfigFromNative(JNIEnv *env, |
| 715 | jobject jAudioPort, |
| 716 | jobject *jAudioPortConfig, |
| 717 | const struct audio_port_config *nAudioPortConfig) |
| 718 | { |
| 719 | jint jStatus = AUDIO_JAVA_SUCCESS; |
| 720 | jobject jAudioGainConfig = NULL; |
| 721 | jobject jAudioGain = NULL; |
| 722 | jintArray jGainValues; |
| 723 | bool audioportCreated = false; |
| 724 | |
| 725 | ALOGV("convertAudioPortConfigFromNative jAudioPort %p", jAudioPort); |
| 726 | |
| 727 | if (jAudioPort == NULL) { |
| 728 | jobject jHandle = env->NewObject(gAudioHandleClass, gAudioHandleCstor, |
| 729 | nAudioPortConfig->id); |
| 730 | |
| 731 | ALOGV("convertAudioPortConfigFromNative handle %d is a %s", nAudioPortConfig->id, |
| 732 | nAudioPortConfig->type == AUDIO_PORT_TYPE_DEVICE ? "device" : "mix"); |
| 733 | |
| 734 | if (jHandle == NULL) { |
| 735 | return (jint)AUDIO_JAVA_ERROR; |
| 736 | } |
| 737 | // create dummy port and port config objects with just the correct handle |
| 738 | // and configuration data. The actual AudioPortConfig objects will be |
| 739 | // constructed by java code with correct class type (device, mix etc...) |
| 740 | // and reference to AudioPort instance in this client |
| 741 | jAudioPort = env->NewObject(gAudioPortClass, gAudioPortCstor, |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 742 | jHandle, // handle |
| 743 | 0, // role |
| 744 | NULL, // name |
| 745 | NULL, // samplingRates |
| 746 | NULL, // channelMasks |
| 747 | NULL, // channelIndexMasks |
| 748 | NULL, // formats |
| 749 | NULL); // gains |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 750 | env->DeleteLocalRef(jHandle); |
| 751 | if (jAudioPort == NULL) { |
| 752 | return (jint)AUDIO_JAVA_ERROR; |
| 753 | } |
| 754 | ALOGV("convertAudioPortConfigFromNative jAudioPort created for handle %d", |
| 755 | nAudioPortConfig->id); |
| 756 | |
| 757 | audioportCreated = true; |
| 758 | } |
| 759 | |
| 760 | bool useInMask = useInChannelMask(nAudioPortConfig->type, nAudioPortConfig->role); |
| 761 | |
| 762 | audio_channel_mask_t nMask; |
| 763 | jint jMask; |
| 764 | |
| 765 | int gainIndex = nAudioPortConfig->gain.index; |
| 766 | if (gainIndex >= 0) { |
| 767 | ALOGV("convertAudioPortConfigFromNative gain found with index %d mode %x", |
| 768 | gainIndex, nAudioPortConfig->gain.mode); |
| 769 | if (audioportCreated) { |
| 770 | ALOGV("convertAudioPortConfigFromNative creating gain"); |
| 771 | jAudioGain = env->NewObject(gAudioGainClass, gAudioGainCstor, |
| 772 | gainIndex, |
| 773 | 0, |
| 774 | 0, |
| 775 | 0, |
| 776 | 0, |
| 777 | 0, |
| 778 | 0, |
| 779 | 0, |
| 780 | 0); |
| 781 | if (jAudioGain == NULL) { |
| 782 | ALOGV("convertAudioPortConfigFromNative creating gain FAILED"); |
| 783 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 784 | goto exit; |
| 785 | } |
| 786 | } else { |
| 787 | ALOGV("convertAudioPortConfigFromNative reading gain from port"); |
| 788 | jobjectArray jGains = (jobjectArray)env->GetObjectField(jAudioPort, |
| 789 | gAudioPortFields.mGains); |
| 790 | if (jGains == NULL) { |
| 791 | ALOGV("convertAudioPortConfigFromNative could not get gains from port"); |
| 792 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 793 | goto exit; |
| 794 | } |
| 795 | jAudioGain = env->GetObjectArrayElement(jGains, gainIndex); |
| 796 | env->DeleteLocalRef(jGains); |
| 797 | if (jAudioGain == NULL) { |
| 798 | ALOGV("convertAudioPortConfigFromNative could not get gain at index %d", gainIndex); |
| 799 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 800 | goto exit; |
| 801 | } |
| 802 | } |
Eric Laurent | 0078c7c | 2014-06-04 09:49:52 -0700 | [diff] [blame] | 803 | int numValues; |
| 804 | if (useInMask) { |
| 805 | numValues = audio_channel_count_from_in_mask(nAudioPortConfig->gain.channel_mask); |
| 806 | } else { |
| 807 | numValues = audio_channel_count_from_out_mask(nAudioPortConfig->gain.channel_mask); |
| 808 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 809 | jGainValues = env->NewIntArray(numValues); |
| 810 | if (jGainValues == NULL) { |
| 811 | ALOGV("convertAudioPortConfigFromNative could not create gain values %d", numValues); |
| 812 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 813 | goto exit; |
| 814 | } |
| 815 | env->SetIntArrayRegion(jGainValues, 0, numValues, |
| 816 | nAudioPortConfig->gain.values); |
| 817 | |
| 818 | nMask = nAudioPortConfig->gain.channel_mask; |
| 819 | if (useInMask) { |
| 820 | jMask = inChannelMaskFromNative(nMask); |
| 821 | ALOGV("convertAudioPortConfigFromNative IN mask java %x native %x", jMask, nMask); |
| 822 | } else { |
| 823 | jMask = outChannelMaskFromNative(nMask); |
| 824 | ALOGV("convertAudioPortConfigFromNative OUT mask java %x native %x", jMask, nMask); |
| 825 | } |
| 826 | |
| 827 | jAudioGainConfig = env->NewObject(gAudioGainConfigClass, |
| 828 | gAudioGainConfigCstor, |
| 829 | gainIndex, |
| 830 | jAudioGain, |
| 831 | nAudioPortConfig->gain.mode, |
| 832 | jMask, |
| 833 | jGainValues, |
| 834 | nAudioPortConfig->gain.ramp_duration_ms); |
| 835 | env->DeleteLocalRef(jGainValues); |
| 836 | if (jAudioGainConfig == NULL) { |
| 837 | ALOGV("convertAudioPortConfigFromNative could not create gain config"); |
| 838 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 839 | goto exit; |
| 840 | } |
| 841 | } |
| 842 | jclass clazz; |
| 843 | jmethodID methodID; |
| 844 | if (audioportCreated) { |
| 845 | clazz = gAudioPortConfigClass; |
| 846 | methodID = gAudioPortConfigCstor; |
| 847 | ALOGV("convertAudioPortConfigFromNative building a generic port config"); |
| 848 | } else { |
| 849 | if (env->IsInstanceOf(jAudioPort, gAudioDevicePortClass)) { |
| 850 | clazz = gAudioDevicePortConfigClass; |
| 851 | methodID = gAudioDevicePortConfigCstor; |
| 852 | ALOGV("convertAudioPortConfigFromNative building a device config"); |
| 853 | } else if (env->IsInstanceOf(jAudioPort, gAudioMixPortClass)) { |
| 854 | clazz = gAudioMixPortConfigClass; |
| 855 | methodID = gAudioMixPortConfigCstor; |
| 856 | ALOGV("convertAudioPortConfigFromNative building a mix config"); |
| 857 | } else { |
| 858 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 859 | goto exit; |
| 860 | } |
| 861 | } |
| 862 | nMask = nAudioPortConfig->channel_mask; |
| 863 | if (useInMask) { |
| 864 | jMask = inChannelMaskFromNative(nMask); |
| 865 | ALOGV("convertAudioPortConfigFromNative IN mask java %x native %x", jMask, nMask); |
| 866 | } else { |
| 867 | jMask = outChannelMaskFromNative(nMask); |
| 868 | ALOGV("convertAudioPortConfigFromNative OUT mask java %x native %x", jMask, nMask); |
| 869 | } |
| 870 | |
| 871 | *jAudioPortConfig = env->NewObject(clazz, methodID, |
| 872 | jAudioPort, |
| 873 | nAudioPortConfig->sample_rate, |
| 874 | jMask, |
| 875 | audioFormatFromNative(nAudioPortConfig->format), |
| 876 | jAudioGainConfig); |
| 877 | if (*jAudioPortConfig == NULL) { |
| 878 | ALOGV("convertAudioPortConfigFromNative could not create new port config"); |
| 879 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 880 | } else { |
| 881 | ALOGV("convertAudioPortConfigFromNative OK"); |
| 882 | } |
| 883 | |
| 884 | exit: |
| 885 | if (audioportCreated) { |
| 886 | env->DeleteLocalRef(jAudioPort); |
| 887 | if (jAudioGain != NULL) { |
| 888 | env->DeleteLocalRef(jAudioGain); |
| 889 | } |
| 890 | } |
| 891 | if (jAudioGainConfig != NULL) { |
| 892 | env->DeleteLocalRef(jAudioGainConfig); |
| 893 | } |
| 894 | return jStatus; |
| 895 | } |
| 896 | |
Paul McLean | 4e5e9e9 | 2015-06-17 10:10:11 -0700 | [diff] [blame] | 897 | static bool hasFormat(int* formats, size_t size, int format) { |
| 898 | for (size_t index = 0; index < size; index++) { |
| 899 | if (formats[index] == format) { |
| 900 | return true; // found |
| 901 | } |
| 902 | } |
| 903 | return false; // not found |
| 904 | } |
| 905 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 906 | static jint convertAudioPortFromNative(JNIEnv *env, |
| 907 | jobject *jAudioPort, const struct audio_port *nAudioPort) |
| 908 | { |
| 909 | jint jStatus = (jint)AUDIO_JAVA_SUCCESS; |
| 910 | jintArray jSamplingRates = NULL; |
| 911 | jintArray jChannelMasks = NULL; |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 912 | jintArray jChannelIndexMasks = NULL; |
Paul McLean | 4e5e9e9 | 2015-06-17 10:10:11 -0700 | [diff] [blame] | 913 | int* cFormats = NULL; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 914 | jintArray jFormats = NULL; |
| 915 | jobjectArray jGains = NULL; |
| 916 | jobject jHandle = NULL; |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 917 | jstring jDeviceName = NULL; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 918 | bool useInMask; |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 919 | size_t numPositionMasks = 0; |
| 920 | size_t numIndexMasks = 0; |
Paul McLean | 2db9437 | 2015-06-18 12:47:34 -0700 | [diff] [blame] | 921 | size_t numUniqueFormats = 0; |
| 922 | |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 923 | ALOGV("convertAudioPortFromNative id %d role %d type %d name %s", |
| 924 | nAudioPort->id, nAudioPort->role, nAudioPort->type, nAudioPort->name); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 925 | |
| 926 | jSamplingRates = env->NewIntArray(nAudioPort->num_sample_rates); |
| 927 | if (jSamplingRates == NULL) { |
| 928 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 929 | goto exit; |
| 930 | } |
| 931 | if (nAudioPort->num_sample_rates) { |
| 932 | env->SetIntArrayRegion(jSamplingRates, 0, nAudioPort->num_sample_rates, |
| 933 | (jint *)nAudioPort->sample_rates); |
| 934 | } |
| 935 | |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 936 | // count up how many masks are positional and indexed |
| 937 | for(size_t index = 0; index < nAudioPort->num_channel_masks; index++) { |
| 938 | const audio_channel_mask_t mask = nAudioPort->channel_masks[index]; |
| 939 | if (audio_channel_mask_get_representation(mask) == AUDIO_CHANNEL_REPRESENTATION_INDEX) { |
| 940 | numIndexMasks++; |
| 941 | } else { |
| 942 | numPositionMasks++; |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | jChannelMasks = env->NewIntArray(numPositionMasks); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 947 | if (jChannelMasks == NULL) { |
| 948 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 949 | goto exit; |
| 950 | } |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 951 | jChannelIndexMasks = env->NewIntArray(numIndexMasks); |
| 952 | if (jChannelIndexMasks == NULL) { |
| 953 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 954 | goto exit; |
| 955 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 956 | useInMask = useInChannelMask(nAudioPort->type, nAudioPort->role); |
| 957 | |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 958 | // put the masks in the output arrays |
| 959 | for (size_t maskIndex = 0, posMaskIndex = 0, indexedMaskIndex = 0; |
| 960 | maskIndex < nAudioPort->num_channel_masks; maskIndex++) { |
| 961 | const audio_channel_mask_t mask = nAudioPort->channel_masks[maskIndex]; |
| 962 | if (audio_channel_mask_get_representation(mask) == AUDIO_CHANNEL_REPRESENTATION_INDEX) { |
| 963 | jint jMask = audio_channel_mask_get_bits(mask); |
| 964 | env->SetIntArrayRegion(jChannelIndexMasks, indexedMaskIndex++, 1, &jMask); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 965 | } else { |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 966 | jint jMask = useInMask ? inChannelMaskFromNative(mask) |
| 967 | : outChannelMaskFromNative(mask); |
| 968 | env->SetIntArrayRegion(jChannelMasks, posMaskIndex++, 1, &jMask); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 969 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 970 | } |
| 971 | |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 972 | // formats |
Paul McLean | 2db9437 | 2015-06-18 12:47:34 -0700 | [diff] [blame] | 973 | if (nAudioPort->num_formats != 0) { |
| 974 | cFormats = new int[nAudioPort->num_formats]; |
| 975 | for (size_t index = 0; index < nAudioPort->num_formats; index++) { |
| 976 | int format = audioFormatFromNative(nAudioPort->formats[index]); |
| 977 | if (!hasFormat(cFormats, numUniqueFormats, format)) { |
| 978 | cFormats[numUniqueFormats++] = format; |
| 979 | } |
Paul McLean | 4e5e9e9 | 2015-06-17 10:10:11 -0700 | [diff] [blame] | 980 | } |
| 981 | } |
| 982 | jFormats = env->NewIntArray(numUniqueFormats); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 983 | if (jFormats == NULL) { |
| 984 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 985 | goto exit; |
| 986 | } |
Paul McLean | 2db9437 | 2015-06-18 12:47:34 -0700 | [diff] [blame] | 987 | if (numUniqueFormats != 0) { |
| 988 | env->SetIntArrayRegion(jFormats, 0, numUniqueFormats, cFormats); |
| 989 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 990 | |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 991 | // gains |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 992 | jGains = env->NewObjectArray(nAudioPort->num_gains, |
| 993 | gAudioGainClass, NULL); |
| 994 | if (jGains == NULL) { |
| 995 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 996 | goto exit; |
| 997 | } |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 998 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 999 | for (size_t j = 0; j < nAudioPort->num_gains; j++) { |
| 1000 | audio_channel_mask_t nMask = nAudioPort->gains[j].channel_mask; |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 1001 | jint jMask; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1002 | if (useInMask) { |
| 1003 | jMask = inChannelMaskFromNative(nMask); |
| 1004 | ALOGV("convertAudioPortConfigFromNative IN mask java %x native %x", jMask, nMask); |
| 1005 | } else { |
| 1006 | jMask = outChannelMaskFromNative(nMask); |
| 1007 | ALOGV("convertAudioPortConfigFromNative OUT mask java %x native %x", jMask, nMask); |
| 1008 | } |
| 1009 | |
| 1010 | jobject jGain = env->NewObject(gAudioGainClass, gAudioGainCstor, |
| 1011 | j, |
| 1012 | nAudioPort->gains[j].mode, |
| 1013 | jMask, |
| 1014 | nAudioPort->gains[j].min_value, |
| 1015 | nAudioPort->gains[j].max_value, |
| 1016 | nAudioPort->gains[j].default_value, |
| 1017 | nAudioPort->gains[j].step_value, |
| 1018 | nAudioPort->gains[j].min_ramp_ms, |
| 1019 | nAudioPort->gains[j].max_ramp_ms); |
| 1020 | if (jGain == NULL) { |
| 1021 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1022 | goto exit; |
| 1023 | } |
| 1024 | env->SetObjectArrayElement(jGains, j, jGain); |
| 1025 | env->DeleteLocalRef(jGain); |
| 1026 | } |
| 1027 | |
| 1028 | jHandle = env->NewObject(gAudioHandleClass, gAudioHandleCstor, |
| 1029 | nAudioPort->id); |
| 1030 | if (jHandle == NULL) { |
| 1031 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1032 | goto exit; |
| 1033 | } |
| 1034 | |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 1035 | jDeviceName = env->NewStringUTF(nAudioPort->name); |
| 1036 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1037 | if (nAudioPort->type == AUDIO_PORT_TYPE_DEVICE) { |
| 1038 | ALOGV("convertAudioPortFromNative is a device %08x", nAudioPort->ext.device.type); |
| 1039 | jstring jAddress = env->NewStringUTF(nAudioPort->ext.device.address); |
| 1040 | *jAudioPort = env->NewObject(gAudioDevicePortClass, gAudioDevicePortCstor, |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 1041 | jHandle, jDeviceName, |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 1042 | jSamplingRates, jChannelMasks, jChannelIndexMasks, |
| 1043 | jFormats, jGains, |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1044 | nAudioPort->ext.device.type, jAddress); |
| 1045 | env->DeleteLocalRef(jAddress); |
| 1046 | } else if (nAudioPort->type == AUDIO_PORT_TYPE_MIX) { |
| 1047 | ALOGV("convertAudioPortFromNative is a mix"); |
| 1048 | *jAudioPort = env->NewObject(gAudioMixPortClass, gAudioMixPortCstor, |
Eric Laurent | 4bcdba8 | 2015-05-01 11:37:49 -0700 | [diff] [blame] | 1049 | jHandle, nAudioPort->ext.mix.handle, |
| 1050 | nAudioPort->role, jDeviceName, |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 1051 | jSamplingRates, jChannelMasks, jChannelIndexMasks, |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1052 | jFormats, jGains); |
| 1053 | } else { |
| 1054 | ALOGE("convertAudioPortFromNative unknown nAudioPort type %d", nAudioPort->type); |
| 1055 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1056 | goto exit; |
| 1057 | } |
| 1058 | if (*jAudioPort == NULL) { |
| 1059 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1060 | goto exit; |
| 1061 | } |
| 1062 | |
| 1063 | jobject jAudioPortConfig; |
| 1064 | jStatus = convertAudioPortConfigFromNative(env, |
| 1065 | *jAudioPort, |
| 1066 | &jAudioPortConfig, |
| 1067 | &nAudioPort->active_config); |
| 1068 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1069 | return jStatus; |
| 1070 | } |
| 1071 | |
| 1072 | env->SetObjectField(*jAudioPort, gAudioPortFields.mActiveConfig, jAudioPortConfig); |
| 1073 | |
| 1074 | exit: |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 1075 | if (jDeviceName != NULL) { |
| 1076 | env->DeleteLocalRef(jDeviceName); |
| 1077 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1078 | if (jSamplingRates != NULL) { |
| 1079 | env->DeleteLocalRef(jSamplingRates); |
| 1080 | } |
| 1081 | if (jChannelMasks != NULL) { |
| 1082 | env->DeleteLocalRef(jChannelMasks); |
| 1083 | } |
Paul McLean | 4e5e9e9 | 2015-06-17 10:10:11 -0700 | [diff] [blame] | 1084 | if (jChannelIndexMasks != NULL) { |
| 1085 | env->DeleteLocalRef(jChannelIndexMasks); |
| 1086 | } |
| 1087 | if (cFormats != NULL) { |
| 1088 | delete[] cFormats; |
| 1089 | } |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1090 | if (jFormats != NULL) { |
| 1091 | env->DeleteLocalRef(jFormats); |
| 1092 | } |
| 1093 | if (jGains != NULL) { |
| 1094 | env->DeleteLocalRef(jGains); |
| 1095 | } |
| 1096 | if (jHandle != NULL) { |
| 1097 | env->DeleteLocalRef(jHandle); |
| 1098 | } |
| 1099 | |
| 1100 | return jStatus; |
| 1101 | } |
| 1102 | |
| 1103 | |
| 1104 | static jint |
| 1105 | android_media_AudioSystem_listAudioPorts(JNIEnv *env, jobject clazz, |
| 1106 | jobject jPorts, jintArray jGeneration) |
| 1107 | { |
| 1108 | ALOGV("listAudioPorts"); |
| 1109 | |
| 1110 | if (jPorts == NULL) { |
| 1111 | ALOGE("listAudioPorts NULL AudioPort ArrayList"); |
| 1112 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1113 | } |
| 1114 | if (!env->IsInstanceOf(jPorts, gArrayListClass)) { |
| 1115 | ALOGE("listAudioPorts not an arraylist"); |
| 1116 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1117 | } |
| 1118 | |
| 1119 | if (jGeneration == NULL || env->GetArrayLength(jGeneration) != 1) { |
| 1120 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1121 | } |
| 1122 | |
| 1123 | status_t status; |
| 1124 | unsigned int generation1; |
| 1125 | unsigned int generation; |
| 1126 | unsigned int numPorts; |
| 1127 | jint *nGeneration; |
| 1128 | struct audio_port *nPorts = NULL; |
| 1129 | int attempts = MAX_PORT_GENERATION_SYNC_ATTEMPTS; |
| 1130 | |
| 1131 | // get the port count and all the ports until they both return the same generation |
| 1132 | do { |
| 1133 | if (attempts-- < 0) { |
| 1134 | status = TIMED_OUT; |
| 1135 | break; |
| 1136 | } |
| 1137 | |
| 1138 | numPorts = 0; |
| 1139 | status = AudioSystem::listAudioPorts(AUDIO_PORT_ROLE_NONE, |
| 1140 | AUDIO_PORT_TYPE_NONE, |
| 1141 | &numPorts, |
| 1142 | NULL, |
| 1143 | &generation1); |
| 1144 | if (status != NO_ERROR || numPorts == 0) { |
| 1145 | ALOGE_IF(status != NO_ERROR, "AudioSystem::listAudioPorts error %d", status); |
| 1146 | break; |
| 1147 | } |
| 1148 | nPorts = (struct audio_port *)realloc(nPorts, numPorts * sizeof(struct audio_port)); |
| 1149 | |
| 1150 | status = AudioSystem::listAudioPorts(AUDIO_PORT_ROLE_NONE, |
| 1151 | AUDIO_PORT_TYPE_NONE, |
| 1152 | &numPorts, |
| 1153 | nPorts, |
| 1154 | &generation); |
| 1155 | ALOGV("listAudioPorts AudioSystem::listAudioPorts numPorts %d generation %d generation1 %d", |
| 1156 | numPorts, generation, generation1); |
| 1157 | } while (generation1 != generation && status == NO_ERROR); |
| 1158 | |
| 1159 | jint jStatus = nativeToJavaStatus(status); |
| 1160 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1161 | goto exit; |
| 1162 | } |
| 1163 | |
| 1164 | nGeneration = env->GetIntArrayElements(jGeneration, NULL); |
| 1165 | if (nGeneration == NULL) { |
| 1166 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1167 | goto exit; |
| 1168 | } |
| 1169 | nGeneration[0] = generation1; |
| 1170 | env->ReleaseIntArrayElements(jGeneration, nGeneration, 0); |
| 1171 | |
| 1172 | for (size_t i = 0; i < numPorts; i++) { |
| 1173 | jobject jAudioPort; |
| 1174 | jStatus = convertAudioPortFromNative(env, &jAudioPort, &nPorts[i]); |
| 1175 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1176 | goto exit; |
| 1177 | } |
| 1178 | env->CallBooleanMethod(jPorts, gArrayListMethods.add, jAudioPort); |
| 1179 | } |
| 1180 | |
| 1181 | exit: |
| 1182 | free(nPorts); |
| 1183 | return jStatus; |
| 1184 | } |
| 1185 | |
| 1186 | static int |
| 1187 | android_media_AudioSystem_createAudioPatch(JNIEnv *env, jobject clazz, |
| 1188 | jobjectArray jPatches, jobjectArray jSources, jobjectArray jSinks) |
| 1189 | { |
| 1190 | status_t status; |
| 1191 | jint jStatus; |
| 1192 | |
| 1193 | ALOGV("createAudioPatch"); |
| 1194 | if (jPatches == NULL || jSources == NULL || jSinks == NULL) { |
| 1195 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1196 | } |
| 1197 | |
| 1198 | if (env->GetArrayLength(jPatches) != 1) { |
| 1199 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1200 | } |
| 1201 | jint numSources = env->GetArrayLength(jSources); |
| 1202 | if (numSources == 0 || numSources > AUDIO_PATCH_PORTS_MAX) { |
| 1203 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1204 | } |
| 1205 | |
| 1206 | jint numSinks = env->GetArrayLength(jSinks); |
| 1207 | if (numSinks == 0 || numSinks > AUDIO_PATCH_PORTS_MAX) { |
| 1208 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1209 | } |
| 1210 | |
| 1211 | audio_patch_handle_t handle = (audio_patch_handle_t)0; |
| 1212 | jobject jPatch = env->GetObjectArrayElement(jPatches, 0); |
| 1213 | jobject jPatchHandle = NULL; |
| 1214 | if (jPatch != NULL) { |
| 1215 | if (!env->IsInstanceOf(jPatch, gAudioPatchClass)) { |
| 1216 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1217 | } |
| 1218 | jPatchHandle = env->GetObjectField(jPatch, gAudioPatchFields.mHandle); |
| 1219 | handle = (audio_patch_handle_t)env->GetIntField(jPatchHandle, gAudioHandleFields.mId); |
| 1220 | } |
| 1221 | |
| 1222 | struct audio_patch nPatch; |
| 1223 | |
| 1224 | nPatch.id = handle; |
| 1225 | nPatch.num_sources = 0; |
| 1226 | nPatch.num_sinks = 0; |
| 1227 | jobject jSource = NULL; |
| 1228 | jobject jSink = NULL; |
| 1229 | |
| 1230 | for (jint i = 0; i < numSources; i++) { |
| 1231 | jSource = env->GetObjectArrayElement(jSources, i); |
| 1232 | if (!env->IsInstanceOf(jSource, gAudioPortConfigClass)) { |
| 1233 | jStatus = (jint)AUDIO_JAVA_BAD_VALUE; |
| 1234 | goto exit; |
| 1235 | } |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 1236 | jStatus = convertAudioPortConfigToNative(env, &nPatch.sources[i], jSource, false); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1237 | env->DeleteLocalRef(jSource); |
| 1238 | jSource = NULL; |
| 1239 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1240 | goto exit; |
| 1241 | } |
| 1242 | nPatch.num_sources++; |
| 1243 | } |
| 1244 | |
| 1245 | for (jint i = 0; i < numSinks; i++) { |
| 1246 | jSink = env->GetObjectArrayElement(jSinks, i); |
| 1247 | if (!env->IsInstanceOf(jSink, gAudioPortConfigClass)) { |
| 1248 | jStatus = (jint)AUDIO_JAVA_BAD_VALUE; |
| 1249 | goto exit; |
| 1250 | } |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 1251 | jStatus = convertAudioPortConfigToNative(env, &nPatch.sinks[i], jSink, false); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1252 | env->DeleteLocalRef(jSink); |
| 1253 | jSink = NULL; |
| 1254 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1255 | goto exit; |
| 1256 | } |
| 1257 | nPatch.num_sinks++; |
| 1258 | } |
| 1259 | |
| 1260 | ALOGV("AudioSystem::createAudioPatch"); |
| 1261 | status = AudioSystem::createAudioPatch(&nPatch, &handle); |
| 1262 | ALOGV("AudioSystem::createAudioPatch() returned %d hande %d", status, handle); |
| 1263 | |
| 1264 | jStatus = nativeToJavaStatus(status); |
| 1265 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1266 | goto exit; |
| 1267 | } |
| 1268 | |
| 1269 | if (jPatchHandle == NULL) { |
| 1270 | jPatchHandle = env->NewObject(gAudioHandleClass, gAudioHandleCstor, |
| 1271 | handle); |
| 1272 | if (jPatchHandle == NULL) { |
| 1273 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1274 | goto exit; |
| 1275 | } |
| 1276 | jPatch = env->NewObject(gAudioPatchClass, gAudioPatchCstor, jPatchHandle, jSources, jSinks); |
| 1277 | if (jPatch == NULL) { |
| 1278 | jStatus = (jint)AUDIO_JAVA_ERROR; |
| 1279 | goto exit; |
| 1280 | } |
| 1281 | env->SetObjectArrayElement(jPatches, 0, jPatch); |
| 1282 | } else { |
| 1283 | env->SetIntField(jPatchHandle, gAudioHandleFields.mId, handle); |
| 1284 | } |
| 1285 | |
| 1286 | exit: |
| 1287 | if (jPatchHandle != NULL) { |
| 1288 | env->DeleteLocalRef(jPatchHandle); |
| 1289 | } |
| 1290 | if (jPatch != NULL) { |
| 1291 | env->DeleteLocalRef(jPatch); |
| 1292 | } |
| 1293 | if (jSource != NULL) { |
| 1294 | env->DeleteLocalRef(jSource); |
| 1295 | } |
| 1296 | if (jSink != NULL) { |
| 1297 | env->DeleteLocalRef(jSink); |
| 1298 | } |
| 1299 | return jStatus; |
| 1300 | } |
| 1301 | |
Andreas Gampe | 0f0b491 | 2014-11-12 08:03:48 -0800 | [diff] [blame] | 1302 | static jint |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1303 | android_media_AudioSystem_releaseAudioPatch(JNIEnv *env, jobject clazz, |
| 1304 | jobject jPatch) |
| 1305 | { |
| 1306 | ALOGV("releaseAudioPatch"); |
| 1307 | if (jPatch == NULL) { |
| 1308 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1309 | } |
| 1310 | |
| 1311 | audio_patch_handle_t handle = (audio_patch_handle_t)0; |
| 1312 | jobject jPatchHandle = NULL; |
| 1313 | if (!env->IsInstanceOf(jPatch, gAudioPatchClass)) { |
| 1314 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1315 | } |
| 1316 | jPatchHandle = env->GetObjectField(jPatch, gAudioPatchFields.mHandle); |
| 1317 | handle = (audio_patch_handle_t)env->GetIntField(jPatchHandle, gAudioHandleFields.mId); |
| 1318 | env->DeleteLocalRef(jPatchHandle); |
| 1319 | |
| 1320 | ALOGV("AudioSystem::releaseAudioPatch"); |
| 1321 | status_t status = AudioSystem::releaseAudioPatch(handle); |
| 1322 | ALOGV("AudioSystem::releaseAudioPatch() returned %d", status); |
| 1323 | jint jStatus = nativeToJavaStatus(status); |
Andreas Gampe | 0f0b491 | 2014-11-12 08:03:48 -0800 | [diff] [blame] | 1324 | return jStatus; |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1325 | } |
| 1326 | |
| 1327 | static jint |
| 1328 | android_media_AudioSystem_listAudioPatches(JNIEnv *env, jobject clazz, |
| 1329 | jobject jPatches, jintArray jGeneration) |
| 1330 | { |
| 1331 | ALOGV("listAudioPatches"); |
| 1332 | if (jPatches == NULL) { |
| 1333 | ALOGE("listAudioPatches NULL AudioPatch ArrayList"); |
| 1334 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1335 | } |
| 1336 | if (!env->IsInstanceOf(jPatches, gArrayListClass)) { |
| 1337 | ALOGE("listAudioPatches not an arraylist"); |
| 1338 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1339 | } |
| 1340 | |
| 1341 | if (jGeneration == NULL || env->GetArrayLength(jGeneration) != 1) { |
| 1342 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1343 | } |
| 1344 | |
| 1345 | status_t status; |
| 1346 | unsigned int generation1; |
| 1347 | unsigned int generation; |
| 1348 | unsigned int numPatches; |
| 1349 | jint *nGeneration; |
| 1350 | struct audio_patch *nPatches = NULL; |
| 1351 | jobjectArray jSources = NULL; |
| 1352 | jobject jSource = NULL; |
| 1353 | jobjectArray jSinks = NULL; |
| 1354 | jobject jSink = NULL; |
| 1355 | jobject jPatch = NULL; |
| 1356 | int attempts = MAX_PORT_GENERATION_SYNC_ATTEMPTS; |
| 1357 | |
| 1358 | // get the patch count and all the patches until they both return the same generation |
| 1359 | do { |
| 1360 | if (attempts-- < 0) { |
| 1361 | status = TIMED_OUT; |
| 1362 | break; |
| 1363 | } |
| 1364 | |
| 1365 | numPatches = 0; |
| 1366 | status = AudioSystem::listAudioPatches(&numPatches, |
| 1367 | NULL, |
| 1368 | &generation1); |
| 1369 | if (status != NO_ERROR || numPatches == 0) { |
| 1370 | ALOGE_IF(status != NO_ERROR, "listAudioPatches AudioSystem::listAudioPatches error %d", |
| 1371 | status); |
| 1372 | break; |
| 1373 | } |
| 1374 | nPatches = (struct audio_patch *)realloc(nPatches, numPatches * sizeof(struct audio_patch)); |
| 1375 | |
| 1376 | status = AudioSystem::listAudioPatches(&numPatches, |
| 1377 | nPatches, |
| 1378 | &generation); |
| 1379 | ALOGV("listAudioPatches AudioSystem::listAudioPatches numPatches %d generation %d generation1 %d", |
| 1380 | numPatches, generation, generation1); |
| 1381 | |
| 1382 | } while (generation1 != generation && status == NO_ERROR); |
| 1383 | |
| 1384 | jint jStatus = nativeToJavaStatus(status); |
| 1385 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1386 | goto exit; |
| 1387 | } |
| 1388 | |
| 1389 | nGeneration = env->GetIntArrayElements(jGeneration, NULL); |
| 1390 | if (nGeneration == NULL) { |
| 1391 | jStatus = AUDIO_JAVA_ERROR; |
| 1392 | goto exit; |
| 1393 | } |
| 1394 | nGeneration[0] = generation1; |
| 1395 | env->ReleaseIntArrayElements(jGeneration, nGeneration, 0); |
| 1396 | |
| 1397 | for (size_t i = 0; i < numPatches; i++) { |
| 1398 | jobject patchHandle = env->NewObject(gAudioHandleClass, gAudioHandleCstor, |
| 1399 | nPatches[i].id); |
| 1400 | if (patchHandle == NULL) { |
| 1401 | jStatus = AUDIO_JAVA_ERROR; |
| 1402 | goto exit; |
| 1403 | } |
Dan Albert | 46d8444 | 2014-11-18 16:07:51 -0800 | [diff] [blame] | 1404 | ALOGV("listAudioPatches patch %zu num_sources %d num_sinks %d", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1405 | i, nPatches[i].num_sources, nPatches[i].num_sinks); |
| 1406 | |
| 1407 | env->SetIntField(patchHandle, gAudioHandleFields.mId, nPatches[i].id); |
| 1408 | |
| 1409 | // load sources |
| 1410 | jSources = env->NewObjectArray(nPatches[i].num_sources, |
| 1411 | gAudioPortConfigClass, NULL); |
| 1412 | if (jSources == NULL) { |
| 1413 | jStatus = AUDIO_JAVA_ERROR; |
| 1414 | goto exit; |
| 1415 | } |
| 1416 | |
| 1417 | for (size_t j = 0; j < nPatches[i].num_sources; j++) { |
| 1418 | jStatus = convertAudioPortConfigFromNative(env, |
| 1419 | NULL, |
| 1420 | &jSource, |
| 1421 | &nPatches[i].sources[j]); |
| 1422 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1423 | goto exit; |
| 1424 | } |
| 1425 | env->SetObjectArrayElement(jSources, j, jSource); |
| 1426 | env->DeleteLocalRef(jSource); |
| 1427 | jSource = NULL; |
Dan Albert | 46d8444 | 2014-11-18 16:07:51 -0800 | [diff] [blame] | 1428 | ALOGV("listAudioPatches patch %zu source %zu is a %s handle %d", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1429 | i, j, |
| 1430 | nPatches[i].sources[j].type == AUDIO_PORT_TYPE_DEVICE ? "device" : "mix", |
| 1431 | nPatches[i].sources[j].id); |
| 1432 | } |
| 1433 | // load sinks |
| 1434 | jSinks = env->NewObjectArray(nPatches[i].num_sinks, |
| 1435 | gAudioPortConfigClass, NULL); |
| 1436 | if (jSinks == NULL) { |
| 1437 | jStatus = AUDIO_JAVA_ERROR; |
| 1438 | goto exit; |
| 1439 | } |
| 1440 | |
| 1441 | for (size_t j = 0; j < nPatches[i].num_sinks; j++) { |
| 1442 | jStatus = convertAudioPortConfigFromNative(env, |
| 1443 | NULL, |
| 1444 | &jSink, |
| 1445 | &nPatches[i].sinks[j]); |
| 1446 | |
| 1447 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1448 | goto exit; |
| 1449 | } |
| 1450 | env->SetObjectArrayElement(jSinks, j, jSink); |
| 1451 | env->DeleteLocalRef(jSink); |
| 1452 | jSink = NULL; |
Dan Albert | 46d8444 | 2014-11-18 16:07:51 -0800 | [diff] [blame] | 1453 | ALOGV("listAudioPatches patch %zu sink %zu is a %s handle %d", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1454 | i, j, |
| 1455 | nPatches[i].sinks[j].type == AUDIO_PORT_TYPE_DEVICE ? "device" : "mix", |
| 1456 | nPatches[i].sinks[j].id); |
| 1457 | } |
| 1458 | |
| 1459 | jPatch = env->NewObject(gAudioPatchClass, gAudioPatchCstor, |
| 1460 | patchHandle, jSources, jSinks); |
| 1461 | env->DeleteLocalRef(jSources); |
| 1462 | jSources = NULL; |
| 1463 | env->DeleteLocalRef(jSinks); |
| 1464 | jSinks = NULL; |
| 1465 | if (jPatch == NULL) { |
| 1466 | jStatus = AUDIO_JAVA_ERROR; |
| 1467 | goto exit; |
| 1468 | } |
| 1469 | env->CallBooleanMethod(jPatches, gArrayListMethods.add, jPatch); |
| 1470 | env->DeleteLocalRef(jPatch); |
| 1471 | jPatch = NULL; |
| 1472 | } |
| 1473 | |
| 1474 | exit: |
| 1475 | if (jSources != NULL) { |
| 1476 | env->DeleteLocalRef(jSources); |
| 1477 | } |
| 1478 | if (jSource != NULL) { |
| 1479 | env->DeleteLocalRef(jSource); |
| 1480 | } |
| 1481 | if (jSinks != NULL) { |
| 1482 | env->DeleteLocalRef(jSinks); |
| 1483 | } |
| 1484 | if (jSink != NULL) { |
| 1485 | env->DeleteLocalRef(jSink); |
| 1486 | } |
| 1487 | if (jPatch != NULL) { |
| 1488 | env->DeleteLocalRef(jPatch); |
| 1489 | } |
| 1490 | free(nPatches); |
| 1491 | return jStatus; |
| 1492 | } |
| 1493 | |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 1494 | static jint |
| 1495 | android_media_AudioSystem_setAudioPortConfig(JNIEnv *env, jobject clazz, |
| 1496 | jobject jAudioPortConfig) |
| 1497 | { |
| 1498 | ALOGV("setAudioPortConfig"); |
| 1499 | if (jAudioPortConfig == NULL) { |
| 1500 | return AUDIO_JAVA_BAD_VALUE; |
| 1501 | } |
| 1502 | if (!env->IsInstanceOf(jAudioPortConfig, gAudioPortConfigClass)) { |
| 1503 | return AUDIO_JAVA_BAD_VALUE; |
| 1504 | } |
| 1505 | struct audio_port_config nAudioPortConfig; |
Eric Laurent | 6368a7d | 2014-11-19 12:18:32 -0800 | [diff] [blame] | 1506 | jint jStatus = convertAudioPortConfigToNative(env, &nAudioPortConfig, jAudioPortConfig, true); |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 1507 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1508 | return jStatus; |
| 1509 | } |
| 1510 | status_t status = AudioSystem::setAudioPortConfig(&nAudioPortConfig); |
| 1511 | ALOGV("AudioSystem::setAudioPortConfig() returned %d", status); |
| 1512 | jStatus = nativeToJavaStatus(status); |
| 1513 | return jStatus; |
| 1514 | } |
| 1515 | |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 1516 | static void |
| 1517 | android_media_AudioSystem_eventHandlerSetup(JNIEnv *env, jobject thiz, jobject weak_this) |
| 1518 | { |
| 1519 | ALOGV("eventHandlerSetup"); |
| 1520 | |
| 1521 | sp<JNIAudioPortCallback> callback = new JNIAudioPortCallback(env, thiz, weak_this); |
| 1522 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 1523 | if (AudioSystem::addAudioPortCallback(callback) == NO_ERROR) { |
| 1524 | setJniCallback(env, thiz, callback); |
| 1525 | } |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | static void |
| 1529 | android_media_AudioSystem_eventHandlerFinalize(JNIEnv *env, jobject thiz) |
| 1530 | { |
| 1531 | ALOGV("eventHandlerFinalize"); |
| 1532 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 1533 | sp<JNIAudioPortCallback> callback = setJniCallback(env, thiz, 0); |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 1534 | |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 1535 | if (callback != 0) { |
| 1536 | AudioSystem::removeAudioPortCallback(callback); |
| 1537 | } |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 1538 | } |
| 1539 | |
Eric Laurent | b634e1b | 2014-08-01 14:44:46 -0700 | [diff] [blame] | 1540 | static jint |
| 1541 | android_media_AudioSystem_getAudioHwSyncForSession(JNIEnv *env, jobject thiz, jint sessionId) |
| 1542 | { |
| 1543 | return (jint)AudioSystem::getAudioHwSyncForSession((audio_session_t)sessionId); |
| 1544 | } |
| 1545 | |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 1546 | static void |
| 1547 | android_media_AudioSystem_registerDynPolicyCallback(JNIEnv *env, jobject thiz) |
| 1548 | { |
| 1549 | AudioSystem::setDynPolicyCallback(android_media_AudioSystem_dyn_policy_callback); |
| 1550 | } |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1551 | |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 1552 | static void |
| 1553 | android_media_AudioSystem_registerRecordingCallback(JNIEnv *env, jobject thiz) |
| 1554 | { |
| 1555 | AudioSystem::setRecordConfigCallback(android_media_AudioSystem_recording_callback); |
| 1556 | } |
| 1557 | |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1558 | |
| 1559 | static jint convertAudioMixToNative(JNIEnv *env, |
| 1560 | AudioMix *nAudioMix, |
| 1561 | const jobject jAudioMix) |
| 1562 | { |
| 1563 | nAudioMix->mMixType = env->GetIntField(jAudioMix, gAudioMixFields.mMixType); |
| 1564 | nAudioMix->mRouteFlags = env->GetIntField(jAudioMix, gAudioMixFields.mRouteFlags); |
Jean-Michel Trivi | 4ad3988 | 2016-03-14 18:46:41 -0700 | [diff] [blame^] | 1565 | nAudioMix->mDeviceType = (audio_devices_t) |
| 1566 | env->GetIntField(jAudioMix, gAudioMixFields.mDeviceType); |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1567 | |
Jean-Michel Trivi | 4ad3988 | 2016-03-14 18:46:41 -0700 | [diff] [blame^] | 1568 | jstring jDeviceAddress = (jstring)env->GetObjectField(jAudioMix, |
| 1569 | gAudioMixFields.mDeviceAddress); |
| 1570 | const char *nDeviceAddress = env->GetStringUTFChars(jDeviceAddress, NULL); |
| 1571 | nAudioMix->mDeviceAddress = String8(nDeviceAddress); |
| 1572 | env->ReleaseStringUTFChars(jDeviceAddress, nDeviceAddress); |
| 1573 | env->DeleteLocalRef(jDeviceAddress); |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1574 | |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 1575 | nAudioMix->mCbFlags = env->GetIntField(jAudioMix, gAudioMixFields.mCallbackFlags); |
| 1576 | |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1577 | jobject jFormat = env->GetObjectField(jAudioMix, gAudioMixFields.mFormat); |
| 1578 | nAudioMix->mFormat.sample_rate = env->GetIntField(jFormat, |
| 1579 | gAudioFormatFields.mSampleRate); |
| 1580 | nAudioMix->mFormat.channel_mask = outChannelMaskToNative(env->GetIntField(jFormat, |
| 1581 | gAudioFormatFields.mChannelMask)); |
| 1582 | nAudioMix->mFormat.format = audioFormatToNative(env->GetIntField(jFormat, |
| 1583 | gAudioFormatFields.mEncoding)); |
| 1584 | env->DeleteLocalRef(jFormat); |
| 1585 | |
| 1586 | jobject jRule = env->GetObjectField(jAudioMix, gAudioMixFields.mRule); |
| 1587 | jobject jRuleCriteria = env->GetObjectField(jRule, gAudioMixingRuleFields.mCriteria); |
| 1588 | env->DeleteLocalRef(jRule); |
| 1589 | jobjectArray jCriteria = (jobjectArray)env->CallObjectMethod(jRuleCriteria, |
| 1590 | gArrayListMethods.toArray); |
| 1591 | env->DeleteLocalRef(jRuleCriteria); |
| 1592 | |
| 1593 | jint numCriteria = env->GetArrayLength(jCriteria); |
| 1594 | if (numCriteria > MAX_CRITERIA_PER_MIX) { |
| 1595 | numCriteria = MAX_CRITERIA_PER_MIX; |
| 1596 | } |
| 1597 | |
| 1598 | for (jint i = 0; i < numCriteria; i++) { |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 1599 | AudioMixMatchCriterion nCriterion; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1600 | |
| 1601 | jobject jCriterion = env->GetObjectArrayElement(jCriteria, i); |
| 1602 | |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 1603 | nCriterion.mRule = env->GetIntField(jCriterion, gAudioMixMatchCriterionFields.mRule); |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1604 | |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 1605 | const uint32_t match_rule = nCriterion.mRule & ~RULE_EXCLUSION_MASK; |
| 1606 | switch (match_rule) { |
| 1607 | case RULE_MATCH_UID: |
| 1608 | nCriterion.mValue.mUid = env->GetIntField(jCriterion, |
| 1609 | gAudioMixMatchCriterionFields.mIntProp); |
| 1610 | break; |
| 1611 | case RULE_MATCH_ATTRIBUTE_USAGE: |
| 1612 | case RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET: { |
| 1613 | jobject jAttributes = env->GetObjectField(jCriterion, gAudioMixMatchCriterionFields.mAttr); |
| 1614 | if (match_rule == RULE_MATCH_ATTRIBUTE_USAGE) { |
| 1615 | nCriterion.mValue.mUsage = (audio_usage_t)env->GetIntField(jAttributes, |
| 1616 | gAudioAttributesFields.mUsage); |
| 1617 | } else { |
| 1618 | nCriterion.mValue.mSource = (audio_source_t)env->GetIntField(jAttributes, |
| 1619 | gAudioAttributesFields.mSource); |
| 1620 | } |
| 1621 | env->DeleteLocalRef(jAttributes); |
| 1622 | } |
| 1623 | break; |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1624 | } |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1625 | |
| 1626 | nAudioMix->mCriteria.add(nCriterion); |
| 1627 | env->DeleteLocalRef(jCriterion); |
| 1628 | } |
| 1629 | |
| 1630 | env->DeleteLocalRef(jCriteria); |
| 1631 | |
| 1632 | return (jint)AUDIO_JAVA_SUCCESS; |
| 1633 | } |
| 1634 | |
| 1635 | static jint |
| 1636 | android_media_AudioSystem_registerPolicyMixes(JNIEnv *env, jobject clazz, |
| 1637 | jobject jMixesList, jboolean registration) |
| 1638 | { |
| 1639 | ALOGV("registerPolicyMixes"); |
| 1640 | |
| 1641 | if (jMixesList == NULL) { |
| 1642 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1643 | } |
| 1644 | if (!env->IsInstanceOf(jMixesList, gArrayListClass)) { |
| 1645 | return (jint)AUDIO_JAVA_BAD_VALUE; |
| 1646 | } |
| 1647 | jobjectArray jMixes = (jobjectArray)env->CallObjectMethod(jMixesList, |
| 1648 | gArrayListMethods.toArray); |
| 1649 | jint numMixes = env->GetArrayLength(jMixes); |
| 1650 | if (numMixes > MAX_MIXES_PER_POLICY) { |
| 1651 | numMixes = MAX_MIXES_PER_POLICY; |
| 1652 | } |
| 1653 | |
| 1654 | status_t status; |
| 1655 | jint jStatus; |
| 1656 | jobject jAudioMix = NULL; |
| 1657 | Vector <AudioMix> mixes; |
| 1658 | for (jint i = 0; i < numMixes; i++) { |
| 1659 | jAudioMix = env->GetObjectArrayElement(jMixes, i); |
| 1660 | if (!env->IsInstanceOf(jAudioMix, gAudioMixClass)) { |
| 1661 | jStatus = (jint)AUDIO_JAVA_BAD_VALUE; |
| 1662 | goto exit; |
| 1663 | } |
| 1664 | AudioMix mix; |
| 1665 | jStatus = convertAudioMixToNative(env, &mix, jAudioMix); |
| 1666 | env->DeleteLocalRef(jAudioMix); |
| 1667 | jAudioMix = NULL; |
| 1668 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1669 | goto exit; |
| 1670 | } |
| 1671 | mixes.add(mix); |
| 1672 | } |
| 1673 | |
| 1674 | ALOGV("AudioSystem::registerPolicyMixes numMixes %d registration %d", numMixes, registration); |
| 1675 | status = AudioSystem::registerPolicyMixes(mixes, registration); |
| 1676 | ALOGV("AudioSystem::registerPolicyMixes() returned %d", status); |
| 1677 | |
| 1678 | jStatus = nativeToJavaStatus(status); |
| 1679 | if (jStatus != AUDIO_JAVA_SUCCESS) { |
| 1680 | goto exit; |
| 1681 | } |
| 1682 | |
| 1683 | exit: |
| 1684 | if (jAudioMix != NULL) { |
| 1685 | env->DeleteLocalRef(jAudioMix); |
| 1686 | } |
| 1687 | return jStatus; |
| 1688 | } |
| 1689 | |
Eric Laurent | 0867bed | 2015-05-20 14:49:08 -0700 | [diff] [blame] | 1690 | static jint |
| 1691 | android_media_AudioSystem_systemReady(JNIEnv *env, jobject thiz) |
| 1692 | { |
| 1693 | return nativeToJavaStatus(AudioSystem::systemReady()); |
| 1694 | } |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1695 | |
| 1696 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1697 | // ---------------------------------------------------------------------------- |
| 1698 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 1699 | static const JNINativeMethod gMethods[] = { |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1700 | {"setParameters", "(Ljava/lang/String;)I", (void *)android_media_AudioSystem_setParameters}, |
| 1701 | {"getParameters", "(Ljava/lang/String;)Ljava/lang/String;", (void *)android_media_AudioSystem_getParameters}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1702 | {"muteMicrophone", "(Z)I", (void *)android_media_AudioSystem_muteMicrophone}, |
| 1703 | {"isMicrophoneMuted", "()Z", (void *)android_media_AudioSystem_isMicrophoneMuted}, |
Jean-Michel Trivi | d677054 | 2012-10-10 12:03:41 -0700 | [diff] [blame] | 1704 | {"isStreamActive", "(II)Z", (void *)android_media_AudioSystem_isStreamActive}, |
Jean-Michel Trivi | 679d504 | 2013-02-04 16:24:09 -0800 | [diff] [blame] | 1705 | {"isStreamActiveRemotely","(II)Z", (void *)android_media_AudioSystem_isStreamActiveRemotely}, |
Jean-Michel Trivi | d677054 | 2012-10-10 12:03:41 -0700 | [diff] [blame] | 1706 | {"isSourceActive", "(I)Z", (void *)android_media_AudioSystem_isSourceActive}, |
Jean-Michel Trivi | 8a21f5d | 2014-06-05 15:03:52 -0700 | [diff] [blame] | 1707 | {"newAudioSessionId", "()I", (void *)android_media_AudioSystem_newAudioSessionId}, |
Paul McLean | 10804eb | 2015-01-28 11:16:35 -0800 | [diff] [blame] | 1708 | {"setDeviceConnectionState", "(IILjava/lang/String;Ljava/lang/String;)I", (void *)android_media_AudioSystem_setDeviceConnectionState}, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1709 | {"getDeviceConnectionState", "(ILjava/lang/String;)I", (void *)android_media_AudioSystem_getDeviceConnectionState}, |
| 1710 | {"setPhoneState", "(I)I", (void *)android_media_AudioSystem_setPhoneState}, |
Eric Laurent | a553c25 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 1711 | {"setForceUse", "(II)I", (void *)android_media_AudioSystem_setForceUse}, |
| 1712 | {"getForceUse", "(I)I", (void *)android_media_AudioSystem_getForceUse}, |
| 1713 | {"initStreamVolume", "(III)I", (void *)android_media_AudioSystem_initStreamVolume}, |
Eric Laurent | 9bc8358d | 2011-11-18 16:43:31 -0800 | [diff] [blame] | 1714 | {"setStreamVolumeIndex","(III)I", (void *)android_media_AudioSystem_setStreamVolumeIndex}, |
| 1715 | {"getStreamVolumeIndex","(II)I", (void *)android_media_AudioSystem_getStreamVolumeIndex}, |
Mike Lockwood | cbdb49d | 2011-10-20 12:54:05 -0400 | [diff] [blame] | 1716 | {"setMasterVolume", "(F)I", (void *)android_media_AudioSystem_setMasterVolume}, |
| 1717 | {"getMasterVolume", "()F", (void *)android_media_AudioSystem_getMasterVolume}, |
| 1718 | {"setMasterMute", "(Z)I", (void *)android_media_AudioSystem_setMasterMute}, |
| 1719 | {"getMasterMute", "()Z", (void *)android_media_AudioSystem_getMasterMute}, |
Andy Hung | f04b84d | 2015-12-18 17:33:27 -0800 | [diff] [blame] | 1720 | {"setMasterMono", "(Z)I", (void *)android_media_AudioSystem_setMasterMono}, |
| 1721 | {"getMasterMono", "()Z", (void *)android_media_AudioSystem_getMasterMono}, |
Glenn Kasten | 8b4b97a | 2011-02-04 13:54:26 -0800 | [diff] [blame] | 1722 | {"getDevicesForStream", "(I)I", (void *)android_media_AudioSystem_getDevicesForStream}, |
Glenn Kasten | c6c4365 | 2012-09-24 17:32:30 -0700 | [diff] [blame] | 1723 | {"getPrimaryOutputSamplingRate", "()I", (void *)android_media_AudioSystem_getPrimaryOutputSamplingRate}, |
| 1724 | {"getPrimaryOutputFrameCount", "()I", (void *)android_media_AudioSystem_getPrimaryOutputFrameCount}, |
Oliver Woodman | 61dcdf3 | 2013-06-26 12:43:36 +0100 | [diff] [blame] | 1725 | {"getOutputLatency", "(I)I", (void *)android_media_AudioSystem_getOutputLatency}, |
Glenn Kasten | fd116ad | 2013-07-12 17:10:39 -0700 | [diff] [blame] | 1726 | {"setLowRamDevice", "(Z)I", (void *)android_media_AudioSystem_setLowRamDevice}, |
Eric Laurent | dfb881f | 2013-07-18 14:41:39 -0700 | [diff] [blame] | 1727 | {"checkAudioFlinger", "()I", (void *)android_media_AudioSystem_checkAudioFlinger}, |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1728 | {"listAudioPorts", "(Ljava/util/ArrayList;[I)I", |
| 1729 | (void *)android_media_AudioSystem_listAudioPorts}, |
| 1730 | {"createAudioPatch", "([Landroid/media/AudioPatch;[Landroid/media/AudioPortConfig;[Landroid/media/AudioPortConfig;)I", |
| 1731 | (void *)android_media_AudioSystem_createAudioPatch}, |
| 1732 | {"releaseAudioPatch", "(Landroid/media/AudioPatch;)I", |
| 1733 | (void *)android_media_AudioSystem_releaseAudioPatch}, |
| 1734 | {"listAudioPatches", "(Ljava/util/ArrayList;[I)I", |
| 1735 | (void *)android_media_AudioSystem_listAudioPatches}, |
Eric Laurent | 3a24199 | 2014-05-19 19:33:26 -0700 | [diff] [blame] | 1736 | {"setAudioPortConfig", "(Landroid/media/AudioPortConfig;)I", |
| 1737 | (void *)android_media_AudioSystem_setAudioPortConfig}, |
Eric Laurent | b634e1b | 2014-08-01 14:44:46 -0700 | [diff] [blame] | 1738 | {"getAudioHwSyncForSession", "(I)I", |
| 1739 | (void *)android_media_AudioSystem_getAudioHwSyncForSession}, |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1740 | {"registerPolicyMixes", "(Ljava/util/ArrayList;Z)I", |
| 1741 | (void *)android_media_AudioSystem_registerPolicyMixes}, |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 1742 | {"native_register_dynamic_policy_callback", "()V", |
| 1743 | (void *)android_media_AudioSystem_registerDynPolicyCallback}, |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 1744 | {"native_register_recording_callback", "()V", |
| 1745 | (void *)android_media_AudioSystem_registerRecordingCallback}, |
Eric Laurent | 0867bed | 2015-05-20 14:49:08 -0700 | [diff] [blame] | 1746 | {"systemReady", "()I", (void *)android_media_AudioSystem_systemReady}, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1747 | }; |
| 1748 | |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1749 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 1750 | static const JNINativeMethod gEventHandlerMethods[] = { |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 1751 | {"native_setup", |
| 1752 | "(Ljava/lang/Object;)V", |
| 1753 | (void *)android_media_AudioSystem_eventHandlerSetup}, |
| 1754 | {"native_finalize", |
| 1755 | "()V", |
| 1756 | (void *)android_media_AudioSystem_eventHandlerFinalize}, |
| 1757 | }; |
| 1758 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1759 | int register_android_media_AudioSystem(JNIEnv *env) |
| 1760 | { |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1761 | jclass arrayListClass = FindClassOrDie(env, "java/util/ArrayList"); |
| 1762 | gArrayListClass = MakeGlobalRefOrDie(env, arrayListClass); |
| 1763 | gArrayListMethods.add = GetMethodIDOrDie(env, arrayListClass, "add", "(Ljava/lang/Object;)Z"); |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1764 | gArrayListMethods.toArray = GetMethodIDOrDie(env, arrayListClass, "toArray", "()[Ljava/lang/Object;"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1765 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1766 | jclass audioHandleClass = FindClassOrDie(env, "android/media/AudioHandle"); |
| 1767 | gAudioHandleClass = MakeGlobalRefOrDie(env, audioHandleClass); |
| 1768 | gAudioHandleCstor = GetMethodIDOrDie(env, audioHandleClass, "<init>", "(I)V"); |
| 1769 | gAudioHandleFields.mId = GetFieldIDOrDie(env, audioHandleClass, "mId", "I"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1770 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1771 | jclass audioPortClass = FindClassOrDie(env, "android/media/AudioPort"); |
| 1772 | gAudioPortClass = MakeGlobalRefOrDie(env, audioPortClass); |
| 1773 | gAudioPortCstor = GetMethodIDOrDie(env, audioPortClass, "<init>", |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 1774 | "(Landroid/media/AudioHandle;ILjava/lang/String;[I[I[I[I[Landroid/media/AudioGain;)V"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1775 | gAudioPortFields.mHandle = GetFieldIDOrDie(env, audioPortClass, "mHandle", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1776 | "Landroid/media/AudioHandle;"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1777 | gAudioPortFields.mRole = GetFieldIDOrDie(env, audioPortClass, "mRole", "I"); |
| 1778 | gAudioPortFields.mGains = GetFieldIDOrDie(env, audioPortClass, "mGains", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1779 | "[Landroid/media/AudioGain;"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1780 | gAudioPortFields.mActiveConfig = GetFieldIDOrDie(env, audioPortClass, "mActiveConfig", |
| 1781 | "Landroid/media/AudioPortConfig;"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1782 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1783 | jclass audioPortConfigClass = FindClassOrDie(env, "android/media/AudioPortConfig"); |
| 1784 | gAudioPortConfigClass = MakeGlobalRefOrDie(env, audioPortConfigClass); |
| 1785 | gAudioPortConfigCstor = GetMethodIDOrDie(env, audioPortConfigClass, "<init>", |
| 1786 | "(Landroid/media/AudioPort;IIILandroid/media/AudioGainConfig;)V"); |
| 1787 | gAudioPortConfigFields.mPort = GetFieldIDOrDie(env, audioPortConfigClass, "mPort", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1788 | "Landroid/media/AudioPort;"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1789 | gAudioPortConfigFields.mSamplingRate = GetFieldIDOrDie(env, audioPortConfigClass, |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1790 | "mSamplingRate", "I"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1791 | gAudioPortConfigFields.mChannelMask = GetFieldIDOrDie(env, audioPortConfigClass, |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1792 | "mChannelMask", "I"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1793 | gAudioPortConfigFields.mFormat = GetFieldIDOrDie(env, audioPortConfigClass, "mFormat", "I"); |
| 1794 | gAudioPortConfigFields.mGain = GetFieldIDOrDie(env, audioPortConfigClass, "mGain", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1795 | "Landroid/media/AudioGainConfig;"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1796 | gAudioPortConfigFields.mConfigMask = GetFieldIDOrDie(env, audioPortConfigClass, "mConfigMask", |
| 1797 | "I"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1798 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1799 | jclass audioDevicePortConfigClass = FindClassOrDie(env, "android/media/AudioDevicePortConfig"); |
| 1800 | gAudioDevicePortConfigClass = MakeGlobalRefOrDie(env, audioDevicePortConfigClass); |
| 1801 | gAudioDevicePortConfigCstor = GetMethodIDOrDie(env, audioDevicePortConfigClass, "<init>", |
| 1802 | "(Landroid/media/AudioDevicePort;IIILandroid/media/AudioGainConfig;)V"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1803 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1804 | jclass audioMixPortConfigClass = FindClassOrDie(env, "android/media/AudioMixPortConfig"); |
| 1805 | gAudioMixPortConfigClass = MakeGlobalRefOrDie(env, audioMixPortConfigClass); |
| 1806 | gAudioMixPortConfigCstor = GetMethodIDOrDie(env, audioMixPortConfigClass, "<init>", |
| 1807 | "(Landroid/media/AudioMixPort;IIILandroid/media/AudioGainConfig;)V"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1808 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1809 | jclass audioDevicePortClass = FindClassOrDie(env, "android/media/AudioDevicePort"); |
| 1810 | gAudioDevicePortClass = MakeGlobalRefOrDie(env, audioDevicePortClass); |
| 1811 | gAudioDevicePortCstor = GetMethodIDOrDie(env, audioDevicePortClass, "<init>", |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 1812 | "(Landroid/media/AudioHandle;Ljava/lang/String;[I[I[I[I[Landroid/media/AudioGain;ILjava/lang/String;)V"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1813 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1814 | jclass audioMixPortClass = FindClassOrDie(env, "android/media/AudioMixPort"); |
| 1815 | gAudioMixPortClass = MakeGlobalRefOrDie(env, audioMixPortClass); |
| 1816 | gAudioMixPortCstor = GetMethodIDOrDie(env, audioMixPortClass, "<init>", |
Paul McLean | f29e5f3 | 2015-06-15 10:19:22 -0700 | [diff] [blame] | 1817 | "(Landroid/media/AudioHandle;IILjava/lang/String;[I[I[I[I[Landroid/media/AudioGain;)V"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1818 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1819 | jclass audioGainClass = FindClassOrDie(env, "android/media/AudioGain"); |
| 1820 | gAudioGainClass = MakeGlobalRefOrDie(env, audioGainClass); |
| 1821 | gAudioGainCstor = GetMethodIDOrDie(env, audioGainClass, "<init>", "(IIIIIIIII)V"); |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1822 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1823 | jclass audioGainConfigClass = FindClassOrDie(env, "android/media/AudioGainConfig"); |
| 1824 | gAudioGainConfigClass = MakeGlobalRefOrDie(env, audioGainConfigClass); |
| 1825 | gAudioGainConfigCstor = GetMethodIDOrDie(env, audioGainConfigClass, "<init>", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1826 | "(ILandroid/media/AudioGain;II[II)V"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1827 | gAudioGainConfigFields.mIndex = GetFieldIDOrDie(env, gAudioGainConfigClass, "mIndex", "I"); |
| 1828 | gAudioGainConfigFields.mMode = GetFieldIDOrDie(env, audioGainConfigClass, "mMode", "I"); |
| 1829 | gAudioGainConfigFields.mChannelMask = GetFieldIDOrDie(env, audioGainConfigClass, "mChannelMask", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1830 | "I"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1831 | gAudioGainConfigFields.mValues = GetFieldIDOrDie(env, audioGainConfigClass, "mValues", "[I"); |
| 1832 | gAudioGainConfigFields.mRampDurationMs = GetFieldIDOrDie(env, audioGainConfigClass, |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1833 | "mRampDurationMs", "I"); |
| 1834 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1835 | jclass audioPatchClass = FindClassOrDie(env, "android/media/AudioPatch"); |
| 1836 | gAudioPatchClass = MakeGlobalRefOrDie(env, audioPatchClass); |
| 1837 | gAudioPatchCstor = GetMethodIDOrDie(env, audioPatchClass, "<init>", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1838 | "(Landroid/media/AudioHandle;[Landroid/media/AudioPortConfig;[Landroid/media/AudioPortConfig;)V"); |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1839 | gAudioPatchFields.mHandle = GetFieldIDOrDie(env, audioPatchClass, "mHandle", |
Eric Laurent | b69681c | 2014-05-19 19:02:51 -0700 | [diff] [blame] | 1840 | "Landroid/media/AudioHandle;"); |
| 1841 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1842 | jclass eventHandlerClass = FindClassOrDie(env, kEventHandlerClassPathName); |
Eric Laurent | 2615afb | 2015-03-25 14:51:08 -0700 | [diff] [blame] | 1843 | gAudioPortEventHandlerMethods.postEventFromNative = GetStaticMethodIDOrDie( |
| 1844 | env, eventHandlerClass, "postEventFromNative", |
| 1845 | "(Ljava/lang/Object;IIILjava/lang/Object;)V"); |
| 1846 | gEventHandlerFields.mJniCallback = GetFieldIDOrDie(env, |
| 1847 | eventHandlerClass, "mJniCallback", "J"); |
Eric Laurent | 700e734 | 2014-05-02 18:33:15 -0700 | [diff] [blame] | 1848 | |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 1849 | gAudioPolicyEventHandlerMethods.postDynPolicyEventFromNative = |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 1850 | GetStaticMethodIDOrDie(env, env->FindClass(kClassPathName), |
| 1851 | "dynamicPolicyCallbackFromNative", "(ILjava/lang/String;I)V"); |
Jean-Michel Trivi | d3c71f0 | 2015-12-07 11:59:31 -0800 | [diff] [blame] | 1852 | gAudioPolicyEventHandlerMethods.postRecordConfigEventFromNative = |
| 1853 | GetStaticMethodIDOrDie(env, env->FindClass(kClassPathName), |
Jean-Michel Trivi | 33fd816 | 2016-02-22 10:52:41 -0800 | [diff] [blame] | 1854 | "recordingCallbackFromNative", "(III[I)V"); |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 1855 | |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1856 | jclass audioMixClass = FindClassOrDie(env, "android/media/audiopolicy/AudioMix"); |
| 1857 | gAudioMixClass = MakeGlobalRefOrDie(env, audioMixClass); |
| 1858 | gAudioMixFields.mRule = GetFieldIDOrDie(env, audioMixClass, "mRule", |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1859 | "Landroid/media/audiopolicy/AudioMixingRule;"); |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1860 | gAudioMixFields.mFormat = GetFieldIDOrDie(env, audioMixClass, "mFormat", |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1861 | "Landroid/media/AudioFormat;"); |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1862 | gAudioMixFields.mRouteFlags = GetFieldIDOrDie(env, audioMixClass, "mRouteFlags", "I"); |
Jean-Michel Trivi | 4ad3988 | 2016-03-14 18:46:41 -0700 | [diff] [blame^] | 1863 | gAudioMixFields.mDeviceType = GetFieldIDOrDie(env, audioMixClass, "mDeviceSystemType", "I"); |
| 1864 | gAudioMixFields.mDeviceAddress = GetFieldIDOrDie(env, audioMixClass, "mDeviceAddress", |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1865 | "Ljava/lang/String;"); |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1866 | gAudioMixFields.mMixType = GetFieldIDOrDie(env, audioMixClass, "mMixType", "I"); |
Jean-Michel Trivi | 5a56109 | 2015-04-23 18:48:08 -0700 | [diff] [blame] | 1867 | gAudioMixFields.mCallbackFlags = GetFieldIDOrDie(env, audioMixClass, "mCallbackFlags", "I"); |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1868 | |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1869 | jclass audioFormatClass = FindClassOrDie(env, "android/media/AudioFormat"); |
| 1870 | gAudioFormatClass = MakeGlobalRefOrDie(env, audioFormatClass); |
| 1871 | gAudioFormatFields.mEncoding = GetFieldIDOrDie(env, audioFormatClass, "mEncoding", "I"); |
| 1872 | gAudioFormatFields.mSampleRate = GetFieldIDOrDie(env, audioFormatClass, "mSampleRate", "I"); |
| 1873 | gAudioFormatFields.mChannelMask = GetFieldIDOrDie(env, audioFormatClass, "mChannelMask", "I"); |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1874 | |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1875 | jclass audioMixingRuleClass = FindClassOrDie(env, "android/media/audiopolicy/AudioMixingRule"); |
| 1876 | gAudioMixingRuleClass = MakeGlobalRefOrDie(env, audioMixingRuleClass); |
| 1877 | gAudioMixingRuleFields.mCriteria = GetFieldIDOrDie(env, audioMixingRuleClass, "mCriteria", |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1878 | "Ljava/util/ArrayList;"); |
| 1879 | |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 1880 | jclass audioMixMatchCriterionClass = |
| 1881 | FindClassOrDie(env, "android/media/audiopolicy/AudioMixingRule$AudioMixMatchCriterion"); |
| 1882 | gAudioMixMatchCriterionClass = MakeGlobalRefOrDie(env,audioMixMatchCriterionClass); |
| 1883 | gAudioMixMatchCriterionFields.mAttr = GetFieldIDOrDie(env, audioMixMatchCriterionClass, "mAttr", |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1884 | "Landroid/media/AudioAttributes;"); |
Jean-Michel Trivi | ba6b4b4 | 2016-02-10 14:26:35 -0800 | [diff] [blame] | 1885 | gAudioMixMatchCriterionFields.mIntProp = GetFieldIDOrDie(env, audioMixMatchCriterionClass, "mIntProp", |
| 1886 | "I"); |
| 1887 | gAudioMixMatchCriterionFields.mRule = GetFieldIDOrDie(env, audioMixMatchCriterionClass, "mRule", |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1888 | "I"); |
| 1889 | |
Eric Laurent | 0937897 | 2014-12-10 10:42:08 -0800 | [diff] [blame] | 1890 | jclass audioAttributesClass = FindClassOrDie(env, "android/media/AudioAttributes"); |
| 1891 | gAudioAttributesClass = MakeGlobalRefOrDie(env, audioAttributesClass); |
| 1892 | gAudioAttributesFields.mUsage = GetFieldIDOrDie(env, audioAttributesClass, "mUsage", "I"); |
| 1893 | gAudioAttributesFields.mSource = GetFieldIDOrDie(env, audioAttributesClass, "mSource", "I"); |
Eric Laurent | 7f5eb9f | 2014-12-01 19:36:30 -0800 | [diff] [blame] | 1894 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1895 | AudioSystem::setErrorCallback(android_media_AudioSystem_error_callback); |
Glenn Kasten | 18db49a | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 1896 | |
Andreas Gampe | ed6b9df | 2014-11-20 22:02:20 -0800 | [diff] [blame] | 1897 | RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods)); |
| 1898 | return RegisterMethodsOrDie(env, kEventHandlerClassPathName, gEventHandlerMethods, |
| 1899 | NELEM(gEventHandlerMethods)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1900 | } |