From 6755b249148a3b8c6d12c01f03259ea5ba62f8a4 Mon Sep 17 00:00:00 2001 From: Tim Schneeberger Date: Wed, 2 Aug 2023 14:16:19 +0200 Subject: [PATCH] Squashed 'libjamesdsp/subtree/' changes from ede2c23..227f6b4 227f6b4 Update jdspController.c 05962f2 Update jdspController.c 26e580b Fix weird linking issue with Android's NDK git-subtree-dir: libjamesdsp/subtree git-subtree-split: 227f6b477c3965b53024e2750c42a7d6bb9cd883 --- .../jni/jamesdsp/jdsp/jdspController.c | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Main/libjamesdsp/jni/jamesdsp/jdsp/jdspController.c b/Main/libjamesdsp/jni/jamesdsp/jdsp/jdspController.c index 0036d662..364c65f9 100644 --- a/Main/libjamesdsp/jni/jamesdsp/jdsp/jdspController.c +++ b/Main/libjamesdsp/jni/jamesdsp/jdsp/jdspController.c @@ -8,6 +8,15 @@ #include "Effects/eel2/ns-eel.h" #include "jdsp_header.h" #define TAG "EffectDSPMain" + +#ifdef __ANDROID_API__ +#if __ANDROID_API__ < __ANDROID_API_J_MR2__ +double log2(double x) { + return (log(x)*1.4426950408889634); +} +#endif +#endif + // Range: 0x800000, 0x7fffff int32_t i32_from_p24_big_endian(const uint8_t *packed24) { @@ -107,6 +116,7 @@ double getProcTime(int flen, int num, double dur) free(y); return t_diff / (double)counter; } +char benchmarkEnable = 0; char benchmarkCompletionFlag = 0; double convbench_c0[MAX_BENCHMARK] = { 2.4999999e-05f,4.9999999e-05f,9.9999997e-05f,0.0002f,0.0005f,0.001f,0.0021f,0.0057f,0.0126f,0.0293f }; double convbench_c1[MAX_BENCHMARK] = { 3.1249999e-06f,6.2499998e-06f,1.2500000e-05f,2.4999999e-05f,4.9999999e-05f,9.9999997e-05f,0.0002f,0.0004f,0.0009f,0.0019f }; @@ -200,6 +210,7 @@ void JamesDSPGlobalMemoryAllocation(int do_benchmark) { benchmarkCompletionFlag = 0; NSEEL_start(); + benchmarkEnable = do_benchmark; if(do_benchmark) { pthread_t benchmarkThread; pthread_create(&benchmarkThread, NULL, convBench, 0); @@ -247,6 +258,14 @@ void JamesDSPReallocateBlock(JamesDSPLib *jdsp, size_t n) } void JamesDSPRefreshConvolutions(JamesDSPLib *jdsp, char refreshAll) { + // Temporary(?) bug fix when benchmarks are off + if(!benchmarkEnable) { +#ifdef DEBUG + __android_log_print(ANDROID_LOG_INFO, TAG, "ignoring call to JamesDSPRefreshConvolutions(...) because benchmarks are disabled"); +#endif + return; + } + #ifdef DEBUG __android_log_print(ANDROID_LOG_INFO, TAG, "Buffer size changed, update convolution object to maximize performance"); #endif @@ -876,6 +895,7 @@ void pfloat32Multiplexed(JamesDSPLib *jdsp, float *x, float *y, size_t n) if (jdsp->blockSize != n) { jdsp->blockSize = n; + JamesDSPRefreshConvolutions(jdsp, 1); } for (size_t i = 0; i < n; i++) @@ -1225,4 +1245,4 @@ void JamesDSPFree(JamesDSPLib *jdsp) FreeIntegerASRCHandler(&jdsp->asrc[1]); } jdsp_unlock(jdsp); -} \ No newline at end of file +}