blob: 5f39f7efb6a2e9e508cee4e2263bc9618ddd91ba [file] [log] [blame]
Jean-Michel Trivi21cd5412019-10-30 08:16:51 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "core_jni_helpers.h"
18#include "android_media_AudioDeviceAddress.h"
19#include "android_media_AudioErrors.h"
20
21#include <media/AudioDeviceTypeAddr.h>
22
23using namespace android;
24
25static jclass gAudioDeviceAddressClass;
26static jmethodID gAudioDeviceAddressCstor;
27
28namespace android {
29
30jint createAudioDeviceAddressFromNative(
31 JNIEnv *env, jobject *jAudioDeviceAddress,
32 const AudioDeviceTypeAddr *devTypeAddr) {
33 jint jStatus = (jint)AUDIO_JAVA_SUCCESS;
34 jint jNativeType = (jint)devTypeAddr->mType;
35 ScopedLocalRef<jstring> jAddress(env, env->NewStringUTF(devTypeAddr->mAddress.data()));
36
37 *jAudioDeviceAddress = env->NewObject(gAudioDeviceAddressClass, gAudioDeviceAddressCstor,
38 jNativeType, jAddress.get());
39
40 return jStatus;
41}
42
43}
44
45int register_android_media_AudioDeviceAddress(JNIEnv *env)
46{
47 jclass audioDeviceTypeAddressClass = FindClassOrDie(env, "android/media/AudioDeviceAddress");
48 gAudioDeviceAddressClass = MakeGlobalRefOrDie(env, audioDeviceTypeAddressClass);
49 gAudioDeviceAddressCstor = GetMethodIDOrDie(env, audioDeviceTypeAddressClass, "<init>",
50 "(ILjava/lang/String;)V");
51
52 return 0;
53}