1 /*
2  * Copyright 2021 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 #include <jni.h>
17 
18 #include <android/log.h>
19 
20 #include <oboe/Oboe.h>
21 #include <aaudio/AAudioExtensions.h>
22 
23 static const char * const TAG = "Globals(native)";
24 
25 using namespace oboe;
26 
27 extern "C" {
28 
29 JNIEXPORT void JNICALL
Java_org_hyphonate_megaaudio_common_Globals_setOboeWorkaroundsEnabled(JNIEnv * env,jclass clazz,jboolean enabled)30 Java_org_hyphonate_megaaudio_common_Globals_setOboeWorkaroundsEnabled(
31         JNIEnv *env, jclass clazz, jboolean enabled) {
32     oboe::OboeGlobals::setWorkaroundsEnabled(enabled);
33 }
34 
35 JNIEXPORT jboolean JNICALL
Java_org_hyphonate_megaaudio_common_Globals_isMMapSupported(JNIEnv * env,jclass clazz)36 Java_org_hyphonate_megaaudio_common_Globals_isMMapSupported(JNIEnv *env, jclass clazz) {
37     return AAudioExtensions::getInstance().isMMapSupported();
38 }
39 
40 JNIEXPORT jboolean JNICALL
Java_org_hyphonate_megaaudio_common_Globals_isMMapExclusiveSupported(JNIEnv * env,jclass clazz)41 Java_org_hyphonate_megaaudio_common_Globals_isMMapExclusiveSupported(JNIEnv *env, jclass clazz) {
42     return AAudioExtensions::getInstance().isMMapExclusiveSupported();
43 }
44 
45 JNIEXPORT void JNICALL
Java_org_hyphonate_megaaudio_common_Globals_setMMapEnabled(JNIEnv * env,jclass clazz,jboolean enabled)46 Java_org_hyphonate_megaaudio_common_Globals_setMMapEnabled(
47         JNIEnv *env, jclass clazz, jboolean enabled) {
48     AAudioExtensions::getInstance().setMMapEnabled(enabled);
49 }
50 
51 JNIEXPORT jboolean JNICALL
Java_org_hyphonate_megaaudio_common_Globals_isMMapEnabled(JNIEnv * env,jclass clazz)52 Java_org_hyphonate_megaaudio_common_Globals_isMMapEnabled(
53         JNIEnv *env, jclass clazz) {
54     return AAudioExtensions::getInstance().isMMapEnabled();
55 }
56 
57 }
58