1 /*
2 * Copyright (C) 2018 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 #define TAG "NativeMidiManager-JNI"
17
18 #include <android/log.h>
19 #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
20
21 #include <amidi/AMidi.h>
22
23 #include "MidiTestManager.h"
24
25 static MidiTestManager sTestManager;
26
27 static bool DEBUG = false;
28
29 extern "C" {
30
Java_com_android_cts_verifier_audio_midilib_NativeMidiManager_initN(JNIEnv * env,jobject midiTestModule)31 void Java_com_android_cts_verifier_audio_midilib_NativeMidiManager_initN(
32 JNIEnv* env, jobject midiTestModule) {
33
34 sTestManager.jniSetup(env);
35 }
36
Java_com_android_cts_verifier_audio_midilib_NativeMidiManager_startTest(JNIEnv * env,jobject thiz,jobject testModuleObj,jobject midiObj)37 void Java_com_android_cts_verifier_audio_midilib_NativeMidiManager_startTest(
38 JNIEnv* env, jobject thiz, jobject testModuleObj, jobject midiObj) {
39
40 (void)thiz;
41
42 if (DEBUG) {
43 ALOGI("NativeMidiManager_startTest(%p, %p)", testModuleObj, midiObj);
44 }
45
46 media_status_t status;
47
48 AMidiDevice* nativeMidiDevice = NULL;
49 status = AMidiDevice_fromJava(env, midiObj, &nativeMidiDevice);
50 if (DEBUG) {
51 ALOGI("nativeSendDevice:%p, status:%d", nativeMidiDevice, status);
52 }
53
54 sTestManager.RunTest(testModuleObj, nativeMidiDevice, nativeMidiDevice);
55
56 status = AMidiDevice_release(nativeMidiDevice);
57 if (DEBUG) {
58 ALOGI("device release status:%d", status);
59 }
60 }
61
62 } // extern "C"
63