feat: audio resources

This commit is contained in:
2026-03-03 12:04:17 +01:00
parent d2c9a7b2ff
commit bc8002fd59
7 changed files with 109 additions and 9 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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) {

View File

@@ -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"