feat: audio resources
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include "PlaybackEngine.h"
|
||||
#include "logging.h"
|
||||
|
||||
PlaybackEngine::PlaybackEngine() {
|
||||
PlaybackEngine::PlaybackEngine(std::string filesDir): mFilesDir(filesDir) {
|
||||
LOGI("PlaybackEngine()");
|
||||
LOGI("NDK LOG_LEVEL=%d", LOG_LEVEL);
|
||||
// NDK LOG_LEVEL=3 (DEBUG)
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
#define LOCKSTEP_PLAYBACKENGINE_H
|
||||
|
||||
#include "OboeSinePlayer.h"
|
||||
#include <string>
|
||||
|
||||
class PlaybackEngine {
|
||||
public:
|
||||
PlaybackEngine();
|
||||
PlaybackEngine(std::string filesDir);
|
||||
virtual ~PlaybackEngine();
|
||||
private:
|
||||
OboeSinePlayer *mPlayer;
|
||||
std::string mFilesDir;
|
||||
};
|
||||
|
||||
#endif //LOCKSTEP_PLAYBACKENGINE_H
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
#include <jni.h>
|
||||
#include "mpg123.h"
|
||||
#include <oboe/Oboe.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
// nice-to: merge with lockstep.cpp
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_at_lockstep_pb_PlaybackEngine_native_1mpg123_1init
|
||||
(JNIEnv *env, jclass) {
|
||||
|
||||
@@ -30,15 +30,13 @@ extern "C" {
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_at_lockstep_pb_PlaybackEngine_native_1createEngine(
|
||||
JNIEnv *env,
|
||||
jclass /*unused*/) {
|
||||
/*
|
||||
jclass /*unused*/, jstring filesDir) {
|
||||
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();
|
||||
auto *engine = new(std::nothrow) PlaybackEngine(filesDirString);
|
||||
return reinterpret_cast<jlong>(engine);
|
||||
}
|
||||
|
||||
@@ -51,4 +49,13 @@ jlong engineHandle) {
|
||||
delete reinterpret_cast<PlaybackEngine *>(engineHandle);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_at_lockstep_pb_PlaybackEngine_native_1setDefaultStreamValues(JNIEnv *env,
|
||||
jclass type,
|
||||
jint sampleRate,
|
||||
jint framesPerBurst) {
|
||||
oboe::DefaultStreamValues::SampleRate = (int32_t) sampleRate;
|
||||
oboe::DefaultStreamValues::FramesPerBurst = (int32_t) framesPerBurst;
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user