55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
|
|
// Write C++ code here.
|
||
|
|
//
|
||
|
|
// Do not forget to dynamically load the C++ library into your application.
|
||
|
|
//
|
||
|
|
// For instance,
|
||
|
|
//
|
||
|
|
// In at.lockstep.app.MainActivity.java:
|
||
|
|
// static {
|
||
|
|
// System.loadLibrary("lockstep");
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// Or, in at.lockstep.app.MainActivity.kt:
|
||
|
|
// companion object {
|
||
|
|
// init {
|
||
|
|
// System.loadLibrary("lockstep")
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
#include "PlaybackEngine.h"
|
||
|
|
#include <jni.h>
|
||
|
|
#include <oboe/Oboe.h>
|
||
|
|
|
||
|
|
extern "C" {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Creates the audio engine
|
||
|
|
*
|
||
|
|
* @return a pointer to the audio engine. This should be passed to other methods
|
||
|
|
*/
|
||
|
|
JNIEXPORT jlong JNICALL
|
||
|
|
Java_at_lockstep_pb_PlaybackEngine_native_1createEngine(
|
||
|
|
JNIEnv *env,
|
||
|
|
jclass /*unused*/) {
|
||
|
|
/*
|
||
|
|
const char* filesDirTemp = env->GetStringUTFChars(filesDir, NULL);
|
||
|
|
std::string filesDirString(filesDirTemp);
|
||
|
|
env->ReleaseStringUTFChars(filesDir, filesDirTemp);
|
||
|
|
*/
|
||
|
|
|
||
|
|
// We use std::nothrow so `new` returns a nullptr if the engine creation fails
|
||
|
|
auto *engine = new(std::nothrow) PlaybackEngine();
|
||
|
|
return reinterpret_cast<jlong>(engine);
|
||
|
|
}
|
||
|
|
|
||
|
|
JNIEXPORT void JNICALL
|
||
|
|
Java_at_lockstep_pb_PlaybackEngine_native_1deleteEngine(
|
||
|
|
JNIEnv *env,
|
||
|
|
jclass,
|
||
|
|
jlong engineHandle) {
|
||
|
|
|
||
|
|
delete reinterpret_cast<PlaybackEngine *>(engineHandle);
|
||
|
|
}
|
||
|
|
|
||
|
|
} // extern "C"
|