aboutsummaryrefslogtreecommitdiff
path: root/externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2025-08-04 04:50:14 +0200
committercrueter <crueter@eden-emu.dev>2025-08-04 04:50:14 +0200
commit51b170b470ed587f99a7c2a773e4464687f0d07a (patch)
tree4c03c510cfb17a5f5d6233df490d78f06dcfa7f7 /externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp
parent04e5e6453875ffa5c79cdb421a29bc19985b1049 (diff)
[cmake] refactor: Use CPM over submodules (#143)
Transfers the majority of submodules and large externals to CPM, using source archives rather than full Git clones. Not only does this save massive amounts of clone and configure time, but dependencies are grabbed on-demand rather than being required by default. Additionally, CPM will (generally) automatically search for system dependencies, though certain dependencies have options to control this. Testing shows gains ranging from 5x to 10x in terms of overall clone/configure time. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/143 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp')
-rw-r--r--externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp160
1 files changed, 0 insertions, 160 deletions
diff --git a/externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp b/externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp
deleted file mode 100644
index 165de68bac..0000000000
--- a/externals/oboe/apps/fxlab/app/src/main/cpp/native-lib.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2019 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <jni.h>
-
-#include <cassert>
-#include <string>
-#include <functional>
-#include <utility>
-#include <vector>
-
-#include "DuplexEngine.h"
-#include "effects/Effects.h"
-#include "FunctionList.h"
-
-
-// JNI Utility functions and globals
-static DuplexEngine *enginePtr = nullptr;
-
-// Actual JNI interface
-extern "C" {
-
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_createAudioEngine(
- JNIEnv,
- jobject /* this */) {
- enginePtr = new DuplexEngine();
-}
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_destroyAudioEngine(
- JNIEnv,
- jobject /* this */) {
- if (!enginePtr) return;
- delete enginePtr;
- enginePtr = nullptr;
-}
-
-JNIEXPORT jobjectArray JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_getEffects(JNIEnv *env, jobject) {
- jclass jcl = env->FindClass("com/mobileer/androidfxlab/datatype/EffectDescription");
- jclass jparamcl = env->FindClass("com/mobileer/androidfxlab/datatype/ParamDescription");
- assert (jcl != nullptr && jparamcl != nullptr);
-
- auto jparamMethodId = env->GetMethodID(jparamcl, "<init>", "(Ljava/lang/String;FFF)V");
- auto jMethodId = env->GetMethodID(jcl, "<init>",
- "(Ljava/lang/String;Ljava/lang/String;I[Lcom/mobileer/androidfxlab/datatype/ParamDescription;)V");
-
- auto arr = env->NewObjectArray(numEffects, jcl, nullptr);
- auto lambda = [&](auto &arg, int i) {
- const auto &paramArr = arg.getParams();
- auto jparamArr = env->NewObjectArray(paramArr.size(), jparamcl, nullptr);
- int c = 0;
- for (auto const &elem: paramArr) {
- jobject j = env->NewObject(jparamcl, jparamMethodId,
- env->NewStringUTF(std::string(elem.kName).c_str()),
- elem.kMinVal, elem.kMaxVal, elem.kDefVal);
- assert(j != nullptr);
- env->SetObjectArrayElement(jparamArr, c++, j);
- }
- jobject j = env->NewObject(jcl, jMethodId,
- env->NewStringUTF(std::string(arg.getName()).c_str()),
- env->NewStringUTF(std::string(arg.getCategory()).c_str()),
- i, jparamArr);
- assert(j != nullptr);
- env->SetObjectArrayElement(arr, i, j);
- };
- int i = 0;
- std::apply([&i, &lambda](auto &&... args) mutable { ((lambda(args, i++)), ...); },
- EffectsTuple);
- return arr;
-}
-
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_addDefaultEffectNative(JNIEnv *, jobject, jint jid) {
- if (!enginePtr) return;
- auto id = static_cast<int>(jid);
-
- std::visit([id](auto &&stack) {
- std::function<void(decltype(stack.getType()), decltype(stack.getType()))> f;
- int i = 0;
- std::apply([id, &f, &i](auto &&... args) mutable {
- ((f = (i++ == id) ?
- args.template buildDefaultEffect<decltype(stack.getType())>() : f), ...);
- }, EffectsTuple);
- stack.addEffect(std::move(f));
- }, enginePtr->functionList);
-}
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_removeEffectNative(JNIEnv *, jobject, jint jind) {
- if (!enginePtr) return;
- auto ind = static_cast<size_t>(jind);
- std::visit([ind](auto &&arg) {
- arg.removeEffectAt(ind);
- }, enginePtr->functionList);
-}
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_rotateEffectNative(JNIEnv *, jobject,
- jint jfrom, jint jto) {
- if (!enginePtr) return;
- auto from = static_cast<size_t>(jfrom);
- auto to = static_cast<size_t>(jto);
-
- std::visit([from, to](auto &&arg) {
- arg.rotateEffectAt(from, to);
- }, enginePtr->functionList);
-}
-
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_modifyEffectNative(
- JNIEnv *env, jobject, jint jid, jint jindex, jfloatArray params) {
- if (!enginePtr) return;
- int id = static_cast<int>(jid);
- int index = static_cast<size_t>(jindex);
-
- jfloat *data = env->GetFloatArrayElements(params, nullptr);
- std::vector<float> arr{data, data + env->GetArrayLength(params)};
- env->ReleaseFloatArrayElements(params, data, 0);
- std::visit([&arr, &id, &index](auto &&stack) {
- std::function<void(decltype(stack.getType()), decltype(stack.getType()))> ef;
- int i = 0;
- std::apply([&](auto &&... args) mutable {
- ((ef = (i++ == id) ?
- args.modifyEffectVec(ef, arr) : ef), ...);
- }, EffectsTuple);
- stack.modifyEffectAt(index, std::move(ef));
- }, enginePtr->functionList);
-}
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_enableEffectNative(
- JNIEnv *, jobject, jint jindex, jboolean jenable) {
- if (!enginePtr) return;
- auto ind = static_cast<size_t>(jindex);
- auto enable = static_cast<bool>(jenable);
- std::visit([ind, enable](auto &&args) {
- args.enableEffectAt(ind, enable);
- }, enginePtr->functionList);
-}
-JNIEXPORT void JNICALL
-Java_com_mobileer_androidfxlab_NativeInterface_enablePassthroughNative(
- JNIEnv *, jobject, jboolean jenable) {
- if (!enginePtr) return;
- std::visit([enable = static_cast<bool>(jenable)](auto &&args) {
- args.mute(!enable);
- }, enginePtr->functionList);
-}
-} //extern C
-