From 92de18672779ebd6b6556b12fbd48ff540caf75d Mon Sep 17 00:00:00 2001 From: Gabor Szanto Date: Wed, 11 Nov 2015 15:26:52 +0100 Subject: [PATCH] Version 1.4.2 Minor bug fix and easier ndk config. --- Android/app/build.gradle | 9 +++++---- Android/app/src/main/jni/SuperpoweredLatency.cpp | 3 +-- Android/app/src/main/jni/latencyMeasurer.cpp | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Android/app/build.gradle b/Android/app/build.gradle index cc7f2d2..5bc688f 100644 --- a/Android/app/build.gradle +++ b/Android/app/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion 11 targetSdkVersion 21 versionCode 3 - versionName "1.4" + versionName "1.4.2" sourceSets.main { jniLibs.srcDir 'src/main/libs' @@ -24,9 +24,10 @@ android { } } task ndkBuild(type: Exec) { - commandLine '/android/ndk/ndk-build', '-B', '-C', file('src/main/jni').absolutePath -// Windows users: -// commandLine 'C:\\Android\\ndk\\ndk-build.cmd', '-B', '-C', file('src/main/jni').absolutePath + Properties properties = new Properties() + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + def ndkDir = properties.getProperty('ndk.dir') + commandLine "$ndkDir/ndk-build", '-B', '-C', file('src/main/jni').absolutePath } lintOptions { diff --git a/Android/app/src/main/jni/SuperpoweredLatency.cpp b/Android/app/src/main/jni/SuperpoweredLatency.cpp index bfd58e8..4b69473 100644 --- a/Android/app/src/main/jni/SuperpoweredLatency.cpp +++ b/Android/app/src/main/jni/SuperpoweredLatency.cpp @@ -118,15 +118,14 @@ JNIEXPORT void Java_com_superpowered_superpoweredlatency_MainActivity_Superpower SLDataSink inputSink = { &inputLocator, &inputFormat }; const SLInterfaceID inputInterfaces[1] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE }; (*openSLEngineInterface)->CreateAudioRecorder(openSLEngineInterface, &inputBufferQueue, &inputSource, &inputSink, 1, inputInterfaces, requireds); - (*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE); // Configure the voice recognition preset which has no signal processing for lower latency. SLAndroidConfigurationItf inputConfiguration; if ((*inputBufferQueue)->GetInterface(inputBufferQueue, SL_IID_ANDROIDCONFIGURATION, &inputConfiguration) == SL_RESULT_SUCCESS) { SLuint32 presetValue = SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION; (*inputConfiguration)->SetConfiguration(inputConfiguration, SL_ANDROID_KEY_RECORDING_PRESET, &presetValue, sizeof(SLuint32)); - (*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE); }; + (*inputBufferQueue)->Realize(inputBufferQueue, SL_BOOLEAN_FALSE); // Create the output buffer queue. SLDataLocator_AndroidSimpleBufferQueue outputLocator = { SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, 1 }; diff --git a/Android/app/src/main/jni/latencyMeasurer.cpp b/Android/app/src/main/jni/latencyMeasurer.cpp index a96b97a..23ae749 100644 --- a/Android/app/src/main/jni/latencyMeasurer.cpp +++ b/Android/app/src/main/jni/latencyMeasurer.cpp @@ -29,7 +29,8 @@ static int sumAudio(short int *audio, int numberOfSamples) { int sum = 0; while (numberOfSamples) { numberOfSamples--; - sum += abs(*audio++) + abs(*audio++); + sum += abs(audio[0]) + abs(audio[1]); + audio += 2; }; return sum; }