Просмотр исходного кода

Update OpenAL-soft to 1.21.0

This allows OpenAL-soft to use Oboe backend which uses AAudio in Android 8
or OpenSLES in earlier Android version. This switch is necessary for
Android 11 compatibility as OpenSLES is now deprecated in Android 11.

Plus, we also have low latency audio for free.
Miku AuahDark 5 лет назад
Родитель
Сommit
dfe836d39c
100 измененных файлов с 13056 добавлено и 0 удалено
  1. 6 0
      love/src/jni/oboe/.gitignore
  2. 30 0
      love/src/jni/oboe/.travis.yml
  3. 9 0
      love/src/jni/oboe/AUTHORS
  4. 84 0
      love/src/jni/oboe/Android.mk
  5. 92 0
      love/src/jni/oboe/CMakeLists.txt
  6. 1 0
      love/src/jni/oboe/CONTRIBUTING
  7. 25 0
      love/src/jni/oboe/CONTRIBUTING.md
  8. 14 0
      love/src/jni/oboe/CONTRIBUTORS
  9. 2482 0
      love/src/jni/oboe/Doxyfile
  10. 202 0
      love/src/jni/oboe/LICENSE
  11. 1 0
      love/src/jni/oboe/README
  12. 53 0
      love/src/jni/oboe/README.md
  13. 11 0
      love/src/jni/oboe/apps/OboeTester/.gitignore
  14. 7 0
      love/src/jni/oboe/apps/OboeTester/.google/packaging.yaml
  15. 6 0
      love/src/jni/oboe/apps/OboeTester/README.md
  16. 34 0
      love/src/jni/oboe/apps/OboeTester/app/CMakeLists.txt
  17. 44 0
      love/src/jni/oboe/apps/OboeTester/app/build.gradle
  18. BIN
      love/src/jni/oboe/apps/OboeTester/app/gradle/wrapper/gradle-wrapper.jar
  19. 6 0
      love/src/jni/oboe/apps/OboeTester/app/gradle/wrapper/gradle-wrapper.properties
  20. 172 0
      love/src/jni/oboe/apps/OboeTester/app/gradlew
  21. 84 0
      love/src/jni/oboe/apps/OboeTester/app/gradlew.bat
  22. 17 0
      love/src/jni/oboe/apps/OboeTester/app/proguard-rules.pro
  23. 119 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/AndroidManifest.xml
  24. 45 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/AudioStreamGateway.cpp
  25. 62 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/AudioStreamGateway.h
  26. 66 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.cpp
  27. 62 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.h
  28. 49 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexEcho.cpp
  29. 57 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexEcho.h
  30. 18 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexGlitches.cpp
  31. 53 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexGlitches.h
  32. 44 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexLatency.cpp
  33. 65 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexLatency.h
  34. 137 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexStream.cpp
  35. 115 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexStream.h
  36. 57 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InputStreamCallbackAnalyzer.cpp
  37. 72 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InputStreamCallbackAnalyzer.h
  38. 42 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InterpolatingDelayLine.cpp
  39. 48 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InterpolatingDelayLine.h
  40. 161 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/MultiChannelRecording.h
  41. 619 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/NativeAudioContext.cpp
  42. 718 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/NativeAudioContext.h
  43. 95 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/OboeStreamCallbackProxy.cpp
  44. 92 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/OboeStreamCallbackProxy.h
  45. 33 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/PlayRecordingCallback.cpp
  46. 46 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/PlayRecordingCallback.h
  47. 68 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/SawPingGenerator.cpp
  48. 44 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/SawPingGenerator.h
  49. 438 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/GlitchAnalyzer.h
  50. 67 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/InfiniteRecording.h
  51. 611 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/LatencyAnalyzer.h
  52. 96 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/ManchesterEncoder.h
  53. 48 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/PeakDetector.h
  54. 57 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/PseudoRandom.h
  55. 41 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/RandomPulseGenerator.h
  56. 89 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/RoundedManchesterEncoder.h
  57. 41 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/android_debug.h
  58. 35 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ExponentialShape.cpp
  59. 70 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ExponentialShape.h
  60. 42 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ImpulseOscillator.cpp
  61. 39 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ImpulseOscillator.h
  62. 36 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/LinearShape.cpp
  63. 53 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/LinearShape.h
  64. 26 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/OscillatorBase.cpp
  65. 100 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/OscillatorBase.h
  66. 39 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SawtoothOscillator.cpp
  67. 36 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SawtoothOscillator.h
  68. 42 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SineOscillator.cpp
  69. 34 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SineOscillator.h
  70. 40 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/TriangleOscillator.cpp
  71. 39 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/TriangleOscillator.h
  72. 625 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/jni-bridge.cpp
  73. 145 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/unused/unused.h
  74. 132 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/util/WaveFileWriter.cpp
  75. 154 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/util/WaveFileWriter.h
  76. 58 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceAdapter.java
  77. 140 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceInfoConverter.java
  78. 93 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceListEntry.java
  79. 127 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceSpinner.java
  80. 236 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AnalyzerActivity.java
  81. 40 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioInputTester.java
  82. 203 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioMidiTester.java
  83. 60 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioOutputTester.java
  84. 156 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioRecordThread.java
  85. 176 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioStreamBase.java
  86. 51 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioStreamTester.java
  87. 328 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AutoGlitchActivity.java
  88. 143 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/BufferSizeView.java
  89. 104 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/CircularCaptureBuffer.java
  90. 140 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/EchoActivity.java
  91. 67 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/ExponentialTaper.java
  92. 112 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/FastButton.java
  93. 337 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/GlitchActivity.java
  94. 64 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/InputMarginView.java
  95. 260 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/MainActivity.java
  96. 286 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/ManualGlitchActivity.java
  97. 10 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/NativeEngine.java
  98. 26 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/OboeAudioInputStream.java
  99. 42 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/OboeAudioOutputStream.java
  100. 255 0
      love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/OboeAudioStream.java

+ 6 - 0
love/src/jni/oboe/.gitignore

@@ -0,0 +1,6 @@
+*/.DS_Store
+.DS_Store
+.externalNativeBuild/
+.cxx/
+.idea
+build

+ 30 - 0
love/src/jni/oboe/.travis.yml

@@ -0,0 +1,30 @@
+language: android
+sudo: true
+android:
+  components:
+    - tools
+    - platform-tools
+    - extra-google-m2repository
+    - extra-android-m2repository
+addons:
+  apt_packages:
+    - pandoc
+before_install:
+  - sudo apt-get install ant
+install:
+  - touch ~/.android/repositories.cfg
+  - echo y | sdkmanager "ndk-bundle"
+  - echo y | sdkmanager "cmake;3.6.4111459"
+  # the following line triggers Trivis-CI's 4MB log limit
+    #  - sdkmanager --update
+before_script:
+  - export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
+
+script:
+  # scripts excutes inside our repo directory on CI machine
+  - export SAMPLE_CI_RESULT=0
+  - source .ci_tools/setup_env.sh
+  - source .ci_tools/build_samples.sh
+  - source .ci_tools/run_samples.sh
+  - source .ci_tools/misc_ci.sh
+  - eval "[[ $SAMPLE_CI_RESULT == 0 ]]"

+ 9 - 0
love/src/jni/oboe/AUTHORS

@@ -0,0 +1,9 @@
+# This is the official list of authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+
+# Names should be added to this file as:
+# Name or Organization <email address>
+# The email address is not required for organizations.
+
+Google Inc.

+ 84 - 0
love/src/jni/oboe/Android.mk

@@ -0,0 +1,84 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+#
+# Module
+#
+LOCAL_MODULE := oboe
+LOCAL_ARM_NEON := true
+
+#
+# Flags
+#
+LOCAL_CFLAGS := -Wall -Wextra-semi -Wshadow -Wshadow-field
+LOCAL_CPPFLAGS := -std=c++14 
+
+#
+# Include paths
+#
+LOCAL_C_INCLUDES := \
+	$(LOCAL_PATH)/include \
+	$(LOCAL_PATH)/src
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+
+#
+# Source files
+#
+LOCAL_SRC_FILES := \
+    src/aaudio/AAudioLoader.cpp \
+    src/aaudio/AudioStreamAAudio.cpp \
+    src/common/AudioSourceCaller.cpp \
+    src/common/AudioStream.cpp \
+    src/common/AudioStreamBuilder.cpp \
+    src/common/DataConversionFlowGraph.cpp \
+    src/common/FilterAudioStream.cpp \
+    src/common/FixedBlockAdapter.cpp \
+    src/common/FixedBlockReader.cpp \
+    src/common/FixedBlockWriter.cpp \
+    src/common/LatencyTuner.cpp \
+    src/common/SourceFloatCaller.cpp \
+    src/common/SourceI16Caller.cpp \
+    src/common/Utilities.cpp \
+    src/common/QuirksManager.cpp \
+    src/fifo/FifoBuffer.cpp \
+    src/fifo/FifoController.cpp \
+    src/fifo/FifoControllerBase.cpp \
+    src/fifo/FifoControllerIndirect.cpp \
+    src/flowgraph/FlowGraphNode.cpp \
+    src/flowgraph/ClipToRange.cpp \
+    src/flowgraph/ManyToMultiConverter.cpp \
+    src/flowgraph/MonoToMultiConverter.cpp \
+    src/flowgraph/RampLinear.cpp \
+    src/flowgraph/SampleRateConverter.cpp \
+    src/flowgraph/SinkFloat.cpp \
+    src/flowgraph/SinkI16.cpp \
+    src/flowgraph/SinkI24.cpp \
+    src/flowgraph/SourceFloat.cpp \
+    src/flowgraph/SourceI16.cpp \
+    src/flowgraph/SourceI24.cpp \
+    src/flowgraph/resampler/IntegerRatio.cpp \
+    src/flowgraph/resampler/LinearResampler.cpp \
+    src/flowgraph/resampler/MultiChannelResampler.cpp \
+    src/flowgraph/resampler/PolyphaseResampler.cpp \
+    src/flowgraph/resampler/PolyphaseResamplerMono.cpp \
+    src/flowgraph/resampler/PolyphaseResamplerStereo.cpp \
+    src/flowgraph/resampler/SincResampler.cpp \
+    src/flowgraph/resampler/SincResamplerStereo.cpp \
+    src/opensles/AudioInputStreamOpenSLES.cpp \
+    src/opensles/AudioOutputStreamOpenSLES.cpp \
+    src/opensles/AudioStreamBuffered.cpp \
+    src/opensles/AudioStreamOpenSLES.cpp \
+    src/opensles/EngineOpenSLES.cpp \
+    src/opensles/OpenSLESUtilities.cpp \
+    src/opensles/OutputMixerOpenSLES.cpp \
+    src/common/StabilizedCallback.cpp \
+    src/common/Trace.cpp \
+    src/common/Version.cpp
+
+#
+# Libraries related
+#
+LOCAL_LDLIBS := -llog
+
+# Build
+include $(BUILD_STATIC_LIBRARY)

+ 92 - 0
love/src/jni/oboe/CMakeLists.txt

@@ -0,0 +1,92 @@
+cmake_minimum_required(VERSION 3.4.1)
+
+# Set the name of the project and store it in PROJECT_NAME. Also set the following variables:
+# PROJECT_SOURCE_DIR (usually the root directory where Oboe has been cloned e.g.)
+# PROJECT_BINARY_DIR (usually the containing project's binary directory,
+# e.g. ${OBOE_HOME}/samples/RhythmGame/.externalNativeBuild/cmake/ndkExtractorDebug/x86/oboe-bin)
+project(oboe)
+
+set (oboe_sources
+    src/aaudio/AAudioLoader.cpp
+    src/aaudio/AudioStreamAAudio.cpp
+    src/common/AudioSourceCaller.cpp
+    src/common/AudioStream.cpp
+    src/common/AudioStreamBuilder.cpp
+    src/common/DataConversionFlowGraph.cpp
+    src/common/FilterAudioStream.cpp
+    src/common/FixedBlockAdapter.cpp
+    src/common/FixedBlockReader.cpp
+    src/common/FixedBlockWriter.cpp
+    src/common/LatencyTuner.cpp
+    src/common/SourceFloatCaller.cpp
+    src/common/SourceI16Caller.cpp
+    src/common/Utilities.cpp
+    src/common/QuirksManager.cpp
+    src/fifo/FifoBuffer.cpp
+    src/fifo/FifoController.cpp
+    src/fifo/FifoControllerBase.cpp
+    src/fifo/FifoControllerIndirect.cpp
+        src/flowgraph/FlowGraphNode.cpp
+    src/flowgraph/ClipToRange.cpp
+    src/flowgraph/ManyToMultiConverter.cpp
+    src/flowgraph/MonoToMultiConverter.cpp
+    src/flowgraph/RampLinear.cpp
+    src/flowgraph/SampleRateConverter.cpp
+    src/flowgraph/SinkFloat.cpp
+    src/flowgraph/SinkI16.cpp
+    src/flowgraph/SinkI24.cpp
+    src/flowgraph/SourceFloat.cpp
+    src/flowgraph/SourceI16.cpp
+    src/flowgraph/SourceI24.cpp
+    src/flowgraph/resampler/IntegerRatio.cpp
+    src/flowgraph/resampler/LinearResampler.cpp
+    src/flowgraph/resampler/MultiChannelResampler.cpp
+    src/flowgraph/resampler/PolyphaseResampler.cpp
+    src/flowgraph/resampler/PolyphaseResamplerMono.cpp
+    src/flowgraph/resampler/PolyphaseResamplerStereo.cpp
+    src/flowgraph/resampler/SincResampler.cpp
+    src/flowgraph/resampler/SincResamplerStereo.cpp
+    src/opensles/AudioInputStreamOpenSLES.cpp
+    src/opensles/AudioOutputStreamOpenSLES.cpp
+    src/opensles/AudioStreamBuffered.cpp
+    src/opensles/AudioStreamOpenSLES.cpp
+    src/opensles/EngineOpenSLES.cpp
+    src/opensles/OpenSLESUtilities.cpp
+    src/opensles/OutputMixerOpenSLES.cpp
+    src/common/StabilizedCallback.cpp
+    src/common/Trace.cpp
+    src/common/Version.cpp
+    )
+
+add_library(oboe ${oboe_sources})
+
+# Specify directories which the compiler should look for headers
+target_include_directories(oboe
+        PRIVATE src
+        PUBLIC include)
+
+# Compile Flags:
+#     Enable -Werror when building debug config
+#     Enable -Ofast
+target_compile_options(oboe
+        PRIVATE
+        -std=c++14
+        -Wall
+        -Wextra-semi
+        -Wshadow
+        -Wshadow-field
+        -Ofast
+        "$<$<CONFIG:DEBUG>:-Werror>")
+
+# Enable logging of D,V for debug builds
+target_compile_definitions(oboe PUBLIC $<$<CONFIG:DEBUG>:OBOE_ENABLE_LOGGING=1>)
+
+target_link_libraries(oboe PRIVATE log OpenSLES)
+
+# When installing oboe put the libraries in the lib/<ABI> folder e.g. lib/arm64-v8a
+install(TARGETS oboe
+        LIBRARY DESTINATION lib/${ANDROID_ABI}
+        ARCHIVE DESTINATION lib/${ANDROID_ABI})
+
+# Also install the headers
+install(DIRECTORY include/oboe DESTINATION include)

+ 1 - 0
love/src/jni/oboe/CONTRIBUTING

@@ -0,0 +1 @@
+Please see the CONTRIBUTING.md file for more information.

+ 25 - 0
love/src/jni/oboe/CONTRIBUTING.md

@@ -0,0 +1,25 @@
+Want to contribute? Great! First, read this page (including the small print at the end).
+
+### Before you contribute
+Before we can use your code, you must sign the
+[Google Individual Contributor License
+Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
+(CLA), which you can do online. The CLA is necessary mainly because you own the
+copyright to your changes, even after your contribution becomes part of our
+codebase, so we need your permission to use and distribute your code. We also
+need to be sure of various other things—for instance that you'll tell us if you
+know that your code infringes on other people's patents. You don't have to sign
+the CLA until after you've submitted your code for review and a member has
+approved it, but you must do it before we can put your code into our codebase.
+Before you start working on a larger contribution, you should get in touch with
+us first through the issue tracker with your idea so that we can help out and
+possibly guide you. Coordinating up front makes it much easier to avoid
+frustration later on.
+
+### Code reviews
+All submissions, including submissions by project members, require review. We
+use Github pull requests for this purpose.
+
+### The small print
+Contributions made by corporations are covered by a different agreement than
+the one above, the Software Grant and Corporate Contributor License Agreement.

+ 14 - 0
love/src/jni/oboe/CONTRIBUTORS

@@ -0,0 +1,14 @@
+# People who have agreed to one of the CLAs and can contribute patches.
+# The AUTHORS file lists the copyright holders; this file
+# lists people.  For example, Google employees are listed here
+# but not in AUTHORS, because Google holds the copyright.
+#
+# https://developers.google.com/open-source/cla/individual
+# https://developers.google.com/open-source/cla/corporate
+#
+# Names should be added to this file as:
+#     Name <email address>
+
+Phil Burk <philburk@google.com>
+Don Turner <donturner@google.com>
+Mikhail Naganov <mnaganov@google.com>

+ 2482 - 0
love/src/jni/oboe/Doxyfile

@@ -0,0 +1,2482 @@
+# Doxyfile 1.8.14
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See
+# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
+PROJECT_NAME           = "Oboe"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
+PROJECT_NUMBER         = 1.2
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = "A library for creating real-time audio apps on Android"
+
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
+
+PROJECT_LOGO           =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = docs
+
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
+CREATE_SUBDIRS         = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES    = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES        = YES
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
+TAB_SIZE               = 4
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines (in the resulting output). You can put ^^ in the value part of an
+# alias to insert a newline as if a physical newline was in the original file.
+
+ALIASES                =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST              =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT       = YES
+
+# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
+# to that level are automatically included in the table of contents, even if
+# they do not have an id attribute.
+# Note: This feature currently applies only to Markdown headings.
+# Minimum value: 0, maximum value: 99, default value: 0.
+# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
+
+TOC_INCLUDE_HEADINGS   = 0
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT       = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO, these declarations will be
+# included in the documentation.
+# The default value is: NO.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC  = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
+SHOW_USED_FILES        = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE            =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
+
+CITE_BIB_FILES         =
+
+#---------------------------------------------------------------------------
+# Configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
+WARNINGS               = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation.
+# The default value is: NO.
+
+WARN_NO_PARAMDOC       = NO
+
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR          = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE           =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
+
+INPUT                  = include
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
+# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.
+
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.idl \
+                         *.ddl \
+                         *.odl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.cs \
+                         *.d \
+                         *.php \
+                         *.php4 \
+                         *.php5 \
+                         *.phtml \
+                         *.inc \
+                         *.m \
+                         *.markdown \
+                         *.md \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.pyw \
+                         *.f90 \
+                         *.f95 \
+                         *.f03 \
+                         *.f08 \
+                         *.f \
+                         *.for \
+                         *.tcl \
+                         *.vhd \
+                         *.vhdl \
+                         *.ucf \
+                         *.qsf
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE                =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
+EXAMPLE_PATH           =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS       = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH             =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE =
+
+#---------------------------------------------------------------------------
+# Configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS        = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see https://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
+ALPHABETICAL_INDEX     = YES
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX          =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_OUTPUT            = reference
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET        =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET  =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES       =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP         = NO
+
+# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
+# documentation will contain a main index with vertical navigation menus that
+# are dynamically created via Javascript. If disabled, the navigation index will
+# consists of multiple levels of tabs that are statically embedded in every HTML
+# page. Disable this option to support browsers that do not have Javascript,
+# like the Qt help browser.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_MENUS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: https://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET        = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP      = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE               =
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION           =
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI           = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING     =
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX          = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW      = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH         = 250
+
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# https://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT         = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from https://www.mathjax.org before deployment.
+# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH        = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS     =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE       =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH    = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH        = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: https://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL       =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE        = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID     =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS  =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PAPER_TYPE             = a4
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER           =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER           =
+
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES      =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BATCHMODE        = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HIDE_INDICES     = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE        = plain
+
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP        = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE    =
+
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE        = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_EXTENSION          = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR             =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_OUTPUT             = xml
+
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to the DOCBOOK output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK       = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT         = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
+# the structure of the code including all documentation. Note that this feature
+# is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# Configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH           =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS  =
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED             =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration options related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
+EXTERNAL_GROUPS        = YES
+
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES         = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see:
+# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH               =
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: NO.
+
+HAVE_DOT               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS        = 0
+
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LOOK               = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDE_GRAPH          = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG        = NO
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS           =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS           =
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS           =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH      =
+
+# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
+# configuration file for plantuml.
+
+PLANTUML_CFG_FILE      =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH  =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_CLEANUP            = YES

+ 202 - 0
love/src/jni/oboe/LICENSE

@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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
+
+       http://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.

+ 1 - 0
love/src/jni/oboe/README

@@ -0,0 +1 @@
+Please see the README.md file for more information.

+ 53 - 0
love/src/jni/oboe/README.md

@@ -0,0 +1,53 @@
+# Oboe [![Build Status](https://travis-ci.org/google/oboe.svg?branch=master)](https://travis-ci.org/google/oboe)
+
+[![Introduction to Oboe video](docs/images/getting-started-video.jpg)](https://www.youtube.com/watch?v=csfHAbr5ilI&list=PLWz5rJ2EKKc_duWv9IPNvx9YBudNMmLSa)
+
+Oboe is a C++ library which makes it easy to build high-performance audio apps on Android. It was created primarily to allow developers to target a simplified API that works across multiple API levels back to API level 16 (Jelly Bean).
+
+## Features
+- Compatible with API 16 onwards - runs on 99% of Android devices
+- Chooses the audio API (OpenSL ES on API 16+ or AAudio on API 27+) which will give the best audio performance on the target Android device
+- Automatic latency tuning
+- Modern C++ allowing you to write clean, elegant code
+- [Used by popular apps and frameworks](docs/AppsUsingOboe.md)
+
+## Requirements
+To build Oboe you'll need a compiler which supports C++14 and the Android header files. The easiest way to obtain these is by downloading the Android NDK r17 or above. It can be installed using Android Studio's SDK manager, or via [direct download](https://developer.android.com/ndk/downloads/).
+
+## API Documentation
+- [Getting Started Guide](docs/GettingStarted.md)
+- [Full Guide to Oboe](docs/FullGuide.md)
+- [API reference](https://google.github.io/oboe/reference)
+- [Tech Notes](docs/notes/)
+- [History of Audio features/bugs by Android version](docs/AndroidAudioHistory.md)
+- [Frequently Asked Questions](docs/FAQ.md) (FAQ)
+- [Our roadmap](https://github.com/google/oboe/milestones) - Vote on a feature/issue by adding a thumbs up to the first comment.
+
+## Testing
+- [**OboeTester** app for measuring latency, glitches, etc.](https://github.com/google/oboe/tree/master/apps/OboeTester/docs)
+- [Oboe unit tests](https://github.com/google/oboe/tree/master/tests)
+
+## Videos
+- [Getting started with Oboe](https://www.youtube.com/playlist?list=PLWz5rJ2EKKc_duWv9IPNvx9YBudNMmLSa)
+- [Low Latency Audio - Because Your Ears Are Worth It](https://www.youtube.com/watch?v=8vOf_fDtur4) (Android Dev Summit '18)
+- [Real-time audio with the 100 oscillator synthesizer](https://www.youtube.com/watch?v=J04iPJBkAKs) (DroidCon Berlin '18)
+- [Winning on Android](https://www.youtube.com/watch?v=tWBojmBpS74) - How to optimize an Android audio app. (ADC '18)
+- [Real-Time Processing on Android](https://youtu.be/hY9BrS2uX-c) (ADC '19)
+
+## Sample code and apps
+- Sample apps can be found in the [samples directory](samples). 
+- A complete "effects processor" app called FXLab can  be found in the [apps/fxlab folder](apps/fxlab). 
+- Also check out the [Rhythm Game codelab](https://codelabs.developers.google.com/codelabs/musicalgame-using-oboe/index.html#0).
+
+### Third party sample code
+- [Ableton Link integration demo](https://github.com/jbloit/AndroidLinkAudio) (author: jbloit)
+
+## Contributing
+We would love to receive your pull requests. Before we can though, please read the [contributing](CONTRIBUTING.md) guidelines.
+
+## Version history
+View the [releases page](../../releases).
+
+## License
+[LICENSE](LICENSE)
+

+ 11 - 0
love/src/jni/oboe/apps/OboeTester/.gitignore

@@ -0,0 +1,11 @@
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build/
+.idea/
+/app/build/
+/app/app.iml
+*.iml
+/app/externalNativeBuild/

+ 7 - 0
love/src/jni/oboe/apps/OboeTester/.google/packaging.yaml

@@ -0,0 +1,7 @@
+status:       PUBLISHED
+technologies: [Android, NDK]
+categories:   [NDK, C++]
+languages:    [C++, Java]
+solutions:    [Mobile]
+github:       googlesamples/android-ndk
+license:      apache2

+ 6 - 0
love/src/jni/oboe/apps/OboeTester/README.md

@@ -0,0 +1,6 @@
+# Oboe Tester
+
+OboeTester is an app that can be used to test many of the features of Oboe, AAudio and OpenSL ES.
+It can also be used to measure device latency and glitches.
+
+# [OboeTester Documentation](docs)

+ 34 - 0
love/src/jni/oboe/apps/OboeTester/app/CMakeLists.txt

@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.4.1)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -std=c++14")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
+
+link_directories(${CMAKE_CURRENT_LIST_DIR}/..)
+
+file(GLOB_RECURSE app_native_sources src/main/cpp/*)
+
+### Name must match loadLibrary() call in MainActivity.java
+add_library(oboetester SHARED ${app_native_sources})
+
+### INCLUDE OBOE LIBRARY ###
+
+# Set the path to the Oboe library directory
+set (OBOE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
+
+# Add the Oboe library as a subproject. Since Oboe is an out-of-tree source library we must also
+# specify a binary directory
+add_subdirectory(${OBOE_DIR} ./oboe-bin)
+
+# Specify the path to the Oboe header files and the source.
+include_directories(
+    ${OBOE_DIR}/include
+    ${OBOE_DIR}/src
+)
+
+### END OBOE INCLUDE SECTION ###
+
+# link to oboe
+target_link_libraries(oboetester log oboe atomic)
+
+# bump 2 to resync CMake

+ 44 - 0
love/src/jni/oboe/apps/OboeTester/app/build.gradle

@@ -0,0 +1,44 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 28
+    defaultConfig {
+        applicationId = "com.google.sample.oboe.manualtest"
+        minSdkVersion 23
+        targetSdkVersion 28
+        // Also update the version in the AndroidManifest.xml file.
+        versionCode 32
+        versionName "1.5.24"
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+        externalNativeBuild {
+            cmake {
+                cppFlags "-std=c++14"
+                abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
+            }
+        }
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+        debug {
+            jniDebuggable true
+        }
+    }
+    externalNativeBuild {
+        cmake {
+            path "CMakeLists.txt"
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(include: ['*.jar'], dir: 'libs')
+    implementation 'com.android.support.constraint:constraint-layout:2.0.0-beta4'
+
+    testImplementation 'junit:junit:4.13-beta-3'
+    implementation 'com.android.support:appcompat-v7:28.0.0'
+    androidTestImplementation 'com.android.support.test:runner:1.0.2'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}

BIN
love/src/jni/oboe/apps/OboeTester/app/gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
love/src/jni/oboe/apps/OboeTester/app/gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Thu Apr 11 16:29:30 PDT 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

+ 172 - 0
love/src/jni/oboe/apps/OboeTester/app/gradlew

@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"

+ 84 - 0
love/src/jni/oboe/apps/OboeTester/app/gradlew.bat

@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 17 - 0
love/src/jni/oboe/apps/OboeTester/app/proguard-rules.pro

@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/gfan/dev/android-sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

+ 119 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/AndroidManifest.xml

@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.google.sample.oboe.manualtest"
+    android:versionCode="32"
+    android:versionName="1.5.24">
+    <!-- versionCode and versionName also have to be updated in build.gradle -->
+
+    <uses-feature android:name="android.hardware.microphone" android:required="true" />
+    <uses-feature android:name="android.hardware.audio.output" android:required="true" />
+    <uses-feature android:name="android.software.midi" android:required="true" />
+
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <!-- debug-writing file need external storage writing -->
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+
+    <application
+        android:allowBackup="false"
+        android:fullBackupContent="false"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.MainActivity"
+            android:launchMode="singleTask"
+            android:label="@string/app_name"
+            android:screenOrientation="portrait">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.TestOutputActivity"
+            android:label="@string/title_activity_test_output"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.TestInputActivity"
+            android:label="@string/title_activity_test_input"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.TapToToneActivity"
+            android:label="@string/title_activity_output_latency"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.RecorderActivity"
+            android:label="@string/title_activity_recorder"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.EchoActivity"
+            android:label="@string/title_activity_echo"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.RoundTripLatencyActivity"
+            android:label="@string/title_activity_rt_latency"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.ManualGlitchActivity"
+            android:label="@string/title_activity_glitches"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.AutoGlitchActivity"
+            android:label="@string/title_activity_glitches"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <activity
+            android:name="com.google.sample.oboe.manualtest.TestDisconnectActivity"
+            android:label="@string/title_test_disconnect"
+            android:screenOrientation="portrait">
+        </activity>
+
+        <service
+            android:name="com.google.sample.oboe.manualtest.AudioMidiTester"
+            android:permission="android.permission.BIND_MIDI_DEVICE_SERVICE">
+            <intent-filter>
+                <action android:name="android.media.midi.MidiDeviceService" />
+            </intent-filter>
+
+            <meta-data
+                android:name="android.media.midi.MidiDeviceService"
+                android:resource="@xml/service_device_info" />
+        </service>
+
+        <provider
+            android:name="android.support.v4.content.FileProvider"
+            android:authorities="${applicationId}.provider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/provider_paths"/>
+        </provider>
+
+    </application>
+
+</manifest>

+ 45 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/AudioStreamGateway.cpp

@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <cstring>
+#include <sched.h>
+
+#include "oboe/Oboe.h"
+#include "AudioStreamGateway.h"
+
+using namespace flowgraph;
+
+oboe::DataCallbackResult AudioStreamGateway::onAudioReady(
+        oboe::AudioStream *audioStream,
+        void *audioData,
+        int numFrames) {
+
+    if (!mSchedulerChecked) {
+        mScheduler = sched_getscheduler(gettid());
+        mSchedulerChecked = true;
+    }
+
+    if (mAudioSink != nullptr) {
+        mAudioSink->read(mFramePosition, audioData, numFrames);
+        mFramePosition += numFrames;
+    }
+
+    return oboe::DataCallbackResult::Continue;
+}
+
+int AudioStreamGateway::getScheduler() {
+    return mScheduler;
+}

+ 62 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/AudioStreamGateway.h

@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+#ifndef NATIVEOBOE_AUDIOGRAPHRUNNER_H
+#define NATIVEOBOE_AUDIOGRAPHRUNNER_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "flowgraph/FlowGraphNode.h"
+#include "oboe/Oboe.h"
+
+using namespace flowgraph;
+
+/**
+ * Bridge between an audio flowgraph and an audio device.
+ * Pass in an AudioSink and then pass
+ * this object to the AudioStreamBuilder as a callback.
+ */
+class AudioStreamGateway : public oboe::AudioStreamCallback {
+public:
+//    AudioStreamGateway(int samplesPerFrame);
+    virtual ~AudioStreamGateway() = default;
+
+    void setAudioSink(std::shared_ptr<flowgraph::FlowGraphSink>  sink) {
+        mAudioSink = sink;
+        if (sink) {
+            mFramePosition = sink->getLastFramePosition();
+        }
+    }
+
+    /**
+     * Called by Oboe when the stream is ready to process audio.
+     */
+    oboe::DataCallbackResult onAudioReady(
+            oboe::AudioStream *audioStream,
+            void *audioData,
+            int numFrames) override;
+
+    int getScheduler();
+
+private:
+    int64_t  mFramePosition = 0;
+    bool     mSchedulerChecked = false;
+    int      mScheduler;
+    std::shared_ptr<flowgraph::FlowGraphSink>  mAudioSink;
+};
+
+
+#endif //NATIVEOBOE_AUDIOGRAPHRUNNER_H

+ 66 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.cpp

@@ -0,0 +1,66 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "FullDuplexAnalyzer.h"
+
+oboe::Result  FullDuplexAnalyzer::start() {
+    getLoopbackProcessor()->setSampleRate(getOutputStream()->getSampleRate());
+    getLoopbackProcessor()->onStartTest();
+    return FullDuplexStream::start();
+}
+
+oboe::DataCallbackResult FullDuplexAnalyzer::onBothStreamsReady(
+        const void *inputData,
+        int   numInputFrames,
+        void *outputData,
+        int   numOutputFrames) {
+
+    int32_t inputStride = getInputStream()->getChannelCount();
+    int32_t outputStride = getOutputStream()->getChannelCount();
+    float *inputFloat = (float *) inputData;
+    float *outputFloat = (float *) outputData;
+
+    (void) getLoopbackProcessor()->process(inputFloat, inputStride, numInputFrames,
+                                   outputFloat, outputStride, numOutputFrames);
+
+    // write the first channel of output and input to the stereo recorder
+    if (mRecording != nullptr) {
+        float buffer[2];
+        int numBoth = std::min(numInputFrames, numOutputFrames);
+        for (int i = 0; i < numBoth; i++) {
+            buffer[0] = *outputFloat;
+            outputFloat += outputStride;
+            buffer[1] = *inputFloat;
+            inputFloat += inputStride;
+            mRecording->write(buffer, 1);
+        }
+        // Handle mismatch in in numFrames.
+        buffer[0] = 0.0f; // gap in output
+        for (int i = numBoth; i < numInputFrames; i++) {
+            buffer[1] = *inputFloat;
+            inputFloat += inputStride;
+            mRecording->write(buffer, 1);
+        }
+        buffer[1] = 0.0f; // gap in input
+        for (int i = numBoth; i < numOutputFrames; i++) {
+            buffer[0] = *outputFloat;
+            outputFloat += outputStride;
+            mRecording->write(buffer, 1);
+        }
+    }
+    return oboe::DataCallbackResult::Continue;
+};

+ 62 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.h

@@ -0,0 +1,62 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_FULL_DUPLEX_ANALYZER_H
+#define OBOETESTER_FULL_DUPLEX_ANALYZER_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+#include "FullDuplexStream.h"
+#include "analyzer/LatencyAnalyzer.h"
+#include "MultiChannelRecording.h"
+
+class FullDuplexAnalyzer : public FullDuplexStream {
+public:
+    FullDuplexAnalyzer() {}
+
+    /**
+     * Called when data is available on both streams.
+     * Caller should override this method.
+     */
+    oboe::DataCallbackResult onBothStreamsReady(
+            const void *inputData,
+            int   numInputFrames,
+            void *outputData,
+            int   numOutputFrames
+    ) override;
+
+    oboe::Result start() override;
+
+    bool isDone() {
+        return false;
+    }
+
+    virtual LoopbackProcessor *getLoopbackProcessor() = 0;
+
+    void setRecording(MultiChannelRecording *recording) {
+        mRecording = recording;
+    }
+
+private:
+    MultiChannelRecording  *mRecording = nullptr;
+
+};
+
+
+#endif //OBOETESTER_FULL_DUPLEX_ANALYZER_H
+

+ 49 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexEcho.cpp

@@ -0,0 +1,49 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "FullDuplexEcho.h"
+
+oboe::Result  FullDuplexEcho::start() {
+    int32_t delayFrames = (int32_t) (kMaxDelayTimeSeconds * getOutputStream()->getSampleRate());
+    mDelayLine = std::make_unique<InterpolatingDelayLine>(delayFrames);
+    return FullDuplexStream::start();
+}
+
+oboe::DataCallbackResult FullDuplexEcho::onBothStreamsReady(
+        const void *inputData,
+        int   numInputFrames,
+        void *outputData,
+        int   numOutputFrames) {
+    // FIXME only handles matching stream formats.
+    // TODO Add delay node
+    // TODO use flowgraph to handle format conversion
+    int32_t framesToEcho = std::min(numInputFrames, numOutputFrames);
+    float *inputFloat = (float *)inputData;
+    float *outputFloat = (float *)outputData;
+    // zero out entire output array
+    memset(outputFloat, 0, numOutputFrames * getOutputStream()->getBytesPerFrame());
+
+    int32_t inputStride = getInputStream()->getChannelCount();
+    int32_t outputStride = getOutputStream()->getChannelCount();
+    float delayFrames = mDelayTimeSeconds * getOutputStream()->getSampleRate();
+    while (framesToEcho-- > 0) {
+        *outputFloat = mDelayLine->process(delayFrames, *inputFloat); // mono delay
+        inputFloat += inputStride;
+        outputFloat += outputStride;
+    }
+    return oboe::DataCallbackResult::Continue;
+};

+ 57 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexEcho.h

@@ -0,0 +1,57 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_FULL_DUPLEX_ECHO_H
+#define OBOETESTER_FULL_DUPLEX_ECHO_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+#include "FullDuplexStream.h"
+#include "InterpolatingDelayLine.h"
+
+class FullDuplexEcho : public FullDuplexStream {
+public:
+    FullDuplexEcho() {
+        setMNumInputBurstsCushion(0);
+    }
+
+    /**
+     * Called when data is available on both streams.
+     * Caller should override this method.
+     */
+    oboe::DataCallbackResult onBothStreamsReady(
+            const void *inputData,
+            int   numInputFrames,
+            void *outputData,
+            int   numOutputFrames
+    ) override;
+
+    oboe::Result start() override;
+
+    void setDelayTime(double delayTimeSeconds) {
+        mDelayTimeSeconds = delayTimeSeconds;
+    }
+
+private:
+    std::unique_ptr<InterpolatingDelayLine> mDelayLine;
+    static constexpr double kMaxDelayTimeSeconds = 4.0;
+    double mDelayTimeSeconds = kMaxDelayTimeSeconds;
+};
+
+
+#endif //OBOETESTER_FULL_DUPLEX_ECHO_H

+ 18 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexGlitches.cpp

@@ -0,0 +1,18 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "FullDuplexGlitches.h"

+ 53 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexGlitches.h

@@ -0,0 +1,53 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_FULL_DUPLEX_GLITCHES_H
+#define OBOETESTER_FULL_DUPLEX_GLITCHES_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+#include "FullDuplexAnalyzer.h"
+#include "analyzer/GlitchAnalyzer.h"
+
+class FullDuplexGlitches : public FullDuplexAnalyzer {
+public:
+    FullDuplexGlitches() {
+        setMNumInputBurstsCushion(1);
+    }
+
+    bool isDone() {
+        return false;
+    }
+
+    GlitchAnalyzer *getGlitchAnalyzer() {
+        return &mGlitchAnalyzer;
+    }
+
+    LoopbackProcessor *getLoopbackProcessor() override {
+        return (LoopbackProcessor *) &mGlitchAnalyzer;
+    }
+
+private:
+
+    GlitchAnalyzer  mGlitchAnalyzer;
+
+};
+
+
+#endif //OBOETESTER_FULL_DUPLEX_GLITCHES_H
+

+ 44 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexLatency.cpp

@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <thread>
+
+#include "common/OboeDebug.h"
+#include "FullDuplexLatency.h"
+
+static void analyze_data(FullDuplexLatency *fullDuplexLatency) {
+    fullDuplexLatency->analyzeData();
+}
+
+oboe::DataCallbackResult FullDuplexLatency::onBothStreamsReady(
+        const void *inputData,
+        int   numInputFrames,
+        void *outputData,
+        int   numOutputFrames) {
+
+    oboe::DataCallbackResult callbackResult = FullDuplexAnalyzer::onBothStreamsReady(
+            inputData, numInputFrames, outputData, numOutputFrames);
+
+    // Are we done?
+    if (mEchoAnalyzer.hasEnoughData()) {
+        // Crunch the numbers on a separate thread.
+        std::thread t(analyze_data, this);
+        t.detach();
+        callbackResult = oboe::DataCallbackResult::Stop;
+    }
+
+    return callbackResult;
+};

+ 65 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexLatency.h

@@ -0,0 +1,65 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_FULL_DUPLEX_LATENCY_H
+#define OBOETESTER_FULL_DUPLEX_LATENCY_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+#include "FullDuplexAnalyzer.h"
+
+class FullDuplexLatency : public FullDuplexAnalyzer {
+public:
+    FullDuplexLatency() {}
+
+    /**
+     * Called when data is available on both streams.
+     * Caller should override this method.
+     */
+    oboe::DataCallbackResult onBothStreamsReady(
+            const void *inputData,
+            int   numInputFrames,
+            void *outputData,
+            int   numOutputFrames
+    ) override;
+
+
+    bool isDone() {
+        return mEchoAnalyzer.isDone();
+    }
+
+    void analyzeData() {
+        mEchoAnalyzer.analyze();
+    }
+
+    LatencyAnalyzer *getLatencyAnalyzer() {
+        return &mEchoAnalyzer;
+    }
+
+    LoopbackProcessor *getLoopbackProcessor() override {
+        return (LoopbackProcessor *) &mEchoAnalyzer;
+    }
+
+private:
+
+    PulseLatencyAnalyzer  mEchoAnalyzer;
+
+};
+
+
+#endif //OBOETESTER_FULL_DUPLEX_LATENCY_H

+ 137 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexStream.cpp

@@ -0,0 +1,137 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "FullDuplexStream.h"
+
+oboe::DataCallbackResult FullDuplexStream::onAudioReady(
+        oboe::AudioStream *outputStream,
+        void *audioData,
+        int numFrames) {
+    oboe::DataCallbackResult callbackResult = oboe::DataCallbackResult::Continue;
+    int32_t actualFramesRead = 0;
+
+    // Silence the output.
+    int32_t numBytes = numFrames * outputStream->getBytesPerFrame();
+    memset(audioData, 0 /* value */, numBytes);
+
+    if (mCountCallbacksToDrain > 0) {
+        // Drain the input.
+        int32_t totalFramesRead = 0;
+        do {
+            oboe::ResultWithValue<int32_t> result = getInputStream()->read(mInputBuffer.get(),
+                                                                           numFrames,
+                                                                           0 /* timeout */);
+            if (!result) {
+                // Ignore errors because input stream may not be started yet.
+                break;
+            }
+            actualFramesRead = result.value();
+            totalFramesRead += actualFramesRead;
+        } while (actualFramesRead > 0);
+        // Only counts if we actually got some data.
+        if (totalFramesRead > 0) {
+            mCountCallbacksToDrain--;
+        }
+
+    } else if (mCountInputBurstsCushion > 0) {
+        // Let the input fill up a bit so we are not so close to the write pointer.
+        mCountInputBurstsCushion--;
+
+    } else if (mCountCallbacksToDiscard > 0) {
+        mCountCallbacksToDiscard--;
+        // Ignore. Allow the input to reach to equilibrium with the output.
+        oboe::ResultWithValue<int32_t> resultAvailable = getInputStream()->getAvailableFrames();
+        if (!resultAvailable) {
+            LOGE("%s() getAvailableFrames() returned %s\n",
+                    __func__, convertToText(resultAvailable.error()));
+            callbackResult = oboe::DataCallbackResult::Stop;
+        } else {
+            int32_t framesAvailable = resultAvailable.value();
+            if (framesAvailable >= mMinimumFramesBeforeRead) {
+                oboe::ResultWithValue<int32_t> resultRead = getInputStream()->read(mInputBuffer.get(), numFrames, 0 /* timeout */);
+                if (!resultRead) {
+                    LOGE("%s() read() returned %s\n", __func__, convertToText(resultRead.error()));
+                    callbackResult = oboe::DataCallbackResult::Stop;
+                }
+            }
+        }
+    } else {
+        int32_t framesRead = 0;
+        oboe::ResultWithValue<int32_t> resultAvailable = getInputStream()->getAvailableFrames();
+        if (!resultAvailable) {
+            LOGE("%s() getAvailableFrames() returned %s\n", __func__, convertToText(resultAvailable.error()));
+            callbackResult = oboe::DataCallbackResult::Stop;
+        } else {
+            int32_t framesAvailable = resultAvailable.value();
+            if (framesAvailable >= mMinimumFramesBeforeRead) {
+                // Read data into input buffer.
+                oboe::ResultWithValue<int32_t> resultRead  = getInputStream()->read(mInputBuffer.get(), numFrames, 0 /* timeout */);
+                if (!resultRead) {
+                    LOGE("%s() read() returned %s\n", __func__, convertToText(resultRead.error()));
+                    callbackResult = oboe::DataCallbackResult::Stop;
+                } else {
+                    framesRead = resultRead.value();
+                }
+            }
+        }
+
+        if (callbackResult == oboe::DataCallbackResult::Continue) {
+            callbackResult = onBothStreamsReady(
+                    mInputBuffer.get(), framesRead,
+                    audioData, numFrames);
+
+        }
+    }
+
+    if (callbackResult == oboe::DataCallbackResult::Stop) {
+        getInputStream()->requestStop();
+    }
+
+    return callbackResult;
+}
+
+oboe::Result FullDuplexStream::start() {
+    mCountCallbacksToDrain = kNumCallbacksToDrain;
+    mCountInputBurstsCushion = mNumInputBurstsCushion;
+    mCountCallbacksToDiscard = kNumCallbacksToDiscard;
+
+    // Determine maximum size that could possibly be called.
+    int32_t bufferSize = getOutputStream()->getBufferCapacityInFrames()
+            * getOutputStream()->getChannelCount();
+    if (bufferSize > mBufferSize) {
+        mInputBuffer = std::make_unique<float[]>(bufferSize);
+        mBufferSize = bufferSize;
+    }
+    oboe::Result result = getInputStream()->requestStart();
+    if (result != oboe::Result::OK) {
+        return result;
+    }
+    return getOutputStream()->requestStart();
+}
+
+oboe::Result FullDuplexStream::stop() {
+    getOutputStream()->requestStop(); // TODO result?
+    return getInputStream()->requestStop();
+}
+
+int32_t FullDuplexStream::getMNumInputBurstsCushion() const {
+    return mNumInputBurstsCushion;
+}
+
+void FullDuplexStream::setMNumInputBurstsCushion(int32_t numBursts) {
+    FullDuplexStream::mNumInputBurstsCushion = numBursts;
+}

+ 115 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/FullDuplexStream.h

@@ -0,0 +1,115 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_FULL_DUPLEX_STREAM_H
+#define OBOETESTER_FULL_DUPLEX_STREAM_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+
+class FullDuplexStream : public oboe::AudioStreamCallback {
+public:
+    FullDuplexStream() {}
+    virtual ~FullDuplexStream() = default;
+
+    void setInputStream(oboe::AudioStream *stream) {
+        mInputStream = stream;
+    }
+
+    oboe::AudioStream *getInputStream() {
+        return mInputStream;
+    }
+
+    void setOutputStream(oboe::AudioStream *stream) {
+        mOutputStream = stream;
+    }
+    oboe::AudioStream *getOutputStream() {
+        return mOutputStream;
+    }
+
+    virtual oboe::Result start();
+
+    virtual oboe::Result stop();
+
+    /**
+     * Called when data is available on both streams.
+     * Caller should override this method.
+     */
+    virtual oboe::DataCallbackResult onBothStreamsReady(
+            const void *inputData,
+            int   numInputFrames,
+            void *outputData,
+            int   numOutputFrames
+            ) = 0;
+
+    /**
+     * Called by Oboe when the stream is ready to process audio.
+     */
+    oboe::DataCallbackResult onAudioReady(
+            oboe::AudioStream *audioStream,
+            void *audioData,
+            int numFrames) override;
+
+    int32_t getMNumInputBurstsCushion() const;
+
+    /**
+     * Number of bursts to leave in the input buffer as a cushion.
+     * Typically 0 for latency measurements
+     * or 1 for glitch tests.
+     *
+     * @param mNumInputBurstsCushion
+     */
+    void setMNumInputBurstsCushion(int32_t mNumInputBurstsCushion);
+
+    void setMinimumFramesBeforeRead(int32_t numFrames) {
+        mMinimumFramesBeforeRead = numFrames;
+    }
+
+    int32_t getMinimumFramesBeforeRead() const {
+        return mMinimumFramesBeforeRead;
+    }
+
+private:
+
+    // TODO add getters and setters
+    static constexpr int32_t kNumCallbacksToDrain   = 20;
+    static constexpr int32_t kNumCallbacksToDiscard = 30;
+
+    // let input fill back up, usually 0 or 1
+    int32_t mNumInputBurstsCushion =  0;
+    int32_t mMinimumFramesBeforeRead = 0;
+
+    // We want to reach a state where the input buffer is empty and
+    // the output buffer is full.
+    // These are used in order.
+    // Drain several callback so that input is empty.
+    int32_t              mCountCallbacksToDrain = kNumCallbacksToDrain;
+    // Let the input fill back up slightly so we don't run dry.
+    int32_t              mCountInputBurstsCushion = mNumInputBurstsCushion;
+    // Discard some callbacks so the input and output reach equilibrium.
+    int32_t              mCountCallbacksToDiscard = kNumCallbacksToDiscard;
+
+    oboe::AudioStream   *mInputStream = nullptr;
+    oboe::AudioStream   *mOutputStream = nullptr;
+
+    int32_t              mBufferSize = 0;
+    std::unique_ptr<float[]> mInputBuffer;
+};
+
+
+#endif //OBOETESTER_FULL_DUPLEX_STREAM_H

+ 57 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InputStreamCallbackAnalyzer.cpp

@@ -0,0 +1,57 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "InputStreamCallbackAnalyzer.h"
+
+oboe::DataCallbackResult InputStreamCallbackAnalyzer::onAudioReady(
+        oboe::AudioStream *audioStream,
+        void *audioData,
+        int numFrames) {
+    int32_t channelCount = audioStream->getChannelCount();
+
+    if (audioStream->getFormat() == oboe::AudioFormat::I16) {
+        int16_t *shortData = (int16_t *) audioData;
+        if (mRecording != nullptr) {
+            mRecording->write(shortData, numFrames);
+        }
+        int16_t *frameData = shortData;
+        for (int iFrame = 0; iFrame < numFrames; iFrame++) {
+            for (int iChannel = 0; iChannel < channelCount; iChannel++) {
+                float sample = frameData[iChannel] / 32768.0f;
+                mPeakDetectors[iChannel].process(sample);
+            }
+            frameData += channelCount;
+        }
+    } else if (audioStream->getFormat() == oboe::AudioFormat::Float) {
+        float *floatData = (float *) audioData;
+        if (mRecording != nullptr) {
+            mRecording->write(floatData, numFrames);
+        }
+        float *frameData = floatData;
+        for (int iFrame = 0; iFrame < numFrames; iFrame++) {
+            for (int iChannel = 0; iChannel < channelCount; iChannel++) {
+                float sample = frameData[iChannel];
+                mPeakDetectors[iChannel].process(sample);
+            }
+            frameData += channelCount;
+        }
+    }
+
+    audioStream->waitForAvailableFrames(mMinimumFramesBeforeRead, oboe::kNanosPerSecond);
+
+    return oboe::DataCallbackResult::Continue;
+}

+ 72 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InputStreamCallbackAnalyzer.h

@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+
+#ifndef NATIVEOBOE_INPUTSTREAMCALLBACKANALYZER_H
+#define NATIVEOBOE_INPUTSTREAMCALLBACKANALYZER_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+// TODO #include "flowgraph/FlowGraph.h"
+#include "oboe/Oboe.h"
+#include "MultiChannelRecording.h"
+#include "analyzer/PeakDetector.h"
+
+constexpr int kMaxInputChannels = 8;
+
+class InputStreamCallbackAnalyzer : public oboe::AudioStreamCallback  {
+public:
+
+    void reset() {
+        for (auto detector : mPeakDetectors) {
+            detector.reset();
+        }
+    }
+
+    /**
+     * Called by Oboe when the stream is ready to process audio.
+     */
+    oboe::DataCallbackResult onAudioReady(
+            oboe::AudioStream *audioStream,
+            void *audioData,
+            int numFrames) override;
+
+    void setRecording(MultiChannelRecording *recording) {
+        mRecording = recording;
+    }
+
+    double getPeakLevel(int index) {
+        return mPeakDetectors[index].getLevel();
+    }
+
+    void setMinimumFramesBeforeRead(int32_t numFrames) {
+        mMinimumFramesBeforeRead = numFrames;
+    }
+
+    int32_t getMinimumFramesBeforeRead() {
+        return mMinimumFramesBeforeRead;
+    }
+
+public:
+    PeakDetector            mPeakDetectors[kMaxInputChannels];
+    MultiChannelRecording  *mRecording = nullptr;
+
+private:
+    int32_t                 mMinimumFramesBeforeRead = 0;
+};
+
+#endif //NATIVEOBOE_INPUTSTREAMCALLBACKANALYZER_H

+ 42 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InterpolatingDelayLine.cpp

@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "InterpolatingDelayLine.h"
+
+InterpolatingDelayLine::InterpolatingDelayLine(int32_t delaySize) {
+    mDelaySize = delaySize;
+    mDelayLine = std::make_unique<float[]>(delaySize);
+}
+
+float InterpolatingDelayLine::process(float delay, float input) {
+    float *writeAddress = mDelayLine.get() + mCursor;
+    *writeAddress = input;
+    mDelayLine.get()[mCursor] = input;
+    int32_t delayInt = std::min(mDelaySize - 1, (int32_t) delay);
+    int32_t readIndex = mCursor - delayInt;
+    if (readIndex < 0) {
+        readIndex += mDelaySize;
+    }
+    // TODO interpolate
+    float *readAddress = mDelayLine.get() + readIndex;
+    float output = *readAddress;
+    mCursor++;
+    if (mCursor >= mDelaySize) {
+        mCursor = 0;
+    }
+    return output;
+};

+ 48 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/InterpolatingDelayLine.h

@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_INTERPOLATING_DELAY_LINE_H
+#define OBOETESTER_INTERPOLATING_DELAY_LINE_H
+
+#include <memory>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+#include "FullDuplexStream.h"
+
+/**
+ * Monophonic delay line.
+ */
+class InterpolatingDelayLine  {
+public:
+    explicit InterpolatingDelayLine(int32_t delaySize);
+
+    /**
+     * @param input sample to be written to the delay line
+     * @param delay number of samples to delay the output
+     * @return delayed value
+     */
+    float process(float delay, float input);
+
+private:
+    std::unique_ptr<float[]> mDelayLine;
+    int32_t mCursor = 0;
+    int32_t mDelaySize = 0;
+};
+
+
+#endif //OBOETESTER_INTERPOLATING_DELAY_LINE_H

+ 161 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/MultiChannelRecording.h

@@ -0,0 +1,161 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_MULTICHANNEL_RECORDING_H
+#define NATIVEOBOE_MULTICHANNEL_RECORDING_H
+
+#include <memory.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/**
+ * Store multi-channel audio data in float format.
+ * The most recent data will be saved.
+ * Old data may be overwritten.
+ *
+ * Note that this is not thread safe. Do not read and write from separate threads.
+ */
+class MultiChannelRecording {
+public:
+    MultiChannelRecording(int32_t channelCount, int32_t maxFrames)
+            : mChannelCount(channelCount)
+            , mMaxFrames(maxFrames) {
+        mData = new float[channelCount * maxFrames];
+    }
+
+    ~MultiChannelRecording() {
+        delete[] mData;
+    }
+
+    void rewind() {
+        mReadCursorFrames = mWriteCursorFrames - getSizeInFrames();
+    }
+
+    void clear() {
+        mReadCursorFrames = 0;
+        mWriteCursorFrames = 0;
+    }
+
+    int32_t getChannelCount() {
+        return mChannelCount;
+    }
+
+    int32_t getSizeInFrames() {
+        return (int32_t) std::min(mWriteCursorFrames, static_cast<int64_t>(mMaxFrames));
+    }
+
+    int32_t getReadIndex() {
+        return mReadCursorFrames % mMaxFrames;
+    }
+    int32_t getWriteIndex() {
+        return mWriteCursorFrames % mMaxFrames;
+    }
+
+    /**
+     * Write numFrames from the short buffer into the recording.
+     * Overwrite old data if necessary.
+     * Convert shorts to floats.
+     *
+     * @param buffer
+     * @param numFrames
+     * @return number of frames actually written.
+     */
+    int32_t write(int16_t *buffer, int32_t numFrames) {
+        int32_t framesLeft = numFrames;
+        while (framesLeft > 0) {
+            int32_t indexFrame = getWriteIndex();
+            // contiguous writes
+            int32_t framesToEndOfBuffer = mMaxFrames - indexFrame;
+            int32_t framesNow = std::min(framesLeft, framesToEndOfBuffer);
+            int32_t numSamples = framesNow * mChannelCount;
+            int32_t sampleIndex = indexFrame * mChannelCount;
+
+            for (int i = 0; i < numSamples; i++) {
+                mData[sampleIndex++] = *buffer++ * (1.0f / 32768);
+            }
+
+            mWriteCursorFrames += framesNow;
+            framesLeft -= framesNow;
+        }
+        return numFrames - framesLeft;
+    }
+
+    /**
+     * Write all numFrames from the float buffer into the recording.
+     * Overwrite old data if full.
+     * @param buffer
+     * @param numFrames
+     * @return number of frames actually written.
+     */
+    int32_t write(float *buffer, int32_t numFrames) {
+        int32_t framesLeft = numFrames;
+        while (framesLeft > 0) {
+            int32_t indexFrame = getWriteIndex();
+            // contiguous writes
+            int32_t framesToEnd = mMaxFrames - indexFrame;
+            int32_t framesNow = std::min(framesLeft, framesToEnd);
+            int32_t numSamples = framesNow * mChannelCount;
+            int32_t sampleIndex = indexFrame * mChannelCount;
+
+            memcpy(&mData[sampleIndex],
+                   buffer,
+                   (numSamples * sizeof(float)));
+            buffer += numSamples;
+            mWriteCursorFrames += framesNow;
+            framesLeft -= framesNow;
+        }
+        return numFrames;
+    }
+
+    /**
+     * Read numFrames from the recording into the buffer, if there is enough data.
+     * Start at the cursor position, aligned up to the next frame.
+     * @param buffer
+     * @param numFrames
+     * @return number of frames actually read.
+     */
+    int32_t read(float *buffer, int32_t numFrames) {
+        int32_t framesRead = 0;
+        int32_t framesLeft = std::min(numFrames,
+                std::min(mMaxFrames, (int32_t)(mWriteCursorFrames - mReadCursorFrames)));
+        while (framesLeft > 0) {
+            int32_t indexFrame = getReadIndex();
+            // contiguous reads
+            int32_t framesToEnd = mMaxFrames - indexFrame;
+            int32_t framesNow = std::min(framesLeft, framesToEnd);
+            int32_t numSamples = framesNow * mChannelCount;
+            int32_t sampleIndex = indexFrame * mChannelCount;
+
+            memcpy(buffer,
+                   &mData[sampleIndex],
+                   (numSamples * sizeof(float)));
+
+            mReadCursorFrames += framesNow;
+            framesLeft -= framesNow;
+            framesRead += framesNow;
+        }
+        return framesRead;
+    }
+
+private:
+    float          *mData = nullptr;
+    int64_t         mReadCursorFrames = 0;
+    int64_t         mWriteCursorFrames = 0; // monotonically increasing
+    const int32_t   mChannelCount;
+    const int32_t   mMaxFrames;
+};
+
+#endif //NATIVEOBOE_MULTICHANNEL_RECORDING_H

+ 619 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/NativeAudioContext.cpp

@@ -0,0 +1,619 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <fstream>
+#include <iostream>
+#include <vector>
+
+#include "util/WaveFileWriter.h"
+
+#include "NativeAudioContext.h"
+
+using namespace oboe;
+
+static oboe::AudioApi convertNativeApiToAudioApi(int nativeApi) {
+    switch (nativeApi) {
+        default:
+        case NATIVE_MODE_UNSPECIFIED:
+            return oboe::AudioApi::Unspecified;
+        case NATIVE_MODE_AAUDIO:
+            return oboe::AudioApi::AAudio;
+        case NATIVE_MODE_OPENSLES:
+            return oboe::AudioApi::OpenSLES;
+    }
+}
+
+class MyOboeOutputStream : public WaveFileOutputStream {
+public:
+    void write(uint8_t b) override {
+        mData.push_back(b);
+    }
+
+    int32_t length() {
+        return (int32_t) mData.size();
+    }
+
+    uint8_t *getData() {
+        return mData.data();
+    }
+
+private:
+    std::vector<uint8_t> mData;
+};
+
+bool ActivityContext::mUseCallback = true;
+int  ActivityContext::callbackSize = 0;
+
+oboe::AudioStream * ActivityContext::getOutputStream() {
+    for (auto entry : mOboeStreams) {
+        oboe::AudioStream *oboeStream = entry.second.get();
+        if (oboeStream->getDirection() == oboe::Direction::Output) {
+            return oboeStream;
+        }
+    }
+    return nullptr;
+}
+
+oboe::AudioStream * ActivityContext::getInputStream() {
+    for (auto entry : mOboeStreams) {
+        oboe::AudioStream *oboeStream = entry.second.get();
+        if (oboeStream != nullptr) {
+            if (oboeStream->getDirection() == oboe::Direction::Input) {
+                return oboeStream;
+            }
+        }
+    }
+    return nullptr;
+}
+
+void ActivityContext::freeStreamIndex(int32_t streamIndex) {
+    mOboeStreams[streamIndex].reset();
+    mOboeStreams.erase(streamIndex);
+}
+
+int32_t ActivityContext::allocateStreamIndex() {
+    return mNextStreamHandle++;
+}
+
+void ActivityContext::close(int32_t streamIndex) {
+    stopBlockingIOThread();
+    oboe::AudioStream *oboeStream = getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        oboeStream->close();
+        LOGD("ActivityContext::%s() delete stream %d ", __func__, streamIndex);
+        freeStreamIndex(streamIndex);
+    }
+}
+
+bool ActivityContext::isMMapUsed(int32_t streamIndex) {
+    oboe::AudioStream *oboeStream = getStream(streamIndex);
+    if (oboeStream == nullptr) return false;
+    if (oboeStream->getAudioApi() != AudioApi::AAudio) return false;
+    return AAudioExtensions::getInstance().isMMapUsed(oboeStream);
+}
+
+oboe::Result ActivityContext::pause() {
+    oboe::Result result = oboe::Result::OK;
+    stopBlockingIOThread();
+    for (auto entry : mOboeStreams) {
+        oboe::AudioStream *oboeStream = entry.second.get();
+        result = oboeStream->requestPause();
+        printScheduler();
+    }
+    return result;
+}
+
+oboe::Result ActivityContext::stopAllStreams() {
+    oboe::Result result = oboe::Result::OK;
+    stopBlockingIOThread();
+    for (auto entry : mOboeStreams) {
+        oboe::AudioStream *oboeStream = entry.second.get();
+        result = oboeStream->requestStop();
+        printScheduler();
+    }
+    return result;
+}
+
+void ActivityContext::configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) {
+    // We needed the proxy because we did not know the channelCount when we setup the Builder.
+    if (mUseCallback) {
+        LOGD("ActivityContext::open() set callback to use oboeCallbackProxy, callback size = %d",
+             callbackSize);
+        builder.setCallback(&oboeCallbackProxy);
+        builder.setFramesPerCallback(callbackSize);
+    }
+}
+
+int ActivityContext::open(jint nativeApi,
+                          jint sampleRate,
+                          jint channelCount,
+                          jint format,
+                          jint sharingMode,
+                          jint performanceMode,
+                          jint inputPreset,
+                          jint deviceId,
+                          jint sessionId,
+                          jint framesPerBurst,
+                          jboolean channelConversionAllowed,
+                          jboolean formatConversionAllowed,
+                          jint rateConversionQuality,
+                          jboolean isMMap,
+                          jboolean isInput) {
+
+    oboe::AudioApi audioApi = oboe::AudioApi::Unspecified;
+    switch (nativeApi) {
+        case NATIVE_MODE_UNSPECIFIED:
+        case NATIVE_MODE_AAUDIO:
+        case NATIVE_MODE_OPENSLES:
+            audioApi = convertNativeApiToAudioApi(nativeApi);
+            break;
+        default:
+            return (jint) oboe::Result::ErrorOutOfRange;
+    }
+
+    int32_t streamIndex = allocateStreamIndex();
+    if (streamIndex < 0) {
+        LOGE("ActivityContext::open() stream array full");
+        return (jint) oboe::Result::ErrorNoFreeHandles;
+    }
+
+    if (channelCount < 0 || channelCount > 256) {
+        LOGE("ActivityContext::open() channels out of range");
+        return (jint) oboe::Result::ErrorOutOfRange;
+    }
+
+    // Create an audio stream.
+    oboe::AudioStreamBuilder builder;
+    builder.setChannelCount(channelCount)
+            ->setDirection(isInput ? oboe::Direction::Input : oboe::Direction::Output)
+            ->setSharingMode((oboe::SharingMode) sharingMode)
+            ->setPerformanceMode((oboe::PerformanceMode) performanceMode)
+            ->setInputPreset((oboe::InputPreset)inputPreset)
+            ->setDeviceId(deviceId)
+            ->setSessionId((oboe::SessionId) sessionId)
+            ->setSampleRate(sampleRate)
+            ->setFormat((oboe::AudioFormat) format)
+            ->setChannelConversionAllowed(channelConversionAllowed)
+            ->setFormatConversionAllowed(formatConversionAllowed)
+            ->setSampleRateConversionQuality((oboe::SampleRateConversionQuality) rateConversionQuality)
+            ;
+
+    configureBuilder(isInput, builder);
+
+    builder.setAudioApi(audioApi);
+
+    // Temporarily set the AAudio MMAP policy to disable MMAP or not.
+    bool oldMMapEnabled = AAudioExtensions::getInstance().isMMapEnabled();
+    AAudioExtensions::getInstance().setMMapEnabled(isMMap);
+
+    // Open a stream based on the builder settings.
+    std::shared_ptr<oboe::AudioStream> oboeStream;
+    Result result = builder.openStream(oboeStream);
+    AAudioExtensions::getInstance().setMMapEnabled(oldMMapEnabled);
+    if (result != Result::OK) {
+        freeStreamIndex(streamIndex);
+        streamIndex = -1;
+    } else {
+        mOboeStreams[streamIndex] = oboeStream; // save shared_ptr
+
+        mChannelCount = oboeStream->getChannelCount(); // FIXME store per stream
+        mFramesPerBurst = oboeStream->getFramesPerBurst();
+        mSampleRate = oboeStream->getSampleRate();
+
+        createRecording();
+
+        finishOpen(isInput, oboeStream.get());
+    }
+
+    if (!mUseCallback) {
+        int numSamples = getFramesPerBlock() * mChannelCount;
+        dataBuffer = std::make_unique<float[]>(numSamples);
+    }
+
+    return (result != Result::OK) ? (int)result : streamIndex;
+}
+
+oboe::Result ActivityContext::start() {
+    oboe::Result result = oboe::Result::OK;
+    oboe::AudioStream *inputStream = getInputStream();
+    oboe::AudioStream *outputStream = getOutputStream();
+    if (inputStream == nullptr && outputStream == nullptr) {
+        LOGD("%s() - no streams defined", __func__);
+        return oboe::Result::ErrorInvalidState; // not open
+    }
+
+    configureForStart();
+
+    result = startStreams();
+
+    if (!mUseCallback && result == oboe::Result::OK) {
+        // Instead of using the callback, start a thread that writes the stream.
+        threadEnabled.store(true);
+        dataThread = new std::thread(threadCallback, this);
+    }
+
+    return result;
+}
+
+int32_t  ActivityContext::saveWaveFile(const char *filename) {
+    if (mRecording == nullptr) {
+        LOGW("ActivityContext::saveWaveFile(%s) but no recording!", filename);
+        return -1;
+    }
+    if (mRecording->getSizeInFrames() == 0) {
+        LOGW("ActivityContext::saveWaveFile(%s) but no frames!", filename);
+        return -2;
+    }
+    MyOboeOutputStream outStream;
+    WaveFileWriter writer(&outStream);
+
+    writer.setFrameRate(mSampleRate);
+    writer.setSamplesPerFrame(mRecording->getChannelCount());
+    writer.setBitsPerSample(24);
+    float buffer[mRecording->getChannelCount()];
+    // Read samples from start to finish.
+    mRecording->rewind();
+    for (int32_t frameIndex = 0; frameIndex < mRecording->getSizeInFrames(); frameIndex++) {
+        mRecording->read(buffer, 1 /* numFrames */);
+        for (int32_t i = 0; i < mRecording->getChannelCount(); i++) {
+            writer.write(buffer[i]);
+        }
+    }
+    writer.close();
+
+    if (outStream.length() > 0) {
+        auto myfile = std::ofstream(filename, std::ios::out | std::ios::binary);
+        myfile.write((char *) outStream.getData(), outStream.length());
+        myfile.close();
+    }
+
+    return outStream.length();
+}
+
+// =================================================================== ActivityTestOutput
+void ActivityTestOutput::close(int32_t streamIndex) {
+    ActivityContext::close(streamIndex);
+    manyToMulti.reset(nullptr);
+    monoToMulti.reset(nullptr);
+    mSinkFloat.reset();
+    mSinkI16.reset();
+}
+
+void ActivityTestOutput::setChannelEnabled(int channelIndex, bool enabled) {
+    if (manyToMulti == nullptr) {
+        return;
+    }
+    if (enabled) {
+        switch (mSignalType) {
+            case SignalType::Sine:
+                sineOscillators[channelIndex].frequency.disconnect();
+                sineOscillators[channelIndex].output.connect(manyToMulti->inputs[channelIndex].get());
+                break;
+            case SignalType::Sawtooth:
+                sawtoothOscillators[channelIndex].output.connect(manyToMulti->inputs[channelIndex].get());
+                break;
+            case SignalType::FreqSweep:
+                mLinearShape.output.connect(&sineOscillators[channelIndex].frequency);
+                sineOscillators[channelIndex].output.connect(manyToMulti->inputs[channelIndex].get());
+                break;
+            case SignalType::PitchSweep:
+                mExponentialShape.output.connect(&sineOscillators[channelIndex].frequency);
+                sineOscillators[channelIndex].output.connect(manyToMulti->inputs[channelIndex].get());
+                break;
+            default:
+                break;
+        }
+    } else {
+        manyToMulti->inputs[channelIndex]->disconnect();
+    }
+}
+
+void ActivityTestOutput::configureForStart() {
+    manyToMulti = std::make_unique<ManyToMultiConverter>(mChannelCount);
+
+    mSinkFloat = std::make_unique<SinkFloat>(mChannelCount);
+    mSinkI16 = std::make_unique<SinkI16>(mChannelCount);
+
+    oboe::AudioStream *outputStream = getOutputStream();
+
+    mTriangleOscillator.setSampleRate(outputStream->getSampleRate());
+    mTriangleOscillator.frequency.setValue(1.0/kSweepPeriod);
+    mTriangleOscillator.amplitude.setValue(1.0);
+    mTriangleOscillator.setPhase(-1.0);
+
+    mLinearShape.setMinimum(0.0);
+    mLinearShape.setMaximum(outputStream->getSampleRate() * 0.5); // Nyquist
+
+    mExponentialShape.setMinimum(110.0);
+    mExponentialShape.setMaximum(outputStream->getSampleRate() * 0.5); // Nyquist
+
+    mTriangleOscillator.output.connect(&(mLinearShape.input));
+    mTriangleOscillator.output.connect(&(mExponentialShape.input));
+    {
+        double frequency = 330.0;
+        for (int i = 0; i < mChannelCount; i++) {
+            sineOscillators[i].setSampleRate(outputStream->getSampleRate());
+            sineOscillators[i].frequency.setValue(frequency);
+            frequency *= 4.0 / 3.0; // each sine is at a higher frequency
+            sineOscillators[i].amplitude.setValue(AMPLITUDE_SINE);
+            setChannelEnabled(i, true);
+        }
+    }
+
+    manyToMulti->output.connect(&(mSinkFloat.get()->input));
+    manyToMulti->output.connect(&(mSinkI16.get()->input));
+
+    // Clear framePosition in sine oscillators.
+    mSinkFloat->pullReset();
+    mSinkI16->pullReset();
+
+    configureStreamGateway();
+}
+
+void ActivityTestOutput::configureStreamGateway() {
+    oboe::AudioStream *outputStream = getOutputStream();
+    if (outputStream->getFormat() == oboe::AudioFormat::I16) {
+        audioStreamGateway.setAudioSink(mSinkI16);
+    } else if (outputStream->getFormat() == oboe::AudioFormat::Float) {
+        audioStreamGateway.setAudioSink(mSinkFloat);
+    }
+
+    if (mUseCallback) {
+        oboeCallbackProxy.setCallback(&audioStreamGateway);
+    }
+}
+
+void ActivityTestOutput::runBlockingIO() {
+    int32_t framesPerBlock = getFramesPerBlock();
+    oboe::DataCallbackResult callbackResult = oboe::DataCallbackResult::Continue;
+
+    oboe::AudioStream *oboeStream = getOutputStream();
+    if (oboeStream == nullptr) {
+        LOGE("%s() : no stream found\n", __func__);
+        return;
+    }
+
+    while (threadEnabled.load()
+           && callbackResult == oboe::DataCallbackResult::Continue) {
+        // generate output by calling the callback
+        callbackResult = audioStreamGateway.onAudioReady(oboeStream,
+                                                         dataBuffer.get(),
+                                                         framesPerBlock);
+
+        auto result = oboeStream->write(dataBuffer.get(),
+                                        framesPerBlock,
+                                        NANOS_PER_SECOND);
+
+        if (!result) {
+            LOGE("%s() returned %s\n", __func__, convertToText(result.error()));
+            break;
+        }
+        int32_t framesWritten = result.value();
+        if (framesWritten < framesPerBlock) {
+            LOGE("%s() : write() wrote %d of %d\n", __func__, framesWritten, framesPerBlock);
+            break;
+        }
+    }
+}
+
+// ======================================================================= ActivityTestInput
+void ActivityTestInput::configureForStart() {
+    mInputAnalyzer.reset();
+    if (mUseCallback) {
+        oboeCallbackProxy.setCallback(&mInputAnalyzer);
+    }
+    mInputAnalyzer.setRecording(mRecording.get());
+}
+
+void ActivityTestInput::runBlockingIO() {
+    int32_t framesPerBlock = getFramesPerBlock();
+    oboe::DataCallbackResult callbackResult = oboe::DataCallbackResult::Continue;
+
+    oboe::AudioStream *oboeStream = getInputStream();
+    if (oboeStream == nullptr) {
+        LOGE("%s() : no stream found\n", __func__);
+        return;
+    }
+
+    while (threadEnabled.load()
+           && callbackResult == oboe::DataCallbackResult::Continue) {
+
+        // Avoid glitches by waiting until there is extra data in the FIFO.
+        auto err = oboeStream->waitForAvailableFrames(mMinimumFramesBeforeRead, kNanosPerSecond);
+        if (!err) break;
+
+        // read from input
+        auto result = oboeStream->read(dataBuffer.get(),
+                                       framesPerBlock,
+                                       NANOS_PER_SECOND);
+        if (!result) {
+            LOGE("%s() : read() returned %s\n", __func__, convertToText(result.error()));
+            break;
+        }
+        int32_t framesRead = result.value();
+        if (framesRead < framesPerBlock) { // timeout?
+            LOGE("%s() : read() read %d of %d\n", __func__, framesRead, framesPerBlock);
+            break;
+        }
+
+        // analyze input
+        callbackResult = mInputAnalyzer.onAudioReady(oboeStream,
+                                                     dataBuffer.get(),
+                                                     framesRead);
+    }
+}
+
+oboe::Result ActivityRecording::stopPlayback() {
+    oboe::Result result = oboe::Result::OK;
+    if (playbackStream != nullptr) {
+        result = playbackStream->requestStop();
+        playbackStream->close();
+        mPlayRecordingCallback.setRecording(nullptr);
+        delete playbackStream;
+        playbackStream = nullptr;
+    }
+    return result;
+}
+
+oboe::Result ActivityRecording::startPlayback() {
+    stop();
+    oboe::AudioStreamBuilder builder;
+    builder.setChannelCount(mChannelCount)
+            ->setSampleRate(mSampleRate)
+            ->setFormat(oboe::AudioFormat::Float)
+            ->setCallback(&mPlayRecordingCallback)
+            ->setAudioApi(oboe::AudioApi::OpenSLES);
+    oboe::Result result = builder.openStream(&playbackStream);
+    if (result != oboe::Result::OK) {
+        delete playbackStream;
+        playbackStream = nullptr;
+    } else if (playbackStream != nullptr) {
+        if (mRecording != nullptr) {
+            mRecording->rewind();
+            mPlayRecordingCallback.setRecording(mRecording.get());
+            result = playbackStream->requestStart();
+        }
+    }
+    return result;
+}
+
+// ======================================================================= ActivityTapToTone
+void ActivityTapToTone::configureForStart() {
+    monoToMulti = std::make_unique<MonoToMultiConverter>(mChannelCount);
+
+    mSinkFloat = std::make_unique<SinkFloat>(mChannelCount);
+    mSinkI16 = std::make_unique<SinkI16>(mChannelCount);
+
+    oboe::AudioStream *outputStream = getOutputStream();
+    sawPingGenerator.setSampleRate(outputStream->getSampleRate());
+    sawPingGenerator.frequency.setValue(FREQUENCY_SAW_PING);
+    sawPingGenerator.amplitude.setValue(AMPLITUDE_SAW_PING);
+
+    sawPingGenerator.output.connect(&(monoToMulti->input));
+    monoToMulti->output.connect(&(mSinkFloat.get()->input));
+    monoToMulti->output.connect(&(mSinkI16.get()->input));
+
+    sawPingGenerator.setEnabled(false);
+    configureStreamGateway();
+}
+
+// ======================================================================= ActivityRoundTripLatency
+void ActivityFullDuplex::configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) {
+    if (isInput) {
+        // Ideally the output streams should be opened first.
+        oboe::AudioStream *outputStream = getOutputStream();
+        if (outputStream != nullptr) {
+            // Make sure the capacity is bigger than two bursts.
+            int32_t burst = outputStream->getFramesPerBurst();
+            builder.setBufferCapacityInFrames(2 * burst);
+        }
+    }
+}
+
+// ======================================================================= ActivityEcho
+void ActivityEcho::configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) {
+    ActivityFullDuplex::configureBuilder(isInput, builder);
+
+    if (mFullDuplexEcho.get() == nullptr) {
+        mFullDuplexEcho = std::make_unique<FullDuplexEcho>();
+    }
+    // only output uses a callback, input is polled
+    if (!isInput) {
+        builder.setCallback(mFullDuplexEcho.get());
+    }
+}
+
+void ActivityEcho::finishOpen(bool isInput, oboe::AudioStream *oboeStream) {
+    if (isInput) {
+        mFullDuplexEcho->setInputStream(oboeStream);
+    } else {
+        mFullDuplexEcho->setOutputStream(oboeStream);
+    }
+}
+
+// ======================================================================= ActivityRoundTripLatency
+void ActivityRoundTripLatency::configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) {
+    ActivityFullDuplex::configureBuilder(isInput, builder);
+
+    if (mFullDuplexLatency.get() == nullptr) {
+        mFullDuplexLatency = std::make_unique<FullDuplexLatency>();
+    }
+    if (!isInput) {
+        // only output uses a callback, input is polled
+        builder.setCallback(mFullDuplexLatency.get());
+    }
+}
+
+void ActivityRoundTripLatency::finishOpen(bool isInput, oboe::AudioStream *oboeStream) {
+    if (isInput) {
+        mFullDuplexLatency->setInputStream(oboeStream);
+        mFullDuplexLatency->setRecording(mRecording.get());
+    } else {
+        mFullDuplexLatency->setOutputStream(oboeStream);
+    }
+}
+
+// ======================================================================= ActivityGlitches
+void ActivityGlitches::configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) {
+    ActivityFullDuplex::configureBuilder(isInput, builder);
+
+    if (mFullDuplexGlitches.get() == nullptr) {
+        mFullDuplexGlitches = std::make_unique<FullDuplexGlitches>();
+    }
+    if (!isInput) {
+        // only output uses a callback, input is polled
+        builder.setCallback(mFullDuplexGlitches.get());
+    }
+}
+
+void ActivityGlitches::finishOpen(bool isInput, oboe::AudioStream *oboeStream) {
+    if (isInput) {
+        mFullDuplexGlitches->setInputStream(oboeStream);
+        mFullDuplexGlitches->setRecording(mRecording.get());
+    } else {
+        mFullDuplexGlitches->setOutputStream(oboeStream);
+    }
+}
+
+
+// =================================================================== ActivityTestDisconnect
+void ActivityTestDisconnect::close(int32_t streamIndex) {
+    ActivityContext::close(streamIndex);
+    mSinkFloat.reset();
+}
+
+void ActivityTestDisconnect::configureForStart() {
+    oboe::AudioStream *outputStream = getOutputStream();
+    oboe::AudioStream *inputStream = getInputStream();
+    if (outputStream) {
+        mSinkFloat = std::make_unique<SinkFloat>(mChannelCount);
+        sineOscillator = std::make_unique<SineOscillator>();
+        monoToMulti = std::make_unique<MonoToMultiConverter>(mChannelCount);
+
+        sineOscillator->setSampleRate(outputStream->getSampleRate());
+        sineOscillator->frequency.setValue(440.0);
+        sineOscillator->amplitude.setValue(AMPLITUDE_SINE);
+        sineOscillator->output.connect(&(monoToMulti->input));
+        monoToMulti->output.connect(&(mSinkFloat->input));
+        // Clear framePosition in sine oscillators.
+        mSinkFloat->pullReset();
+        audioStreamGateway.setAudioSink(mSinkFloat);
+    } else if (inputStream) {
+        audioStreamGateway.setAudioSink(nullptr);
+    }
+    oboeCallbackProxy.setCallback(&audioStreamGateway);
+}
+

+ 718 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/NativeAudioContext.h

@@ -0,0 +1,718 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_NATIVEAUDIOCONTEXT_H
+#define NATIVEOBOE_NATIVEAUDIOCONTEXT_H
+
+#include <dlfcn.h>
+#include <jni.h>
+#include <sys/system_properties.h>
+#include <thread>
+#include <unordered_map>
+#include <vector>
+
+#include "common/OboeDebug.h"
+#include "oboe/Oboe.h"
+
+#include "AudioStreamGateway.h"
+#include "flowunits/ImpulseOscillator.h"
+#include "flowgraph/ManyToMultiConverter.h"
+#include "flowgraph/MonoToMultiConverter.h"
+#include "flowgraph/SinkFloat.h"
+#include "flowgraph/SinkI16.h"
+#include "flowunits/ExponentialShape.h"
+#include "flowunits/LinearShape.h"
+#include "flowunits/SineOscillator.h"
+#include "flowunits/SawtoothOscillator.h"
+
+#include "FullDuplexEcho.h"
+#include "FullDuplexGlitches.h"
+#include "FullDuplexLatency.h"
+#include "FullDuplexStream.h"
+#include "InputStreamCallbackAnalyzer.h"
+#include "MultiChannelRecording.h"
+#include "OboeStreamCallbackProxy.h"
+#include "PlayRecordingCallback.h"
+#include "SawPingGenerator.h"
+#include "flowunits/TriangleOscillator.h"
+
+// These must match order in strings.xml and in StreamConfiguration.java
+#define NATIVE_MODE_UNSPECIFIED  0
+#define NATIVE_MODE_OPENSLES     1
+#define NATIVE_MODE_AAUDIO       2
+
+#define MAX_SINE_OSCILLATORS     8
+#define AMPLITUDE_SINE           1.0
+#define AMPLITUDE_SAWTOOTH       0.5
+#define FREQUENCY_SAW_PING       800.0
+#define AMPLITUDE_SAW_PING       0.8
+#define AMPLITUDE_IMPULSE        0.7
+
+#define NANOS_PER_MICROSECOND    ((int64_t) 1000)
+#define NANOS_PER_MILLISECOND    (1000 * NANOS_PER_MICROSECOND)
+#define NANOS_PER_SECOND         (1000 * NANOS_PER_MILLISECOND)
+
+#define LIB_AAUDIO_NAME          "libaaudio.so"
+#define FUNCTION_IS_MMAP         "AAudioStream_isMMapUsed"
+#define FUNCTION_SET_MMAP_POLICY "AAudio_setMMapPolicy"
+#define FUNCTION_GET_MMAP_POLICY "AAudio_getMMapPolicy"
+
+#define SECONDS_TO_RECORD        10
+
+typedef struct AAudioStreamStruct         AAudioStream;
+
+/**
+ * Call some AAudio test routines that are not part of the normal API.
+ */
+class AAudioExtensions {
+public:
+    AAudioExtensions() {
+        int32_t policy = getIntegerProperty("aaudio.mmap_policy", 0);
+        mMMapSupported = isPolicyEnabled(policy);
+
+        policy = getIntegerProperty("aaudio.mmap_exclusive_policy", 0);
+        mMMapExclusiveSupported = isPolicyEnabled(policy);
+    }
+
+    static bool isPolicyEnabled(int32_t policy) {
+        return (policy == AAUDIO_POLICY_AUTO || policy == AAUDIO_POLICY_ALWAYS);
+    }
+
+    static AAudioExtensions &getInstance() {
+        static AAudioExtensions instance;
+        return instance;
+    }
+
+    bool isMMapUsed(oboe::AudioStream *oboeStream) {
+        if (!loadLibrary()) return false;
+        AAudioStream *aaudioStream = (AAudioStream *) oboeStream->getUnderlyingStream();
+        return mAAudioStream_isMMap(aaudioStream);
+    }
+
+    bool setMMapEnabled(bool enabled) {
+        if (!loadLibrary()) return false;
+        return mAAudio_setMMapPolicy(enabled ? AAUDIO_POLICY_AUTO : AAUDIO_POLICY_NEVER);
+    }
+
+    bool isMMapEnabled() {
+        if (!loadLibrary()) return false;
+        int32_t policy = mAAudio_getMMapPolicy();
+        return isPolicyEnabled(policy);
+    }
+
+    bool isMMapSupported() {
+        return mMMapSupported;
+    }
+
+    bool isMMapExclusiveSupported() {
+        return mMMapExclusiveSupported;
+    }
+
+private:
+
+    enum {
+        AAUDIO_POLICY_NEVER = 1,
+        AAUDIO_POLICY_AUTO,
+        AAUDIO_POLICY_ALWAYS
+    };
+    typedef int32_t aaudio_policy_t;
+
+    int getIntegerProperty(const char *name, int defaultValue) {
+        int result = defaultValue;
+        char valueText[PROP_VALUE_MAX] = {0};
+        if (__system_property_get(name, valueText) != 0) {
+            result = atoi(valueText);
+        }
+        return result;
+    }
+
+    // return true if it succeeds
+    bool loadLibrary() {
+        if (mFirstTime) {
+            mFirstTime = false;
+            mLibHandle = dlopen(LIB_AAUDIO_NAME, 0);
+            if (mLibHandle == nullptr) {
+                LOGI("%s() could not find " LIB_AAUDIO_NAME, __func__);
+                return false;
+            }
+
+            mAAudioStream_isMMap = (bool (*)(AAudioStream *stream))
+                    dlsym(mLibHandle, FUNCTION_IS_MMAP);
+            if (mAAudioStream_isMMap == nullptr) {
+                LOGI("%s() could not find " FUNCTION_IS_MMAP, __func__);
+                return false;
+            }
+
+            mAAudio_setMMapPolicy = (int32_t (*)(aaudio_policy_t policy))
+                    dlsym(mLibHandle, FUNCTION_SET_MMAP_POLICY);
+            if (mAAudio_setMMapPolicy == nullptr) {
+                LOGI("%s() could not find " FUNCTION_SET_MMAP_POLICY, __func__);
+                return false;
+            }
+
+            mAAudio_getMMapPolicy = (aaudio_policy_t (*)())
+                    dlsym(mLibHandle, FUNCTION_GET_MMAP_POLICY);
+            if (mAAudio_getMMapPolicy == nullptr) {
+                LOGI("%s() could not find " FUNCTION_GET_MMAP_POLICY, __func__);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    bool      mFirstTime = true;
+    void     *mLibHandle = nullptr;
+    bool    (*mAAudioStream_isMMap)(AAudioStream *stream) = nullptr;
+    int32_t (*mAAudio_setMMapPolicy)(aaudio_policy_t policy) = nullptr;
+    aaudio_policy_t (*mAAudio_getMMapPolicy)() = nullptr;
+    bool      mMMapSupported = false;
+    bool      mMMapExclusiveSupported = false;
+};
+
+/**
+ * Abstract base class that corresponds to a test at the Java level.
+ */
+class ActivityContext {
+public:
+
+    ActivityContext() {}
+    virtual ~ActivityContext() = default;
+
+    oboe::AudioStream *getStream(int32_t streamIndex) {
+        auto it = mOboeStreams.find(streamIndex);
+        if (it != mOboeStreams.end()) {
+            return it->second.get();
+        } else {
+            return nullptr;
+        }
+    }
+
+    virtual void configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder);
+
+    int open(jint nativeApi,
+             jint sampleRate,
+             jint channelCount,
+             jint format,
+             jint sharingMode,
+             jint performanceMode,
+             jint inputPreset,
+             jint deviceId,
+             jint sessionId,
+             jint framesPerBurst,
+             jboolean channelConversionAllowed,
+             jboolean formatConversionAllowed,
+             jint rateConversionQuality,
+             jboolean isMMap,
+             jboolean isInput);
+
+
+    virtual void close(int32_t streamIndex);
+
+    void printScheduler() {
+#if OBOE_ENABLE_LOGGING
+        int scheduler = audioStreamGateway.getScheduler();
+#endif
+        LOGI("scheduler = 0x%08x, SCHED_FIFO = 0x%08X\n", scheduler, SCHED_FIFO);
+    }
+
+    virtual void configureForStart() {}
+
+    oboe::Result start();
+
+    oboe::Result pause();
+
+    oboe::Result stopAllStreams();
+
+    virtual oboe::Result stop() {
+        return stopAllStreams();
+    }
+
+    double getCpuLoad() {
+        return oboeCallbackProxy.getCpuLoad();
+    }
+
+    void setWorkload(double workload) {
+        oboeCallbackProxy.setWorkload(workload);
+    }
+
+    virtual oboe::Result startPlayback() {
+        return oboe::Result::OK;
+    }
+
+    virtual oboe::Result stopPlayback() {
+        return oboe::Result::OK;
+    }
+
+    virtual void runBlockingIO() {};
+
+    static void threadCallback(ActivityContext *context) {
+        context->runBlockingIO();
+    }
+
+    void stopBlockingIOThread() {
+        if (dataThread != nullptr) {
+            // stop a thread that runs in place of the callback
+            threadEnabled.store(false); // ask thread to exit its loop
+            dataThread->join();
+            dataThread = nullptr;
+        }
+    }
+
+    virtual double getPeakLevel(int index) {
+        return 0.0;
+    }
+
+    virtual void setEnabled(bool enabled) {
+    }
+
+    bool isMMapUsed(int32_t streamIndex);
+
+    int32_t getFramesPerBlock() {
+        return (callbackSize == 0) ? mFramesPerBurst : callbackSize;
+    }
+
+    int64_t getCallbackCount() {
+        return oboeCallbackProxy.getCallbackCount();
+    }
+
+    int32_t getFramesPerCallback() {
+        return oboeCallbackProxy.getFramesPerCallback();
+    }
+
+    virtual void setChannelEnabled(int channelIndex, bool enabled) {}
+
+    virtual void setSignalType(int signalType) {}
+
+    virtual int32_t saveWaveFile(const char *filename);
+
+    virtual void setMinimumFramesBeforeRead(int32_t numFrames) {}
+
+    static bool   mUseCallback;
+    static int    callbackSize;
+
+protected:
+    oboe::AudioStream *getInputStream();
+    oboe::AudioStream *getOutputStream();
+    int32_t allocateStreamIndex();
+    void freeStreamIndex(int32_t streamIndex);
+
+    virtual void createRecording() {
+        mRecording = std::make_unique<MultiChannelRecording>(mChannelCount,
+                                                             SECONDS_TO_RECORD * mSampleRate);
+    }
+
+    virtual void finishOpen(bool isInput, oboe::AudioStream *oboeStream) {}
+
+    virtual oboe::Result startStreams() = 0;
+
+    std::unique_ptr<float []>    dataBuffer{};
+
+    AudioStreamGateway           audioStreamGateway;
+    OboeStreamCallbackProxy      oboeCallbackProxy;
+
+    std::unique_ptr<MultiChannelRecording>  mRecording{};
+
+    int32_t                      mNextStreamHandle = 0;
+    std::unordered_map<int32_t, std::shared_ptr<oboe::AudioStream>>  mOboeStreams;
+    int32_t                      mFramesPerBurst = 0; // TODO per stream
+    int32_t                      mChannelCount = 0; // TODO per stream
+    int32_t                      mSampleRate = 0; // TODO per stream
+
+    std::atomic<bool>            threadEnabled{false};
+    std::thread                 *dataThread = nullptr;
+
+private:
+};
+
+/**
+ * Test a single input stream.
+ */
+class ActivityTestInput : public ActivityContext {
+public:
+
+    ActivityTestInput() {}
+    virtual ~ActivityTestInput() = default;
+
+    void configureForStart() override;
+
+    double getPeakLevel(int index) override {
+        return mInputAnalyzer.getPeakLevel(index);
+    }
+
+    void runBlockingIO() override;
+
+    InputStreamCallbackAnalyzer  mInputAnalyzer;
+
+    void setMinimumFramesBeforeRead(int32_t numFrames) override {
+        mInputAnalyzer.setMinimumFramesBeforeRead(numFrames);
+        mMinimumFramesBeforeRead = numFrames;
+    }
+
+    int32_t getMinimumFramesBeforeRead() const {
+        return mMinimumFramesBeforeRead;
+    }
+
+protected:
+
+    oboe::Result startStreams() override {
+        mInputAnalyzer.reset();
+        return getInputStream()->requestStart();
+    }
+
+    int32_t mMinimumFramesBeforeRead = 0;
+};
+
+/**
+ * Record a configured input stream and play it back some simple way.
+ */
+class ActivityRecording : public ActivityTestInput {
+public:
+
+    ActivityRecording() {}
+    virtual ~ActivityRecording() = default;
+
+    oboe::Result stop() override {
+
+        oboe::Result resultStopPlayback = stopPlayback();
+        oboe::Result resultStopAudio = ActivityContext::stop();
+
+        return (resultStopPlayback != oboe::Result::OK) ? resultStopPlayback : resultStopAudio;
+    }
+
+    oboe::Result startPlayback() override;
+
+    oboe::Result stopPlayback() override;
+
+    PlayRecordingCallback        mPlayRecordingCallback;
+    oboe::AudioStream           *playbackStream = nullptr;
+
+};
+
+/**
+ * Test a single output stream.
+ */
+class ActivityTestOutput : public ActivityContext {
+public:
+    ActivityTestOutput()
+            : sineOscillators(MAX_SINE_OSCILLATORS)
+            , sawtoothOscillators(MAX_SINE_OSCILLATORS) {}
+
+    virtual ~ActivityTestOutput() = default;
+
+    void close(int32_t streamIndex) override;
+
+    oboe::Result startStreams() override {
+        return getOutputStream()->start();
+    }
+
+    void configureForStart() override;
+
+    virtual void configureStreamGateway();
+
+    void runBlockingIO() override;
+
+    void setChannelEnabled(int channelIndex, bool enabled) override;
+
+    // WARNING - must match order in strings.xml and OboeAudioOutputStream.java
+    enum SignalType {
+        Sine = 0,
+        Sawtooth = 1,
+        FreqSweep = 2,
+        PitchSweep = 3,
+        WhiteNoise = 4
+    };
+
+    void setSignalType(int signalType) override {
+        mSignalType = (SignalType) signalType;
+    }
+
+protected:
+    SignalType                       mSignalType = SignalType::Sine;
+
+    std::vector<SineOscillator>      sineOscillators;
+    std::vector<SawtoothOscillator>  sawtoothOscillators;
+    static constexpr float           kSweepPeriod = 10.0; // for triangle up and down
+
+    // A triangle LFO is shaped into either a linear or an exponential range.
+    TriangleOscillator               mTriangleOscillator;
+    LinearShape                      mLinearShape;
+    ExponentialShape                 mExponentialShape;
+
+    std::unique_ptr<ManyToMultiConverter>   manyToMulti;
+    std::unique_ptr<MonoToMultiConverter>   monoToMulti;
+    std::shared_ptr<flowgraph::SinkFloat>   mSinkFloat;
+    std::shared_ptr<flowgraph::SinkI16>     mSinkI16;
+};
+
+/**
+ * Generate a short beep with a very short attack.
+ * This is used by Java to measure output latency.
+ */
+class ActivityTapToTone : public ActivityTestOutput {
+public:
+    ActivityTapToTone() {}
+    virtual ~ActivityTapToTone() = default;
+
+    void configureForStart() override;
+
+    virtual void setEnabled(bool enabled) override {
+        sawPingGenerator.setEnabled(enabled);
+    }
+
+    SawPingGenerator             sawPingGenerator;
+};
+
+/**
+ * Activity that uses synchronized input/output streams.
+ */
+class ActivityFullDuplex : public ActivityContext {
+public:
+
+    void configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) override;
+
+    virtual int32_t getState() { return -1; }
+    virtual int32_t getResult() { return -1; }
+    virtual bool isAnalyzerDone() { return false; }
+
+    void setMinimumFramesBeforeRead(int32_t numFrames) override {
+        getFullDuplexAnalyzer()->setMinimumFramesBeforeRead(numFrames);
+    }
+
+    virtual FullDuplexAnalyzer *getFullDuplexAnalyzer() = 0;
+
+    int32_t getResetCount() {
+        return getFullDuplexAnalyzer()->getLoopbackProcessor()->getResetCount();
+    }
+
+protected:
+    void createRecording() override {
+        mRecording = std::make_unique<MultiChannelRecording>(2, // output and input
+                                                             SECONDS_TO_RECORD * mSampleRate);
+    }
+};
+
+/**
+ * Echo input to output through a delay line.
+ */
+class ActivityEcho : public ActivityFullDuplex {
+public:
+
+    oboe::Result startStreams() override {
+        return mFullDuplexEcho->start();
+    }
+
+    void configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) override;
+
+    void setDelayTime(double delayTimeSeconds) {
+        if (mFullDuplexEcho) {
+            mFullDuplexEcho->setDelayTime(delayTimeSeconds);
+        }
+    }
+
+    FullDuplexAnalyzer *getFullDuplexAnalyzer() override {
+        return (FullDuplexAnalyzer *) mFullDuplexEcho.get();
+    }
+
+protected:
+    void finishOpen(bool isInput, oboe::AudioStream *oboeStream) override;
+
+private:
+    std::unique_ptr<FullDuplexEcho>   mFullDuplexEcho{};
+};
+
+/**
+ * Measure Round Trip Latency
+ */
+class ActivityRoundTripLatency : public ActivityFullDuplex {
+public:
+
+    oboe::Result startStreams() override {
+        return mFullDuplexLatency->start();
+    }
+
+    void configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) override;
+
+    LatencyAnalyzer *getLatencyAnalyzer() {
+        return mFullDuplexLatency->getLatencyAnalyzer();
+    }
+
+    int32_t getState() override {
+        return getLatencyAnalyzer()->getState();
+    }
+    int32_t getResult() override {
+        return getLatencyAnalyzer()->getState();
+    }
+    bool isAnalyzerDone() override {
+        return mFullDuplexLatency->isDone();
+    }
+
+    FullDuplexAnalyzer *getFullDuplexAnalyzer() override {
+        return (FullDuplexAnalyzer *) mFullDuplexLatency.get();
+    }
+
+protected:
+    void finishOpen(bool isInput, oboe::AudioStream *oboeStream) override;
+
+private:
+    std::unique_ptr<FullDuplexLatency>   mFullDuplexLatency{};
+};
+
+/**
+ * Measure Glitches
+ */
+class ActivityGlitches : public ActivityFullDuplex {
+public:
+
+    oboe::Result startStreams() override {
+        return mFullDuplexGlitches->start();
+    }
+
+    void configureBuilder(bool isInput, oboe::AudioStreamBuilder &builder) override;
+
+    GlitchAnalyzer *getGlitchAnalyzer() {
+        if (!mFullDuplexGlitches) return nullptr;
+        return mFullDuplexGlitches->getGlitchAnalyzer();
+    }
+
+    int32_t getState() override {
+        return getGlitchAnalyzer()->getState();
+    }
+    int32_t getResult() override {
+        return getGlitchAnalyzer()->getResult();
+    }
+    bool isAnalyzerDone() override {
+        return mFullDuplexGlitches->isDone();
+    }
+
+    FullDuplexAnalyzer *getFullDuplexAnalyzer() override {
+        return (FullDuplexAnalyzer *) mFullDuplexGlitches.get();
+    }
+
+protected:
+    void finishOpen(bool isInput, oboe::AudioStream *oboeStream) override;
+
+private:
+    std::unique_ptr<FullDuplexGlitches>   mFullDuplexGlitches{};
+};
+
+/**
+ * Test a single output stream.
+ */
+class ActivityTestDisconnect : public ActivityContext {
+public:
+    ActivityTestDisconnect() {}
+
+    virtual ~ActivityTestDisconnect() = default;
+
+    void close(int32_t streamIndex) override;
+
+    oboe::Result startStreams() override {
+        oboe::AudioStream *outputStream = getOutputStream();
+        if (outputStream) {
+            return outputStream->start();
+        }
+
+        oboe::AudioStream *inputStream = getInputStream();
+        if (inputStream) {
+            return inputStream->start();
+        }
+        return oboe::Result::ErrorNull;
+    }
+
+    void configureForStart() override;
+
+private:
+    std::unique_ptr<SineOscillator>         sineOscillator;
+    std::unique_ptr<MonoToMultiConverter>   monoToMulti;
+    std::shared_ptr<flowgraph::SinkFloat>   mSinkFloat;
+};
+
+/**
+ * Switch between various
+ */
+class NativeAudioContext {
+public:
+
+    ActivityContext *getCurrentActivity() {
+        return currentActivity;
+    };
+
+    void setActivityType(int activityType) {
+        mActivityType = (ActivityType) activityType;
+        switch(mActivityType) {
+            default:
+            case ActivityType::Undefined:
+            case ActivityType::TestOutput:
+                currentActivity = &mActivityTestOutput;
+                break;
+            case ActivityType::TestInput:
+                currentActivity = &mActivityTestInput;
+                break;
+            case ActivityType::TapToTone:
+                currentActivity = &mActivityTapToTone;
+                break;
+            case ActivityType::RecordPlay:
+                currentActivity = &mActivityRecording;
+                break;
+            case ActivityType::Echo:
+                currentActivity = &mActivityEcho;
+                break;
+            case ActivityType::RoundTripLatency:
+                currentActivity = &mActivityRoundTripLatency;
+                break;
+            case ActivityType::Glitches:
+                currentActivity = &mActivityGlitches;
+                break;
+            case ActivityType::TestDisconnect:
+                currentActivity = &mActivityTestDisconnect;
+                break;
+        }
+    }
+
+    void setDelayTime(double delayTimeMillis) {
+        mActivityEcho.setDelayTime(delayTimeMillis);
+    }
+
+    ActivityTestOutput           mActivityTestOutput;
+    ActivityTestInput            mActivityTestInput;
+    ActivityTapToTone            mActivityTapToTone;
+    ActivityRecording            mActivityRecording;
+    ActivityEcho                 mActivityEcho;
+    ActivityRoundTripLatency     mActivityRoundTripLatency;
+    ActivityGlitches             mActivityGlitches;
+    ActivityTestDisconnect       mActivityTestDisconnect;
+
+private:
+
+    // WARNING - must match definitions in TestAudioActivity.java
+    enum ActivityType {
+        Undefined = -1,
+        TestOutput = 0,
+        TestInput = 1,
+        TapToTone = 2,
+        RecordPlay = 3,
+        Echo = 4,
+        RoundTripLatency = 5,
+        Glitches = 6,
+        TestDisconnect = 7,
+    };
+
+    ActivityType                 mActivityType = ActivityType::Undefined;
+    ActivityContext             *currentActivity = &mActivityTestOutput;
+
+};
+
+#endif //NATIVEOBOE_NATIVEAUDIOCONTEXT_H

+ 95 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/OboeStreamCallbackProxy.cpp

@@ -0,0 +1,95 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "common/OboeDebug.h"
+#include "OboeStreamCallbackProxy.h"
+
+// Linear congruential random number generator.
+static uint32_t s_random16() {
+    static uint32_t seed = 1234;
+    seed = ((seed * 31421) + 6927) & 0x0FFFF;
+    return seed;
+}
+
+/**
+ * The random number generator is good for burning CPU because the compiler cannot
+ * easily optimize away the computation.
+ * @param workload number of times to execute the loop
+ * @return a white noise value between -1.0 and +1.0
+ */
+static float s_burnCPU(int32_t workload) {
+    uint32_t random = 0;
+    for (int32_t i = 0; i < workload; i++) {
+        for (int32_t j = 0; j < 10; j++) {
+            random = random ^ s_random16();
+        }
+    }
+    return (random - 32768) * (1.0 / 32768);
+}
+
+bool OboeStreamCallbackProxy::mCallbackReturnStop = false;
+
+int64_t OboeStreamCallbackProxy::getNanoseconds(clockid_t clockId) {
+    struct timespec time;
+    int result = clock_gettime(clockId, &time);
+    if (result < 0) {
+        return result;
+    }
+    return (time.tv_sec * 1e9) + time.tv_nsec;
+}
+
+oboe::DataCallbackResult OboeStreamCallbackProxy::onAudioReady(
+        oboe::AudioStream *audioStream,
+        void *audioData,
+        int numFrames) {
+    oboe::DataCallbackResult callbackResult = oboe::DataCallbackResult::Stop;
+    int64_t startTimeNanos = getNanoseconds();
+
+    mCallbackCount++;
+    mFramesPerCallback = numFrames;
+
+    if (mCallbackReturnStop) {
+        return oboe::DataCallbackResult::Stop;
+    }
+
+    s_burnCPU((int32_t)(mWorkload * kWorkloadScaler * numFrames));
+
+    if (mCallback != nullptr) {
+        callbackResult = mCallback->onAudioReady(audioStream, audioData, numFrames);
+    }
+
+    // Update CPU load
+    double calculationTime = (double)(getNanoseconds() - startTimeNanos);
+    double inverseRealTime = audioStream->getSampleRate() / (1.0e9 * numFrames);
+    double currentCpuLoad = calculationTime * inverseRealTime; // avoid a divide
+    mCpuLoad = (mCpuLoad * 0.95) + (currentCpuLoad * 0.05); // simple low pass filter
+
+    return callbackResult;
+}
+
+void OboeStreamCallbackProxy::onErrorBeforeClose(oboe::AudioStream *audioStream, oboe::Result error) {
+    LOGD("OboeStreamCallbackProxy::%s(%p, %d) called", __func__, audioStream, error);
+    if (mCallback != nullptr) {
+        mCallback->onErrorBeforeClose(audioStream, error);
+    }
+}
+
+void OboeStreamCallbackProxy::onErrorAfterClose(oboe::AudioStream *audioStream, oboe::Result  error) {
+    LOGD("OboeStreamCallbackProxy::%s(%p, %d) called", __func__, audioStream, error);
+    if (mCallback != nullptr) {
+        mCallback->onErrorAfterClose(audioStream, error);
+    }
+}

+ 92 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/OboeStreamCallbackProxy.h

@@ -0,0 +1,92 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_OBOESTREAMCALLBACKPROXY_H
+#define NATIVEOBOE_OBOESTREAMCALLBACKPROXY_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "oboe/Oboe.h"
+
+class OboeStreamCallbackProxy : public oboe::AudioStreamCallback {
+public:
+
+    void setCallback(oboe::AudioStreamCallback *callback) {
+        mCallback = callback;
+        setCallbackCount(0);
+    }
+
+    static void setCallbackReturnStop(bool b) {
+        mCallbackReturnStop = b;
+    }
+
+    int64_t getCallbackCount() {
+        return mCallbackCount;
+    }
+
+    void setCallbackCount(int64_t count) {
+        mCallbackCount = count;
+    }
+
+    int32_t getFramesPerCallback() {
+        return mFramesPerCallback.load();
+    }
+
+    /**
+     * Called when the stream is ready to process audio.
+     */
+    oboe::DataCallbackResult onAudioReady(
+            oboe::AudioStream *audioStream,
+            void *audioData,
+            int numFrames) override;
+
+    void onErrorBeforeClose(oboe::AudioStream *audioStream, oboe::Result error) override;
+
+    void onErrorAfterClose(oboe::AudioStream *audioStream, oboe::Result error) override;
+
+    /**
+     * Specify the amount of artificial workload that will waste CPU cycles
+     * and increase the CPU load.
+     * @param workload typically ranges from 0.0 to 100.0
+     */
+    void setWorkload(double workload) {
+        mWorkload = std::max(0.0, workload);
+    }
+
+    double getWorkload() const {
+        return mWorkload;
+    }
+
+    double getCpuLoad() const {
+        return mCpuLoad;
+    }
+
+    static int64_t getNanoseconds(clockid_t clockId = CLOCK_MONOTONIC);
+
+private:
+    static constexpr int32_t   kWorkloadScaler = 500;
+    double                     mWorkload = 0.0;
+    std::atomic<double>        mCpuLoad{0};
+
+    oboe::AudioStreamCallback *mCallback = nullptr;
+    static bool                mCallbackReturnStop;
+    int64_t                    mCallbackCount = 0;
+    std::atomic<int32_t>       mFramesPerCallback{0};
+};
+
+
+#endif //NATIVEOBOE_OBOESTREAMCALLBACKPROXY_H

+ 33 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/PlayRecordingCallback.cpp

@@ -0,0 +1,33 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "PlayRecordingCallback.h"
+
+/**
+ * Called when the stream is ready to process audio.
+ */
+oboe::DataCallbackResult PlayRecordingCallback::onAudioReady(
+        oboe::AudioStream *audioStream,
+        void *audioData,
+        int numFrames) {
+    float *floatData = (float *)audioData;
+    // Read stored data into the buffer provided.
+    int32_t framesRead = mRecording->read(floatData, numFrames);
+    // LOGI("%s() framesRead = %d, numFrames = %d", __func__, framesRead, numFrames);
+    return framesRead > 0
+           ? oboe::DataCallbackResult::Continue
+           : oboe::DataCallbackResult::Stop;
+}

+ 46 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/PlayRecordingCallback.h

@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_PLAY_RECORDING_CALLBACK_H
+#define NATIVEOBOE_PLAY_RECORDING_CALLBACK_H
+
+#include "oboe/Oboe.h"
+
+#include "MultiChannelRecording.h"
+
+class PlayRecordingCallback : public oboe::AudioStreamCallback {
+public:
+    PlayRecordingCallback() {}
+    ~PlayRecordingCallback() = default;
+
+    void setRecording(MultiChannelRecording *recording) {
+        mRecording = recording;
+    }
+
+    /**
+     * Called when the stream is ready to process audio.
+     */
+    oboe::DataCallbackResult onAudioReady(
+            oboe::AudioStream *audioStream,
+            void *audioData,
+            int numFrames);
+
+private:
+    MultiChannelRecording *mRecording = nullptr;
+};
+
+
+#endif //NATIVEOBOE_PLAYRECORDINGCALLBACK_H

+ 68 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/SawPingGenerator.cpp

@@ -0,0 +1,68 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <unistd.h>
+#include "common/OboeDebug.h"
+#include "oboe/Definitions.h"
+#include "SawPingGenerator.h"
+
+using namespace flowgraph;
+
+SawPingGenerator::SawPingGenerator()
+        : OscillatorBase()
+        , mRequestCount(0)
+        , mAcknowledgeCount(0)
+        , mLevel(0.0f) {
+}
+
+SawPingGenerator::~SawPingGenerator() { }
+
+int32_t SawPingGenerator::onProcess(int numFrames) {
+
+    const float *frequencies = frequency.getBuffer();
+    const float *amplitudes = amplitude.getBuffer();
+    float *buffer = output.getBuffer();
+
+    if (mRequestCount.load() > mAcknowledgeCount.load()) {
+        mPhase = -1.0f;
+        mLevel = 1.0;
+        mAcknowledgeCount++;
+    }
+
+    // Check level to prevent numeric underflow.
+    if (mLevel > 0.000001) {
+        for (int i = 0; i < numFrames; i++) {
+            float sawtooth = incrementPhase(frequencies[i]);
+            *buffer++ = (float) (sawtooth * mLevel * amplitudes[i]);
+            mLevel *= 0.999;
+        }
+    } else {
+        for (int i = 0; i < numFrames; i++) {
+            *buffer++ = 0.0f;
+        }
+    }
+
+    return numFrames;
+}
+
+void SawPingGenerator::setEnabled(bool enabled) {
+    if (enabled) {
+        mRequestCount++;
+    } else {
+        mAcknowledgeCount.store(mRequestCount.load());
+    }
+}
+

+ 44 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/SawPingGenerator.h

@@ -0,0 +1,44 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_SAWPINGGENERATOR_H
+#define NATIVEOBOE_SAWPINGGENERATOR_H
+
+#include <atomic>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "flowgraph/FlowGraphNode.h"
+#include "flowunits/OscillatorBase.h"
+
+class SawPingGenerator : public OscillatorBase {
+public:
+    SawPingGenerator();
+
+    virtual ~SawPingGenerator();
+
+    int32_t onProcess(int numFrames) override;
+
+    void setEnabled(bool enabled);
+
+private:
+    std::atomic<int> mRequestCount; // external thread increments this to request a beep
+    std::atomic<int> mAcknowledgeCount; // audio thread sets this to acknowledge
+    double mLevel;
+};
+
+
+#endif //NATIVEOBOE_SAWPINGGENERATOR_H

+ 438 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/GlitchAnalyzer.h

@@ -0,0 +1,438 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_GLITCHANALYZER_H
+#define OBOETESTER_GLITCHANALYZER_H
+
+#include <cctype>
+
+#include "PseudoRandom.h"
+#include "LatencyAnalyzer.h"
+#include "InfiniteRecording.h"
+
+/**
+ * Output a steady sinewave and analyze the return signal.
+ *
+ * Use a cosine transform to measure the predicted magnitude and relative phase of the
+ * looped back sine wave. Then generate a predicted signal and compare with the actual signal.
+ */
+class GlitchAnalyzer : public LoopbackProcessor {
+public:
+
+    GlitchAnalyzer()
+            : LoopbackProcessor()
+            , mInfiniteRecording(64 * 1024) {}
+
+    int32_t getState() {
+        return mState;
+    }
+
+    float getPeakAmplitude() {
+        return mPeakFollower.getLevel();
+    }
+
+    float getTolerance() {
+        return mTolerance;
+    }
+
+    void setTolerance(float tolerance) {
+        mTolerance = tolerance;
+        mScaledTolerance = mMagnitude * mTolerance;
+    }
+
+    void setMagnitude(double magnitude) {
+        mMagnitude = magnitude;
+        mScaledTolerance = mMagnitude * mTolerance;
+    }
+
+    int32_t getGlitchCount() {
+        return mGlitchCount;
+    }
+
+    int32_t getStateFrameCount(int state) {
+        return mStateFrameCounters[state];
+    }
+
+    double getSignalToNoiseDB() {
+        static const double threshold = 1.0e-14;
+        if (mMeanSquareSignal < threshold || mMeanSquareNoise < threshold) {
+            return 0.0;
+        } else {
+            double signalToNoise = mMeanSquareSignal / mMeanSquareNoise; // power ratio
+            double signalToNoiseDB = 10.0 * log(signalToNoise);
+            if (signalToNoiseDB < MIN_SNRATIO_DB) {
+                LOGD("ERROR - signal to noise ratio is too low! < %d dB. Adjust volume.",
+                     MIN_SNRATIO_DB);
+                setResult(ERROR_VOLUME_TOO_LOW);
+            }
+            return signalToNoiseDB;
+        }
+    }
+
+    void analyze() override {
+        LOGD("GlitchAnalyzer ------------------");
+        LOGD(LOOPBACK_RESULT_TAG "peak.amplitude     = %8f", getPeakAmplitude());
+        LOGD(LOOPBACK_RESULT_TAG "sine.magnitude     = %8f", mMagnitude);
+        LOGD(LOOPBACK_RESULT_TAG "rms.noise          = %8f", mMeanSquareNoise);
+        LOGD(LOOPBACK_RESULT_TAG "signal.to.noise.db = %8.2f", getSignalToNoiseDB());
+        LOGD(LOOPBACK_RESULT_TAG "frames.accumulated = %8d", mFramesAccumulated);
+        LOGD(LOOPBACK_RESULT_TAG "sine.period        = %8d", mSinePeriod);
+        LOGD(LOOPBACK_RESULT_TAG "test.state         = %8d", mState);
+        LOGD(LOOPBACK_RESULT_TAG "frame.count        = %8d", mFrameCounter);
+        // Did we ever get a lock?
+        bool gotLock = (mState == STATE_LOCKED) || (mGlitchCount > 0);
+        if (!gotLock) {
+            LOGD("ERROR - failed to lock on reference sine tone");
+            setResult(ERROR_NO_LOCK);
+        } else {
+            // Only print if meaningful.
+            LOGD(LOOPBACK_RESULT_TAG "glitch.count       = %8d", mGlitchCount);
+            LOGD(LOOPBACK_RESULT_TAG "max.glitch         = %8f", mMaxGlitchDelta);
+            if (mGlitchCount > 0) {
+                LOGD("ERROR - number of glitches > 0");
+                setResult(ERROR_GLITCHES);
+            }
+        }
+    }
+
+    void printStatus() override {
+        LOGD("st = %d, #gl = %3d,", mState, mGlitchCount);
+    }
+
+    double calculateMagnitude(double *phasePtr = NULL) {
+        if (mFramesAccumulated == 0) {
+            return 0.0;
+        }
+        double sinMean = mSinAccumulator / mFramesAccumulated;
+        double cosMean = mCosAccumulator / mFramesAccumulated;
+        double magnitude = 2.0 * sqrt( (sinMean * sinMean) + (cosMean * cosMean ));
+        if( phasePtr != NULL )
+        {
+            double phase = M_PI_2 - atan2( sinMean, cosMean );
+            *phasePtr = phase;
+        }
+        return magnitude;
+    }
+
+    /**
+     * @param frameData contains microphone data with sine signal feedback
+     * @param channelCount
+     */
+    result_code processInputFrame(float *frameData, int channelCount) override {
+        result_code result = RESULT_OK;
+
+        float sample = frameData[0];
+        float peak = mPeakFollower.process(sample);
+        mInfiniteRecording.write(sample);
+
+        // Force a periodic glitch!
+        if (mForceGlitchDuration > 0) {
+            if (mForceGlitchCounter == 0) {
+                LOGE("%s: force a glitch!!", __func__);
+                mForceGlitchCounter = getSampleRate();
+            } else if (mForceGlitchCounter <= mForceGlitchDuration) {
+                sample += (sample > 0.0) ? -0.5f : 0.5f;
+            }
+            --mForceGlitchCounter;
+        }
+
+        mStateFrameCounters[mState]++; // count how many frames we are in each state
+
+        switch (mState) {
+            case STATE_IDLE:
+                mDownCounter--;
+                if (mDownCounter <= 0) {
+                    mState = STATE_IMMUNE;
+                    mDownCounter = IMMUNE_FRAME_COUNT;
+                    mInputPhase = 0.0; // prevent spike at start
+                    mOutputPhase = 0.0;
+                }
+                break;
+
+            case STATE_IMMUNE:
+                mDownCounter--;
+                if (mDownCounter <= 0) {
+                    mState = STATE_WAITING_FOR_SIGNAL;
+                }
+                break;
+
+            case STATE_WAITING_FOR_SIGNAL:
+                if (peak > mThreshold) {
+                    mState = STATE_WAITING_FOR_LOCK;
+                    //LOGD("%5d: switch to STATE_WAITING_FOR_LOCK", mFrameCounter);
+                    resetAccumulator();
+                }
+                break;
+
+            case STATE_WAITING_FOR_LOCK:
+                mSinAccumulator += sample * sinf(mInputPhase);
+                mCosAccumulator += sample * cosf(mInputPhase);
+                mFramesAccumulated++;
+                // Must be a multiple of the period or the calculation will not be accurate.
+                if (mFramesAccumulated == mSinePeriod * PERIODS_NEEDED_FOR_LOCK) {
+                    double phaseOffset = 0.0;
+                    setMagnitude(calculateMagnitude(&phaseOffset));
+//                    LOGD("%s() mag = %f, offset = %f, prev = %f",
+//                            __func__, mMagnitude, mPhaseOffset, mPreviousPhaseOffset);
+                    if (mMagnitude > mThreshold) {
+                        if (abs(phaseOffset) < kMaxPhaseError) {
+                            mState = STATE_LOCKED;
+//                            LOGD("%5d: switch to STATE_LOCKED", mFrameCounter);
+                        }
+                        // Adjust mInputPhase to match measured phase
+                        mInputPhase += phaseOffset;
+                    }
+                    resetAccumulator();
+                }
+                incrementInputPhase();
+                break;
+
+            case STATE_LOCKED: {
+                // Predict next sine value
+                float predicted = sinf(mInputPhase) * mMagnitude;
+                float diff = predicted - sample;
+                float absDiff = fabs(diff);
+                mMaxGlitchDelta = std::max(mMaxGlitchDelta, absDiff);
+                if (absDiff > mScaledTolerance) {
+                    result = ERROR_GLITCHES;
+                    onGlitchStart();
+//                    LOGI("diff glitch detected, absDiff = %g", absDiff);
+                } else {
+                    mSumSquareSignal += predicted * predicted;
+                    mSumSquareNoise += diff * diff;
+                    // Track incoming signal and slowly adjust magnitude to account
+                    // for drift in the DRC or AGC.
+                    mSinAccumulator += sample * sinf(mInputPhase);
+                    mCosAccumulator += sample * cosf(mInputPhase);
+                    mFramesAccumulated++;
+                    // Must be a multiple of the period or the calculation will not be accurate.
+                    if (mFramesAccumulated == mSinePeriod) {
+                        const double coefficient = 0.1;
+                        double phaseOffset = 0.0;
+                        double magnitude = calculateMagnitude(&phaseOffset);
+                        // One pole averaging filter.
+                        setMagnitude((mMagnitude * (1.0 - coefficient)) + (magnitude * coefficient));
+
+                        mMeanSquareNoise = mSumSquareNoise * mInverseSinePeriod;
+                        mMeanSquareSignal = mSumSquareSignal * mInverseSinePeriod;
+                        resetAccumulator();
+
+                        if (abs(phaseOffset) > kMaxPhaseError) {
+                            result = ERROR_GLITCHES;
+                            onGlitchStart();
+                            LOGD("phase glitch detected, phaseOffset = %g", phaseOffset);
+                        } else if (mMagnitude < mThreshold) {
+                            result = ERROR_GLITCHES;
+                            onGlitchStart();
+                            LOGD("magnitude glitch detected, mMagnitude = %g", mMagnitude);
+                        }
+                    }
+                }
+                incrementInputPhase();
+            } break;
+
+            case STATE_GLITCHING: {
+                // Predict next sine value
+                mGlitchLength++;
+                float predicted = sinf(mInputPhase) * mMagnitude;
+                float diff = predicted - sample;
+                float absDiff = fabs(diff);
+                mMaxGlitchDelta = std::max(mMaxGlitchDelta, absDiff);
+                if (absDiff < mScaledTolerance) { // close enough?
+                    // If we get a full sine period of non-glitch samples in a row then consider the glitch over.
+                    // We don't want to just consider a zero crossing the end of a glitch.
+                    if (mNonGlitchCount++ > mSinePeriod) {
+                        onGlitchEnd();
+                    }
+                } else {
+                    mNonGlitchCount = 0;
+                    if (mGlitchLength > (4 * mSinePeriod)) {
+                        relock();
+                    }
+                }
+                incrementInputPhase();
+            } break;
+
+            case NUM_STATES: // not a real state
+                break;
+        }
+
+        mFrameCounter++;
+
+        return result;
+    }
+
+    // advance and wrap phase
+    void incrementInputPhase() {
+        mInputPhase += mPhaseIncrement;
+        if (mInputPhase > M_PI) {
+            mInputPhase -= (2.0 * M_PI);
+        }
+    }
+
+    // advance and wrap phase
+    void incrementOutputPhase() {
+        mOutputPhase += mPhaseIncrement;
+        if (mOutputPhase > M_PI) {
+            mOutputPhase -= (2.0 * M_PI);
+        }
+    }
+
+    /**
+     * @param frameData upon return, contains the reference sine wave
+     * @param channelCount
+     */
+    result_code processOutputFrame(float *frameData, int channelCount) override {
+        float output = 0.0f;
+        // Output sine wave so we can measure it.
+        if (mState != STATE_IDLE) {
+            float sinOut = sinf(mOutputPhase);
+            incrementOutputPhase();
+            output = (sinOut * mOutputAmplitude)
+                     + (mWhiteNoise.nextRandomDouble() * kNoiseAmplitude);
+            // LOGD("%5d: sin(%f) = %f, %f", i, mPhase, sinOut,  mPhaseIncrement);
+        }
+        frameData[0] = output;
+        for (int i = 1; i < channelCount; i++) {
+            frameData[i] = 0.0f;
+        }
+        return RESULT_OK;
+    }
+
+    void onGlitchStart() {
+        mGlitchCount++;
+//        LOGD("%5d: STARTED a glitch # %d", mFrameCounter, mGlitchCount);
+        mState = STATE_GLITCHING;
+        mGlitchLength = 1;
+        mNonGlitchCount = 0;
+        mLastGlitchPosition = mInfiniteRecording.getTotalWritten();
+    }
+
+    void onGlitchEnd() {
+//        LOGD("%5d: ENDED a glitch # %d, length = %d", mFrameCounter, mGlitchCount, mGlitchLength);
+        mState = STATE_LOCKED;
+        resetAccumulator();
+    }
+
+    // reset the sine wave detector
+    void resetAccumulator() {
+        mFramesAccumulated = 0;
+        mSinAccumulator = 0.0;
+        mCosAccumulator = 0.0;
+        mSumSquareSignal = 0.0;
+        mSumSquareNoise = 0.0;
+    }
+
+    void relock() {
+//        LOGD("relock: %d because of a very long %d glitch", mFrameCounter, mGlitchLength);
+        mState = STATE_WAITING_FOR_LOCK;
+        resetAccumulator();
+    }
+
+    void reset() override {
+        LoopbackProcessor::reset();
+        mState = STATE_IDLE;
+        mDownCounter = IDLE_FRAME_COUNT;
+        resetAccumulator();
+    }
+
+    void onStartTest() override {
+        LoopbackProcessor::onStartTest();
+        mSinePeriod = getSampleRate() / kTargetGlitchFrequency;
+        mOutputPhase = 0.0f;
+        mInverseSinePeriod = 1.0 / mSinePeriod;
+        mPhaseIncrement = 2.0 * M_PI * mInverseSinePeriod;
+        mGlitchCount = 0;
+        mMaxGlitchDelta = 0.0;
+        for (int i = 0; i < NUM_STATES; i++) {
+            mStateFrameCounters[i] = 0;
+        }
+    }
+
+
+    int32_t getLastGlitch(float *buffer, int32_t length) {
+        return mInfiniteRecording.readFrom(buffer, mLastGlitchPosition - 32, length);
+    }
+
+private:
+
+    // These must match the values in GlitchActivity.java
+    enum sine_state_t {
+        STATE_IDLE,               // beginning
+        STATE_IMMUNE,             // ignoring input, waiting fo HW to settle
+        STATE_WAITING_FOR_SIGNAL, // looking for a loud signal
+        STATE_WAITING_FOR_LOCK,   // trying to lock onto the phase of the sine
+        STATE_LOCKED,             // locked on the sine wave, looking for glitches
+        STATE_GLITCHING,           // locked on the sine wave but glitching
+        NUM_STATES
+    };
+
+    enum constants {
+        // Arbitrary durations, assuming 48000 Hz
+                IDLE_FRAME_COUNT = 48 * 100,
+        IMMUNE_FRAME_COUNT = 48 * 100,
+        PERIODS_NEEDED_FOR_LOCK = 8,
+        MIN_SNRATIO_DB = 65
+    };
+
+    static constexpr float kNoiseAmplitude = 0.00; // Used to experiment with warbling caused by DRC.
+    static constexpr int kTargetGlitchFrequency = 607;
+    static constexpr double kMaxPhaseError = M_PI * 0.05;
+
+    float   mTolerance = 0.10; // scaled from 0.0 to 1.0
+    double  mThreshold = 0.005;
+    int     mSinePeriod = 1; // this will be set before use
+    double  mInverseSinePeriod = 1.0;
+
+    int32_t mStateFrameCounters[NUM_STATES];
+
+    double  mPhaseIncrement = 0.0;
+    double  mInputPhase = 0.0;
+    double  mOutputPhase = 0.0;
+    double  mMagnitude = 0.0;
+    int32_t mFramesAccumulated = 0;
+    double  mSinAccumulator = 0.0;
+    double  mCosAccumulator = 0.0;
+    float   mMaxGlitchDelta = 0.0f;
+    int32_t mGlitchCount = 0;
+    int32_t mNonGlitchCount = 0;
+    int32_t mGlitchLength = 0;
+    float   mScaledTolerance = 0.0;
+    int     mDownCounter = IDLE_FRAME_COUNT;
+    int32_t mFrameCounter = 0;
+    float   mOutputAmplitude = 0.75;
+
+    int32_t mForceGlitchDuration = 0; // if > 0 then force a glitch for debugging
+    int32_t mForceGlitchCounter = 4 * 48000; // count down and trigger at zero
+
+    // measure background noise continuously as a deviation from the expected signal
+    double  mSumSquareSignal = 0.0;
+    double  mSumSquareNoise = 0.0;
+    double  mMeanSquareSignal = 0.0;
+    double  mMeanSquareNoise = 0.0;
+
+    PeakDetector  mPeakFollower;
+
+    PseudoRandom  mWhiteNoise;
+
+    sine_state_t  mState = STATE_IDLE;
+
+    InfiniteRecording<float> mInfiniteRecording;
+    int64_t       mLastGlitchPosition;
+};
+
+
+#endif //OBOETESTER_GLITCHANALYZER_H

+ 67 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/InfiniteRecording.h

@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef OBOETESTER_INFINITE_RECORDING_H
+#define OBOETESTER_INFINITE_RECORDING_H
+
+#include <memory>
+#include <unistd.h>
+
+/**
+ * Record forever. Keep last data.
+ */
+template <typename T>
+class InfiniteRecording {
+public:
+    InfiniteRecording(size_t maxSamples)
+            : mMaxSamples(maxSamples) {
+        mData = std::make_unique<T[]>(mMaxSamples);
+    }
+
+    int32_t readFrom(T *buffer, size_t position, size_t count) {
+        const size_t maxPosition = mWritten.load();
+        position = std::min(position, maxPosition);
+        size_t numToRead = std::min(count, mMaxSamples);
+        numToRead = std::min(numToRead, maxPosition - position);
+        if (numToRead == 0) return 0;
+        // We may need to read in two parts if it wraps.
+        const size_t offset = position % mMaxSamples;
+        const size_t firstReadSize = std::min(numToRead, mMaxSamples - offset); // till end
+        std::copy(&mData[offset], &mData[offset + firstReadSize], buffer);
+        if (firstReadSize < numToRead) {
+            // Second read needed.
+            std::copy(&mData[0], &mData[numToRead - firstReadSize], &buffer[firstReadSize]);
+        }
+        return numToRead;
+    }
+
+    void write(T sample) {
+        const size_t position = mWritten.load();
+        const size_t offset = position % mMaxSamples;
+        mData[offset] = sample;
+        mWritten++;
+    }
+
+    int64_t getTotalWritten() {
+        return mWritten.load();
+    }
+
+private:
+    std::unique_ptr<T[]> mData;
+    std::atomic<size_t>      mWritten{0};
+    const size_t             mMaxSamples;
+};
+#endif //OBOETESTER_INFINITE_RECORDING_H

+ 611 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/LatencyAnalyzer.h

@@ -0,0 +1,611 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+/**
+ * Tools for measuring latency and for detecting glitches.
+ * These classes are pure math and can be used with any audio system.
+ */
+
+#ifndef ANALYZER_LATENCY_ANALYZER_H
+#define ANALYZER_LATENCY_ANALYZER_H
+
+#include <algorithm>
+#include <assert.h>
+#include <cctype>
+#include <math.h>
+#include <memory>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <vector>
+
+#include "RandomPulseGenerator.h"
+#include "PeakDetector.h"
+#include "PseudoRandom.h"
+
+#define LOOPBACK_RESULT_TAG  "RESULT: "
+
+static constexpr int32_t kDefaultSampleRate = 48000;
+static constexpr int32_t kMillisPerSecond   = 1000;
+static constexpr int32_t kMaxLatencyMillis  = 700;  // arbitrary and generous
+static constexpr double  kMinimumConfidence = 0.2;
+
+typedef struct LatencyReport_s {
+    int32_t latencyInFrames = 0.0;
+    double confidence = 0.0;
+
+    void reset() {
+        latencyInFrames = 0;
+        confidence = 0.0;
+    }
+} LatencyReport;
+
+// Calculate a normalized cross correlation.
+static double calculateNormalizedCorrelation(const float *a,
+                                             const float *b,
+                                             int windowSize)
+{
+    double correlation = 0.0;
+    double sumProducts = 0.0;
+    double sumSquares = 0.0;
+
+    // Correlate a against b.
+    for (int i = 0; i < windowSize; i++) {
+        float s1 = a[i];
+        float s2 = b[i];
+        // Use a normalized cross-correlation.
+        sumProducts += s1 * s2;
+        sumSquares += ((s1 * s1) + (s2 * s2));
+    }
+
+    if (sumSquares >= 1.0e-9) {
+        correlation = (float) (2.0 * sumProducts / sumSquares);
+    }
+    return correlation;
+}
+
+static double calculateRootMeanSquare(float *data, int32_t numSamples) {
+    double sum = 0.0;
+    for (int32_t i = 0; i < numSamples; i++) {
+        float sample = data[i];
+        sum += sample * sample;
+    }
+    return sqrt(sum / numSamples);
+}
+
+/**
+ * Monophonic recording with processing.
+ */
+class AudioRecording
+{
+public:
+    AudioRecording() {
+    }
+    ~AudioRecording() {
+        delete[] mData;
+    }
+
+    void allocate(int maxFrames) {
+        delete[] mData;
+        mData = new float[maxFrames];
+        mMaxFrames = maxFrames;
+    }
+
+    // Write SHORT data from the first channel.
+    int32_t write(int16_t *inputData, int32_t inputChannelCount, int32_t numFrames) {
+        // stop at end of buffer
+        if ((mFrameCounter + numFrames) > mMaxFrames) {
+            numFrames = mMaxFrames - mFrameCounter;
+        }
+        for (int i = 0; i < numFrames; i++) {
+            mData[mFrameCounter++] = inputData[i * inputChannelCount] * (1.0f / 32768);
+        }
+        return numFrames;
+    }
+
+    // Write FLOAT data from the first channel.
+    int32_t write(float *inputData, int32_t inputChannelCount, int32_t numFrames) {
+        // stop at end of buffer
+        if ((mFrameCounter + numFrames) > mMaxFrames) {
+            numFrames = mMaxFrames - mFrameCounter;
+        }
+        for (int i = 0; i < numFrames; i++) {
+            mData[mFrameCounter++] = inputData[i * inputChannelCount];
+        }
+        return numFrames;
+    }
+
+    // Write FLOAT data from the first channel.
+    int32_t write(float sample) {
+        // stop at end of buffer
+        if (mFrameCounter < mMaxFrames) {
+            mData[mFrameCounter++] = sample;
+        }
+        return 1;
+    }
+
+    void clear() {
+        mFrameCounter = 0;
+    }
+    int32_t size() {
+        return mFrameCounter;
+    }
+
+    bool isFull() {
+        return mFrameCounter >= mMaxFrames;
+    }
+
+    float *getData() {
+        return mData;
+    }
+
+    void setSampleRate(int32_t sampleRate) {
+        mSampleRate = sampleRate;
+    }
+
+    int32_t getSampleRate() {
+        return mSampleRate;
+    }
+
+    /**
+     * Square the samples so they are all positive and so the peaks are emphasized.
+     */
+    void square() {
+        for (int i = 0; i < mFrameCounter; i++) {
+            const float sample = mData[i];
+            mData[i] = sample * sample;
+        }
+    }
+
+    /**
+     * Amplify a signal so that the peak matches the specified target.
+     *
+     * @param target final max value
+     * @return gain applied to signal
+     */
+    float normalize(float target) {
+        float maxValue = 1.0e-9f;
+        for (int i = 0; i < mFrameCounter; i++) {
+            maxValue = std::max(maxValue, abs(mData[i]));
+        }
+        float gain = target / maxValue;
+        for (int i = 0; i < mFrameCounter; i++) {
+            mData[i] *= gain;
+        }
+        return gain;
+    }
+
+private:
+    float        *mData = nullptr;
+    int32_t       mFrameCounter = 0;
+    int32_t       mMaxFrames = 0;
+    int32_t       mSampleRate = kDefaultSampleRate; // common default
+};
+
+static int measureLatencyFromPulse(AudioRecording &recorded,
+                                   AudioRecording &pulse,
+                                   int32_t framesPerEncodedBit,
+                                   LatencyReport *report) {
+
+    report->latencyInFrames = 0;
+    report->confidence = 0.0;
+
+    int numCorrelations = recorded.size() - pulse.size();
+    if (numCorrelations < 10) {
+        LOGE("%s() recording too small = %d frames", __func__, recorded.size());
+        return -1;
+    }
+    std::unique_ptr<float[]> correlations= std::make_unique<float[]>(numCorrelations);
+
+    // Correlate pulse against the recorded data.
+    for (int i = 0; i < numCorrelations; i++) {
+        float correlation = (float) calculateNormalizedCorrelation(&recorded.getData()[i],
+                                                                   &pulse.getData()[0],
+                                                                   pulse.size());
+        correlations[i] = correlation;
+    }
+
+    // Find highest peak in correlation array.
+    float peakCorrelation = 0.0;
+    int peakIndex = -1;
+    for (int i = 0; i < numCorrelations; i++) {
+        float value = abs(correlations[i]);
+        if (value > peakCorrelation) {
+            peakCorrelation = value;
+            peakIndex = i;
+        }
+    }
+    if (peakIndex < 0) {
+        LOGE("%s() no signal for correlation", __func__);
+        return -2;
+    }
+
+    report->latencyInFrames = peakIndex;
+    report->confidence = peakCorrelation;
+
+    return 0;
+}
+
+// ====================================================================================
+class LoopbackProcessor {
+public:
+    virtual ~LoopbackProcessor() = default;
+
+    // Note that these values must match the switch in RoundTripLatencyActivity.h
+    enum result_code {
+        RESULT_OK = 0,
+        ERROR_NOISY = -99,
+        ERROR_VOLUME_TOO_LOW,
+        ERROR_VOLUME_TOO_HIGH,
+        ERROR_CONFIDENCE,
+        ERROR_INVALID_STATE,
+        ERROR_GLITCHES,
+        ERROR_NO_LOCK
+    };
+
+    virtual void onStartTest() {
+        reset();
+    }
+
+    virtual void reset() {
+        mResult = 0;
+        mResetCount++;
+    }
+
+    virtual result_code processInputFrame(float *frameData, int channelCount) = 0;
+    virtual result_code processOutputFrame(float *frameData, int channelCount) = 0;
+
+    void process(float *inputData, int inputChannelCount, int numInputFrames,
+                        float *outputData, int outputChannelCount, int numOutputFrames) {
+        int numBoth = std::min(numInputFrames, numOutputFrames);
+        // Process one frame at a time.
+        for (int i = 0; i < numBoth; i++) {
+            processInputFrame(inputData, inputChannelCount);
+            inputData += inputChannelCount;
+            processOutputFrame(outputData, outputChannelCount);
+            outputData += outputChannelCount;
+        }
+        // If there is more input than output.
+        for (int i = numBoth; i < numInputFrames; i++) {
+            processInputFrame(inputData, inputChannelCount);
+            inputData += inputChannelCount;
+        }
+        // If there is more output than input.
+        for (int i = numBoth; i < numOutputFrames; i++) {
+            processOutputFrame(outputData, outputChannelCount);
+            outputData += outputChannelCount;
+        }
+    }
+
+    virtual void analyze() = 0;
+
+    virtual void printStatus() {};
+
+    int32_t getResult() {
+        return mResult;
+    }
+
+    void setResult(int32_t result) {
+        mResult = result;
+    }
+
+    virtual bool isDone() {
+        return false;
+    }
+
+    virtual int save(const char *fileName) {
+        (void) fileName;
+        return -1;
+    }
+
+    virtual int load(const char *fileName) {
+        (void) fileName;
+        return -1;
+    }
+
+    virtual void setSampleRate(int32_t sampleRate) {
+        mSampleRate = sampleRate;
+    }
+
+    int32_t getSampleRate() {
+        return mSampleRate;
+    }
+
+    int32_t getResetCount() {
+        return mResetCount;
+    }
+
+    /** Called when not enough input frames could be read after synchronization.
+     */
+    virtual void onInsufficientRead() {
+        reset();
+    }
+
+protected:
+    int32_t   mResetCount = 0;
+
+private:
+    int32_t mSampleRate = kDefaultSampleRate;
+    int32_t mResult = 0;
+};
+
+class LatencyAnalyzer : public LoopbackProcessor {
+public:
+
+    LatencyAnalyzer() : LoopbackProcessor() {}
+    virtual ~LatencyAnalyzer() = default;
+
+    virtual int32_t getProgress() = 0;
+
+    virtual int getState() = 0;
+
+    // @return latency in frames
+    virtual int32_t getMeasuredLatency() = 0;
+
+    virtual double getMeasuredConfidence() = 0;
+
+    virtual double getBackgroundRMS() = 0;
+
+    virtual double getSignalRMS() = 0;
+
+};
+
+// ====================================================================================
+/**
+ * Measure latency given a loopback stream data.
+ * Use an encoded bit train as the sound source because it
+ * has an unambiguous correlation value.
+ * Uses a state machine to cycle through various stages.
+ *
+ */
+class PulseLatencyAnalyzer : public LatencyAnalyzer {
+public:
+
+    PulseLatencyAnalyzer() : LatencyAnalyzer() {
+        int32_t maxLatencyFrames = getSampleRate() * kMaxLatencyMillis / kMillisPerSecond;
+        int32_t numPulseBits = getSampleRate() * kPulseLengthMillis
+                / (kFramesPerEncodedBit * kMillisPerSecond);
+        int32_t  pulseLength = numPulseBits * kFramesPerEncodedBit;
+        mFramesToRecord = pulseLength + maxLatencyFrames;
+        LOGD("PulseLatencyAnalyzer: allocate recording with %d frames", mFramesToRecord);
+        mAudioRecording.allocate(mFramesToRecord);
+        mAudioRecording.setSampleRate(getSampleRate());
+        generateRandomPulse(pulseLength);
+    }
+
+    void generateRandomPulse(int32_t pulseLength) {
+        mPulse.allocate(pulseLength);
+        RandomPulseGenerator pulser(kFramesPerEncodedBit);
+        for (int i = 0; i < pulseLength; i++) {
+            mPulse.write(pulser.nextFloat());
+        }
+    }
+
+    int getState() override {
+        return mState;
+    }
+
+    void setSampleRate(int32_t sampleRate) override {
+        LoopbackProcessor::setSampleRate(sampleRate);
+        mAudioRecording.setSampleRate(sampleRate);
+    }
+
+    void reset() override {
+        LoopbackProcessor::reset();
+        mDownCounter = getSampleRate() / 2;
+        mLoopCounter = 0;
+
+        mPulseCursor = 0;
+        mBackgroundSumSquare = 0.0f;
+        mBackgroundSumCount = 0;
+        mBackgroundRMS = 0.0f;
+        mSignalRMS = 0.0f;
+
+        LOGD("state reset to STATE_MEASURE_BACKGROUND");
+        mState = STATE_MEASURE_BACKGROUND;
+        mAudioRecording.clear();
+        mLatencyReport.reset();
+    }
+
+    bool hasEnoughData() {
+        return mAudioRecording.isFull();
+    }
+
+    bool isDone() override {
+        return mState == STATE_DONE;
+    }
+
+    int32_t getProgress() override {
+        return mAudioRecording.size();
+    }
+
+    void analyze() override {
+        LOGD("PulseLatencyAnalyzer ---------------");
+        LOGD(LOOPBACK_RESULT_TAG "test.state             = %8d", mState);
+        LOGD(LOOPBACK_RESULT_TAG "test.state.name        = %8s", convertStateToText(mState));
+        LOGD(LOOPBACK_RESULT_TAG "background.rms         = %8f", mBackgroundRMS);
+
+        int32_t newResult = RESULT_OK;
+        if (mState != STATE_GOT_DATA) {
+            LOGD("WARNING - Bad state. Check volume on device.");
+            // setResult(ERROR_INVALID_STATE);
+        } else {
+            LOGD("Please wait several seconds for cross-correlation to complete.");
+            float gain = mAudioRecording.normalize(1.0f);
+            measureLatencyFromPulse(mAudioRecording,
+                                    mPulse,
+                                    kFramesPerEncodedBit,
+                                    &mLatencyReport);
+
+            if (mLatencyReport.confidence < kMinimumConfidence) {
+                LOGD("   ERROR - confidence too low!");
+                newResult = ERROR_CONFIDENCE;
+            } else {
+                mSignalRMS = calculateRootMeanSquare(
+                        &mAudioRecording.getData()[mLatencyReport.latencyInFrames], mPulse.size())
+                                / gain;
+            }
+#if OBOE_ENABLE_LOGGING
+            double latencyMillis = kMillisPerSecond * (double) mLatencyReport.latencyInFrames
+                                   / getSampleRate();
+#endif
+            LOGD(LOOPBACK_RESULT_TAG "latency.frames         = %8d",
+                   mLatencyReport.latencyInFrames);
+            LOGD(LOOPBACK_RESULT_TAG "latency.msec           = %8.2f",
+                   latencyMillis);
+            LOGD(LOOPBACK_RESULT_TAG "latency.confidence     = %8.6f",
+                   mLatencyReport.confidence);
+        }
+        mState = STATE_DONE;
+        if (getResult() == RESULT_OK) {
+            setResult(newResult);
+        }
+    }
+
+    int32_t getMeasuredLatency() override {
+        return mLatencyReport.latencyInFrames;
+    }
+
+    double getMeasuredConfidence() override {
+        return mLatencyReport.confidence;
+    }
+
+    double getBackgroundRMS() override {
+        return mBackgroundRMS;
+    }
+
+    double getSignalRMS() override {
+        return mSignalRMS;
+    }
+
+    void printStatus() override {
+        LOGD("st = %d", mState);
+    }
+
+    result_code processInputFrame(float *frameData, int channelCount) override {
+        echo_state nextState = mState;
+        mLoopCounter++;
+
+        switch (mState) {
+            case STATE_MEASURE_BACKGROUND:
+                // Measure background RMS on channel 0
+                mBackgroundSumSquare += frameData[0] * frameData[0];
+                mBackgroundSumCount++;
+                mDownCounter--;
+                if (mDownCounter <= 0) {
+                    mBackgroundRMS = sqrtf(mBackgroundSumSquare / mBackgroundSumCount);
+                    nextState = STATE_IN_PULSE;
+                    mPulseCursor = 0;
+                    LOGD("LatencyAnalyzer state => STATE_SENDING_PULSE");
+                }
+                break;
+
+            case STATE_IN_PULSE:
+                // Record input until the mAudioRecording is full.
+                mAudioRecording.write(frameData, channelCount, 1);
+                if (hasEnoughData()) {
+                    LOGD("LatencyAnalyzer state => STATE_GOT_DATA");
+                    nextState = STATE_GOT_DATA;
+                }
+                break;
+
+            case STATE_GOT_DATA:
+            case STATE_DONE:
+            default:
+                break;
+        }
+
+        mState = nextState;
+        return RESULT_OK;
+    }
+
+    result_code processOutputFrame(float *frameData, int channelCount) override {
+        switch (mState) {
+            case STATE_IN_PULSE:
+                if (mPulseCursor < mPulse.size()) {
+                    float pulseSample = mPulse.getData()[mPulseCursor++];
+                    for (int i = 0; i < channelCount; i++) {
+                        frameData[i] = pulseSample;
+                    }
+                } else {
+                    for (int i = 0; i < channelCount; i++) {
+                        frameData[i] = 0;
+                    }
+                }
+                break;
+
+            case STATE_MEASURE_BACKGROUND:
+            case STATE_GOT_DATA:
+            case STATE_DONE:
+            default:
+                for (int i = 0; i < channelCount; i++) {
+                    frameData[i] = 0.0f; // silence
+                }
+                break;
+        }
+
+        return RESULT_OK;
+    }
+
+private:
+
+    enum echo_state {
+        STATE_MEASURE_BACKGROUND,
+        STATE_IN_PULSE,
+        STATE_GOT_DATA, // must match RoundTripLatencyActivity.java
+        STATE_DONE,
+    };
+
+    const char *convertStateToText(echo_state state) {
+        const char *result = "Unknown";
+        switch(state) {
+            case STATE_MEASURE_BACKGROUND:
+                result = "INIT";
+                break;
+            case STATE_IN_PULSE:
+                result = "PULSE";
+                break;
+            case STATE_GOT_DATA:
+                result = "GOT_DATA";
+                break;
+            case STATE_DONE:
+                result = "DONE";
+                break;
+        }
+        return result;
+    }
+
+    int32_t         mDownCounter = 500;
+    int32_t         mLoopCounter = 0;
+    echo_state      mState = STATE_MEASURE_BACKGROUND;
+
+    static constexpr int32_t kFramesPerEncodedBit = 8; // multiple of 2
+    static constexpr int32_t kPulseLengthMillis = 500;
+
+    AudioRecording     mPulse;
+    int32_t            mPulseCursor = 0;
+
+    float              mBackgroundSumSquare = 0.0f;
+    int32_t            mBackgroundSumCount = 0;
+    float              mBackgroundRMS = 0.0f;
+    float              mSignalRMS = 0.0f;
+    int32_t            mFramesToRecord = 0;
+
+    AudioRecording     mAudioRecording; // contains only the input after starting the pulse
+    LatencyReport      mLatencyReport;
+};
+
+#endif // ANALYZER_LATENCY_ANALYZER_H

+ 96 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/ManchesterEncoder.h

@@ -0,0 +1,96 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *     http://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.
+ */
+
+#ifndef ANALYZER_MANCHESTER_ENCODER_H
+#define ANALYZER_MANCHESTER_ENCODER_H
+
+#include <cstdint>
+
+/**
+ * Encode bytes using Manchester Coding scheme.
+ *
+ * Manchester Code is self clocking.
+ * There is a transition in the middle of every bit.
+ * Zero is high then low.
+ * One is low then high.
+ *
+ * This avoids having long DC sections that would droop when
+ * passed though analog circuits with AC coupling.
+ *
+ * IEEE 802.3 compatible.
+ */
+
+class ManchesterEncoder {
+public:
+    ManchesterEncoder(int samplesPerPulse)
+            : mSamplesPerPulse(samplesPerPulse)
+            , mSamplesPerPulseHalf(samplesPerPulse / 2)
+            , mCursor(samplesPerPulse) {
+    }
+
+    /**
+     * This will be called when the next byte is needed.
+     * @return
+     */
+    virtual uint8_t onNextByte() = 0;
+
+    /**
+     * Generate the next floating point sample.
+     * @return
+     */
+    virtual float nextFloat() {
+        advanceSample();
+        if (mCurrentBit) {
+            return (mCursor < mSamplesPerPulseHalf) ? -1.0f : 1.0f; // one
+        } else {
+            return (mCursor < mSamplesPerPulseHalf) ? 1.0f : -1.0f; // zero
+        }
+    }
+
+protected:
+    /**
+     * This will be called when a new bit is ready to be encoded.
+     * It can be used to prepare the encoded samples.
+     * @param current 
+     */
+    virtual void onNextBit(bool current) {};
+    
+    void advanceSample() {
+        // Are we ready for a new bit?
+        if (++mCursor >= mSamplesPerPulse) {
+            mCursor = 0;
+            if (mBitsLeft == 0) {
+                mCurrentByte = onNextByte();
+                mBitsLeft = 8;
+            }
+            --mBitsLeft;
+            mCurrentBit = (mCurrentByte >> mBitsLeft) & 1;
+            onNextBit(mCurrentBit);
+        }
+    }
+
+    bool getCurrentBit() {
+        return mCurrentBit;
+    }
+
+    const int mSamplesPerPulse;
+    const int mSamplesPerPulseHalf;
+    int       mCursor;
+    int       mBitsLeft = 0;
+    uint8_t   mCurrentByte = 0;
+    bool      mCurrentBit = false;
+};
+#endif //ANALYZER_MANCHESTER_ENCODER_H

+ 48 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/PeakDetector.h

@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef ANALYZER_PEAK_DETECTOR_H
+#define ANALYZER_PEAK_DETECTOR_H
+
+#include <math.h>
+
+class PeakDetector {
+public:
+
+    void reset() {
+        mLevel = 0.0;
+    }
+
+    double process(double input) {
+        mLevel *= mDecay;
+        input = fabs(input);
+        if (input > mLevel) {
+            mLevel = input;
+        }
+        return mLevel;
+    }
+
+    double getLevel() {
+        return mLevel;
+    }
+
+private:
+    static constexpr float kDefaultDecay = 0.99f;
+
+    double mLevel = 0.0;
+    double mDecay = kDefaultDecay;
+};
+#endif //ANALYZER_PEAK_DETECTOR_H

+ 57 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/PseudoRandom.h

@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+
+#ifndef ANALYZER_PSEUDORANDOM_H
+#define ANALYZER_PSEUDORANDOM_H
+
+#include <cctype>
+
+class PseudoRandom {
+public:
+    PseudoRandom() {}
+    PseudoRandom(int64_t seed)
+            :    mSeed(seed)
+    {}
+
+    /**
+     * Returns the next random double from -1.0 to 1.0
+     *
+     * @return value from -1.0 to 1.0
+     */
+    double nextRandomDouble() {
+        return nextRandomInteger() * (0.5 / (((int32_t)1) << 30));
+    }
+
+    /** Calculate random 32 bit number using linear-congruential method.
+     */
+    int32_t nextRandomInteger() {
+#if __has_builtin(__builtin_mul_overflow) && __has_builtin(__builtin_add_overflow)
+        int64_t prod;
+        // Use values for 64-bit sequence from MMIX by Donald Knuth.
+        __builtin_mul_overflow(mSeed, (int64_t)6364136223846793005, &prod);
+        __builtin_add_overflow(prod, (int64_t)1442695040888963407, &mSeed);
+#else
+        mSeed = (mSeed * (int64_t)6364136223846793005) + (int64_t)1442695040888963407;
+#endif
+        return (int32_t) (mSeed >> 32); // The higher bits have a longer sequence.
+    }
+
+private:
+    int64_t mSeed = 99887766;
+};
+
+#endif //ANALYZER_PSEUDORANDOM_H

+ 41 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/RandomPulseGenerator.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef ANALYZER_RANDOM_PULSE_GENERATOR_H
+#define ANALYZER_RANDOM_PULSE_GENERATOR_H
+
+#include <stdlib.h>
+#include "RoundedManchesterEncoder.h"
+
+/**
+ * Encode random ones and zeros using Manchester Code per IEEE 802.3.
+ */
+class RandomPulseGenerator : public RoundedManchesterEncoder {
+public:
+    RandomPulseGenerator(int samplesPerPulse)
+    : RoundedManchesterEncoder(samplesPerPulse) {
+    }
+
+    /**
+     * This will be called when the next byte is needed.
+     * @return random byte
+     */
+    uint8_t onNextByte() override {
+        return static_cast<uint8_t>(rand() & 0x00FF);
+    }
+};
+
+#endif //ANALYZER_RANDOM_PULSE_GENERATOR_H

+ 89 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/analyzer/RoundedManchesterEncoder.h

@@ -0,0 +1,89 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *     http://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.
+ */
+
+#ifndef ANALYZER_ROUNDED_MANCHESTER_ENCODER_H
+#define ANALYZER_ROUNDED_MANCHESTER_ENCODER_H
+
+#include <math.h>
+#include <memory.h>
+#include <stdlib.h>
+#include "ManchesterEncoder.h"
+
+/**
+ * Encode bytes using Manchester Code.
+ * Round the edges using a half cosine to reduce ringing caused by a hard edge.
+ */
+
+class RoundedManchesterEncoder : public ManchesterEncoder {
+public:
+    RoundedManchesterEncoder(int samplesPerPulse)
+            : ManchesterEncoder(samplesPerPulse) {
+        int rampSize = samplesPerPulse / 4;
+        mZeroAfterZero = std::make_unique<float[]>(samplesPerPulse);
+        mZeroAfterOne = std::make_unique<float[]>(samplesPerPulse);
+
+        int i = 0;
+        for (int j = 0; j < rampSize; j++) {
+            float phase = (j + 1) * M_PI / rampSize;
+            float sample = -cosf(phase);
+            mZeroAfterZero[i] = sample;
+            mZeroAfterOne[i] = 1.0f;
+            i++;
+        }
+        for (int j = 0; j < rampSize; j++) {
+            mZeroAfterZero[i] = 1.0f;
+            mZeroAfterOne[i] = 1.0f;
+            i++;
+        }
+        for (int j = 0; j < rampSize; j++) {
+            float phase = (j + 1) * M_PI / rampSize;
+            float sample = cosf(phase);
+            mZeroAfterZero[i] = sample;
+            mZeroAfterOne[i] = sample;
+            i++;
+        }
+        for (int j = 0; j < rampSize; j++) {
+            mZeroAfterZero[i] = -1.0f;
+            mZeroAfterOne[i] = -1.0f;
+            i++;
+        }
+    }
+
+    void onNextBit(bool current) override {
+        // Do we need to use the rounded edge?
+        mCurrentSamples = (current ^ mPreviousBit)
+                          ? mZeroAfterOne.get()
+                          : mZeroAfterZero.get();
+        mPreviousBit = current;
+    }
+
+
+    float nextFloat() override {
+        advanceSample();
+        float output = mCurrentSamples[mCursor];
+        if (getCurrentBit()) output = -output;
+        return output;
+    }
+
+private:
+
+    bool mPreviousBit = false;
+    float *mCurrentSamples = nullptr;
+    std::unique_ptr<float[]> mZeroAfterZero;
+    std::unique_ptr<float[]> mZeroAfterOne;
+};
+
+#endif //ANALYZER_ROUNDED_MANCHESTER_ENCODER_H

+ 41 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/android_debug.h

@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ *
+ */
+#ifndef NATIVE_AUDIO_ANDROID_DEBUG_H_H
+#define NATIVE_AUDIO_ANDROID_DEBUG_H_H
+#include <android/log.h>
+
+#if 1
+
+#define MODULE_NAME  "OboeAudio"
+#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, MODULE_NAME, __VA_ARGS__)
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, MODULE_NAME, __VA_ARGS__)
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, MODULE_NAME, __VA_ARGS__)
+#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, MODULE_NAME, __VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, MODULE_NAME, __VA_ARGS__)
+#define LOGF(...) __android_log_print(ANDROID_LOG_FATAL, MODULE_NAME, __VA_ARGS__)
+
+#else
+
+#define LOGV(...)
+#define LOGD(...)
+#define LOGI(...)
+#define LOGW(...)
+#define LOGE(...)
+#define LOGF(...)
+#endif
+
+#endif //NATIVE_AUDIO_ANDROID_DEBUG_H_H

+ 35 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ExponentialShape.cpp

@@ -0,0 +1,35 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <math.h>
+
+#include "ExponentialShape.h"
+
+ExponentialShape::ExponentialShape()
+        : FlowGraphFilter(1) {
+}
+
+int32_t ExponentialShape::onProcess(int32_t numFrames) {
+    float *inputs = input.getBuffer();
+    float *outputs = output.getBuffer();
+
+    for (int i = 0; i < numFrames; i++) {
+        float normalizedPhase = (inputs[i] * 0.5) + 0.5;
+        outputs[i] = mMinimum * powf(mRatio, normalizedPhase);
+    }
+
+    return numFrames;
+}

+ 70 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ExponentialShape.h

@@ -0,0 +1,70 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+
+#ifndef OBOETESTER_EXPONENTIAL_SHAPE_H
+#define OBOETESTER_EXPONENTIAL_SHAPE_H
+
+#include "flowgraph/FlowGraphNode.h"
+
+/**
+ * Generate a exponential sweep between min and max.
+ *
+ * The waveform is not band-limited so it will have aliasing artifacts at higher frequencies.
+ */
+class ExponentialShape : public flowgraph::FlowGraphFilter {
+public:
+    ExponentialShape();
+
+    int32_t onProcess(int32_t numFrames) override;
+
+    float getMinimum() const {
+        return mMinimum;
+    }
+
+    /**
+     * The minimum and maximum should not span zero.
+     * They should both be positive or both negative.
+     *
+     * @param minimum
+     */
+    void setMinimum(float minimum) {
+        mMinimum = minimum;
+        mRatio = mMaximum / mMinimum;
+    }
+
+    float getMaximum() const {
+        return mMaximum;
+    }
+
+    /**
+     * The minimum and maximum should not span zero.
+     * They should both be positive or both negative.
+     *
+     * @param maximum
+     */
+    void setMaximum(float maximum) {
+        mMaximum = maximum;
+        mRatio = mMaximum / mMinimum;
+    }
+
+private:
+float mMinimum = 0.0;
+float mMaximum = 1.0;
+float mRatio = 1.0;
+};
+
+#endif //OBOETESTER_EXPONENTIAL_SHAPE_H

+ 42 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ImpulseOscillator.cpp

@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <math.h>
+#include <unistd.h>
+
+#include "ImpulseOscillator.h"
+
+ImpulseOscillator::ImpulseOscillator()
+        : OscillatorBase() {
+}
+
+int32_t ImpulseOscillator::onProcess(int32_t numFrames) {
+    const float *frequencies = frequency.getBuffer();
+    const float *amplitudes = amplitude.getBuffer();
+    float *buffer = output.getBuffer();
+
+    for (int i = 0; i < numFrames; i++) {
+        float value = 0.0f;
+        mPhase += mFrequencyToPhaseIncrement * frequencies[i];
+        if (mPhase >= 1.0f) {
+            value = amplitudes[i]; // spike
+            mPhase -= 2.0f;
+        }
+        *buffer++ = value;
+    }
+
+    return numFrames;
+}

+ 39 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/ImpulseOscillator.h

@@ -0,0 +1,39 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_IMPULSE_GENERATOR_H
+#define NATIVEOBOE_IMPULSE_GENERATOR_H
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "flowgraph/FlowGraphNode.h"
+#include "OscillatorBase.h"
+
+/**
+ * Generate a raw impulse equal to the amplitude.
+ * The output baseline is zero.
+ *
+ * The waveform is not band-limited so it will have aliasing artifacts at higher frequencies.
+ */
+class ImpulseOscillator : public OscillatorBase {
+public:
+    ImpulseOscillator();
+
+    int32_t onProcess(int32_t numFrames) override;
+};
+
+#endif //NATIVEOBOE_IMPULSE_GENERATOR_H

+ 36 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/LinearShape.cpp

@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "LinearShape.h"
+
+using namespace flowgraph;
+
+LinearShape::LinearShape()
+        : FlowGraphFilter(1) {
+}
+
+int32_t LinearShape::onProcess(int numFrames) {
+    float *inputs = input.getBuffer();
+    float *outputs = output.getBuffer();
+
+    for (int i = 0; i < numFrames; i++) {
+        float normalizedPhase = (inputs[i] * 0.5f) + 0.5f; // from 0.0 to 1.0
+        outputs[i] = mMinimum + (normalizedPhase * (mMaximum - mMinimum));
+    }
+
+    return numFrames;
+}

+ 53 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/LinearShape.h

@@ -0,0 +1,53 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+
+#ifndef OBOETESTER_LINEAR_SHAPE_H
+#define OBOETESTER_LINEAR_SHAPE_H
+
+#include "flowgraph/FlowGraphNode.h"
+
+/**
+ * Convert an input between -1.0 and +1.0 to a linear region between min and max.
+ */
+class LinearShape : public flowgraph::FlowGraphFilter {
+public:
+    LinearShape();
+
+    int32_t onProcess(int numFrames) override;
+
+    float getMinimum() const {
+        return mMinimum;
+    }
+
+    void setMinimum(float minimum) {
+        mMinimum = minimum;
+    }
+
+    float getMaximum() const {
+        return mMaximum;
+    }
+
+    void setMaximum(float maximum) {
+        mMaximum = maximum;
+    }
+
+private:
+    float mMinimum = 0.0;
+    float mMaximum = 1.0;
+};
+
+#endif //OBOETESTER_LINEAR_SHAPE_H

+ 26 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/OscillatorBase.cpp

@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 "OscillatorBase.h"
+
+using namespace flowgraph;
+
+OscillatorBase::OscillatorBase()
+        : frequency(*this, 1)
+        , amplitude(*this, 1)
+        , output(*this, 1) {
+    setSampleRate(48000);
+}

+ 100 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/OscillatorBase.h

@@ -0,0 +1,100 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef NATIVEOBOE_OSCILLATORBASE_H
+#define NATIVEOBOE_OSCILLATORBASE_H
+
+#include "flowgraph/FlowGraphNode.h"
+
+/**
+ * Base class for various oscillators.
+ * The oscillator has a phase that ranges from -1.0 to +1.0.
+ * That makes it easier to implement simple algebraic waveforms.
+ *
+ * Subclasses must implement onProcess().
+ *
+ * This module has "frequency" and "amplitude" ports for control.
+ */
+
+class OscillatorBase : public flowgraph::FlowGraphNode {
+public:
+    OscillatorBase();
+
+    virtual ~OscillatorBase() = default;
+
+    void setSampleRate(float sampleRate) {
+        mSampleRate = sampleRate;
+        mFrequencyToPhaseIncrement = 2.0f / sampleRate; // -1 to +1 is a range of 2
+    }
+
+    float getSampleRate() {
+        return mSampleRate;
+    }
+
+    /**
+     * This can be used to set the initial phase of an oscillator before starting.
+     * This is mostly used with an LFO.
+     * Calling this while the oscillator is running will cause sharp pops.
+     * @param phase between -1.0 and +1.0
+     */
+    void setPhase(float phase) {
+        mPhase = phase;
+    }
+
+    float getPhase() {
+        return mPhase;
+    }
+
+    /**
+     * Control the frequency of the oscillator in Hz.
+     */
+    flowgraph::FlowGraphPortFloatInput  frequency;
+
+    /**
+     * Control the linear amplitude of the oscillator.
+     * Silence is 0.0.
+     * A typical full amplitude would be 1.0.
+     */
+    flowgraph::FlowGraphPortFloatInput  amplitude;
+
+    flowgraph::FlowGraphPortFloatOutput output;
+
+protected:
+    /**
+     * Increment phase based on frequency in Hz.
+     * Frequency may be positive or negative.
+     *
+     * Frequency should not exceed +/- Nyquist Rate.
+     * Nyquist Rate is sampleRate/2.
+     */
+    float incrementPhase(float frequency) {
+        mPhase += frequency * mFrequencyToPhaseIncrement;
+        // Wrap phase in the range of -1 to +1
+        if (mPhase >= 1.0f) {
+            mPhase -= 2.0f;
+        } else if (mPhase < -1.0f) {
+            mPhase += 2.0f;
+        }
+        return mPhase;
+    }
+
+    float   mPhase = 0.0f;  // phase that ranges from -1.0 to +1.0
+    float   mSampleRate = 0.0f;
+    float   mFrequencyToPhaseIncrement = 0.0f; // scaler for converting frequency to phase increment
+};
+
+
+#endif //NATIVEOBOE_OSCILLATORBASE_H

+ 39 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SawtoothOscillator.cpp

@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <math.h>
+#include <unistd.h>
+
+#include "SawtoothOscillator.h"
+
+SawtoothOscillator::SawtoothOscillator()
+        : OscillatorBase() {
+}
+
+int32_t SawtoothOscillator::onProcess(int32_t numFrames) {
+    const float *frequencies = frequency.getBuffer();
+    const float *amplitudes = amplitude.getBuffer();
+    float *buffer = output.getBuffer();
+
+    // Use the phase directly as a non-band-limited "sawtooth".
+    // WARNING: This will generate unpleasant aliasing artifacts at higher frequencies.
+    for (int i = 0; i < numFrames; i++) {
+        float phase = incrementPhase(frequencies[i]); // phase ranges from -1 to +1
+        *buffer++ = phase * amplitudes[i];
+    }
+
+    return numFrames;
+}

+ 36 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SawtoothOscillator.h

@@ -0,0 +1,36 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef FLOWGRAPH_SAWTOOTH_OSCILLATOR_H
+#define FLOWGRAPH_SAWTOOTH_OSCILLATOR_H
+
+#include <unistd.h>
+
+#include "OscillatorBase.h"
+
+/**
+ * Oscillator that generates a sawtooth wave at the specified frequency and amplitude.
+ *
+ * The waveform is not band-limited so it will have aliasing artifacts at higher frequencies.
+ */
+class SawtoothOscillator : public OscillatorBase {
+public:
+    SawtoothOscillator();
+
+    int32_t onProcess(int32_t numFrames) override;
+};
+
+#endif //FLOWGRAPH_SAWTOOTH_OSCILLATOR_H

+ 42 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SineOscillator.cpp

@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <math.h>
+#include <unistd.h>
+
+#include "SineOscillator.h"
+
+/*
+ * This calls sinf() so it is not very efficient.
+ * A more efficient implementation might use a wave-table or a polynomial.
+ */
+SineOscillator::SineOscillator()
+        : OscillatorBase() {
+}
+
+int32_t SineOscillator::onProcess(int32_t numFrames) {
+    const float *frequencies = frequency.getBuffer();
+    const float *amplitudes = amplitude.getBuffer();
+    float *buffer = output.getBuffer();
+
+    // Generate sine wave.
+    for (int i = 0; i < numFrames; i++) {
+        float phase = incrementPhase(frequencies[i]); // phase ranges from -1 to +1
+        *buffer++ = sinf(phase * M_PI) * amplitudes[i];
+    }
+
+    return numFrames;
+}

+ 34 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/SineOscillator.h

@@ -0,0 +1,34 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef FLOWGRAPH_SINE_OSCILLATOR_H
+#define FLOWGRAPH_SINE_OSCILLATOR_H
+
+#include <unistd.h>
+
+#include "OscillatorBase.h"
+
+/**
+ * Oscillator that generates a sine wave at the specified frequency and amplitude.
+ */
+class SineOscillator : public OscillatorBase {
+public:
+    SineOscillator();
+
+    int32_t onProcess(int32_t numFrames) override;
+};
+
+#endif //FLOWGRAPH_SINE_OSCILLATOR_H

+ 40 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/TriangleOscillator.cpp

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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 <math.h>
+#include <unistd.h>
+
+#include "TriangleOscillator.h"
+
+TriangleOscillator::TriangleOscillator()
+        : OscillatorBase() {
+}
+
+int32_t TriangleOscillator::onProcess(int32_t numFrames) {
+    const float *frequencies = frequency.getBuffer();
+    const float *amplitudes = amplitude.getBuffer();
+    float *buffer = output.getBuffer();
+
+    // Use the phase directly as a non-band-limited "triangle".
+    // WARNING: This will generate unpleasant aliasing artifacts at higher frequencies.
+    for (int i = 0; i < numFrames; i++) {
+        float phase = incrementPhase(frequencies[i]); // phase ranges from -1 to +1
+        float triangle = 2.0f * ((phase < 0.0f) ? (0.5f + phase): (0.5f - phase));
+        *buffer++ = triangle * amplitudes[i];
+    }
+
+    return numFrames;
+}

+ 39 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/flowunits/TriangleOscillator.h

@@ -0,0 +1,39 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#ifndef FLOWGRAPH_TRIANGLE_OSCILLATOR_H
+#define FLOWGRAPH_TRIANGLE_OSCILLATOR_H
+
+#include <unistd.h>
+
+#include "OscillatorBase.h"
+
+/**
+ * Oscillator that generates a triangle wave at the specified frequency and amplitude.
+ *
+ * The triangle output rises from -1 to +1 when the phase is between -1 and 0.
+ * The triangle output falls from +1 to 11 when the phase is between 0 and +1.
+ *
+ * The waveform is not band-limited so it will have aliasing artifacts at higher frequencies.
+ */
+class TriangleOscillator : public OscillatorBase {
+public:
+    TriangleOscillator();
+
+    int32_t onProcess(int32_t numFrames) override;
+};
+
+#endif //FLOWGRAPH_TRIANGLE_OSCILLATOR_H

+ 625 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/jni-bridge.cpp

@@ -0,0 +1,625 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+#define MODULE_NAME "OboeTester"
+
+#include <cassert>
+#include <cstring>
+#include <jni.h>
+#include <stdint.h>
+#include <thread>
+
+#include "common/OboeDebug.h"
+#include "oboe/Oboe.h"
+
+#include "NativeAudioContext.h"
+
+NativeAudioContext engine;
+
+/*********************************************************************************/
+/**********************  JNI  Prototypes *****************************************/
+/*********************************************************************************/
+extern "C" {
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_openNative(JNIEnv *env, jobject,
+                                                       jint nativeApi,
+                                                       jint sampleRate,
+                                                       jint channelCount,
+                                                       jint format,
+                                                       jint sharingMode,
+                                                       jint performanceMode,
+                                                       jint inputPreset,
+                                                       jint deviceId,
+                                                       jint sessionId,
+                                                       jint framesPerBurst,
+                                                       jboolean channelConversionAllowed,
+                                                       jboolean formatConversionAllowed,
+                                                       jint rateConversionQuality,
+                                                       jboolean isMMap,
+                                                       jboolean isInput);
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_close(JNIEnv *env, jobject, jint);
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setThresholdInFrames(JNIEnv *env, jobject, jint, jint);
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getThresholdInFrames(JNIEnv *env, jobject, jint);
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getBufferCapacityInFrames(JNIEnv *env, jobject, jint);
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setNativeApi(JNIEnv *env, jobject, jint, jint);
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setUseCallback(JNIEnv *env, jclass type,
+                                                                      jboolean useCallback);
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setCallbackReturnStop(JNIEnv *env,
+                                                                             jclass type,
+                                                                             jboolean b);
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setCallbackSize(JNIEnv *env, jclass type,
+                                                            jint callbackSize);
+
+// ================= OboeAudioOutputStream ================================
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setToneEnabled(JNIEnv *env, jobject, jboolean);
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setToneType(JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setAmplitude(JNIEnv *env, jobject, jdouble);
+
+/*********************************************************************************/
+/**********************  JNI Implementations *************************************/
+/*********************************************************************************/
+
+JNIEXPORT jboolean JNICALL
+Java_com_google_sample_oboe_manualtest_NativeEngine_isMMapSupported(JNIEnv *env, jclass type) {
+    return AAudioExtensions::getInstance().isMMapSupported();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_google_sample_oboe_manualtest_NativeEngine_isMMapExclusiveSupported(JNIEnv *env, jclass type) {
+    return AAudioExtensions::getInstance().isMMapExclusiveSupported();
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_NativeEngine_setWorkaroundsEnabled(JNIEnv *env, jclass type,
+                                                                          jboolean enabled) {
+    oboe::OboeGlobals::setWorkaroundsEnabled(enabled);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_openNative(
+        JNIEnv *env, jobject synth,
+        jint nativeApi,
+        jint sampleRate,
+        jint channelCount,
+        jint format,
+        jint sharingMode,
+        jint performanceMode,
+        jint inputPreset,
+        jint deviceId,
+        jint sessionId,
+        jint framesPerBurst,
+        jboolean channelConversionAllowed,
+        jboolean formatConversionAllowed,
+        jint rateConversionQuality,
+        jboolean isMMap,
+        jboolean isInput) {
+    LOGD("OboeAudioStream_openNative: sampleRate = %d, framesPerBurst = %d", sampleRate, framesPerBurst);
+
+    return (jint) engine.getCurrentActivity()->open(nativeApi,
+                                                    sampleRate,
+                                                    channelCount,
+                                                    format,
+                                                    sharingMode,
+                                                    performanceMode,
+                                                    inputPreset,
+                                                    deviceId,
+                                                    sessionId,
+                                                    framesPerBurst,
+                                                    channelConversionAllowed,
+                                                    formatConversionAllowed,
+                                                    rateConversionQuality,
+                                                    isMMap,
+                                                    isInput);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_TestAudioActivity_startNative(JNIEnv *env, jobject) {
+    return (jint) engine.getCurrentActivity()->start();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_TestAudioActivity_pauseNative(JNIEnv *env, jobject) {
+    return (jint) engine.getCurrentActivity()->pause();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_TestAudioActivity_stopNative(JNIEnv *env, jobject) {
+    return (jint) engine.getCurrentActivity()->stop();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_TestAudioActivity_getFramesPerCallback(JNIEnv *env, jobject) {
+    return (jint) engine.getCurrentActivity()->getFramesPerCallback();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_startPlaybackNative(JNIEnv *env, jobject) {
+    return (jint) engine.getCurrentActivity()->startPlayback();
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_close(JNIEnv *env, jobject, jint streamIndex) {
+    engine.getCurrentActivity()->close(streamIndex);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setBufferSizeInFrames(
+        JNIEnv *env, jobject, jint streamIndex, jint threshold) {
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        auto result = oboeStream->setBufferSizeInFrames(threshold);
+        return (!result)
+               ? (jint) result.error()
+               : (jint) result.value();
+    }
+    return (jint) oboe::Result::ErrorNull;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getBufferSizeInFrames(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getBufferSizeInFrames();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getBufferCapacityInFrames(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getBufferCapacityInFrames();
+    }
+    return result;
+}
+
+static int convertAudioApiToNativeApi(oboe::AudioApi audioApi) {
+    switch(audioApi) {
+        case oboe::AudioApi::Unspecified:
+            return NATIVE_MODE_UNSPECIFIED;
+        case oboe::AudioApi::OpenSLES:
+            return NATIVE_MODE_OPENSLES;
+        case oboe::AudioApi::AAudio:
+            return NATIVE_MODE_AAUDIO;
+        default:
+            return -1;
+    }
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getNativeApi(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        oboe::AudioApi audioApi = oboeStream->getAudioApi();
+        result = convertAudioApiToNativeApi(audioApi);
+        LOGD("OboeAudioStream_getNativeApi got %d", result);
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getSampleRate(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getSampleRate();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getSharingMode(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = (jint) oboeStream->getSharingMode();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getPerformanceMode(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = (jint) oboeStream->getPerformanceMode();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getInputPreset(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = (jint) oboeStream->getInputPreset();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getFramesPerBurst(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getFramesPerBurst();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getChannelCount(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getChannelCount();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getFormat(JNIEnv *env, jobject instance, jint streamIndex) {
+        jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = (jint) oboeStream->getFormat();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getDeviceId(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getDeviceId();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getSessionId(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getSessionId();
+    }
+    return result;
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getFramesWritten(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jlong result = (jint) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getFramesWritten();
+    }
+    return result;
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getFramesRead(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jlong result = (jlong) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        result = oboeStream->getFramesRead();
+    }
+    return result;
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getXRunCount(
+        JNIEnv *env, jobject, jint streamIndex) {
+    jint result = (jlong) oboe::Result::ErrorNull;
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        auto oboeResult  = oboeStream->getXRunCount();
+        if (!oboeResult) {
+            result = (jint) oboeResult.error();
+        } else {
+            result = oboeResult.value();
+        }
+    }
+    return result;
+}
+
+JNIEXPORT jlong JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getCallbackCount(
+        JNIEnv *env, jobject) {
+    return engine.getCurrentActivity()->getCallbackCount();
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getLatency(JNIEnv *env, jobject instance, jint streamIndex) {
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        auto result = oboeStream->calculateLatencyMillis();
+        return (!result) ? -1.0 : result.value();
+    }
+    return -1.0;
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getCpuLoad(JNIEnv *env, jobject instance, jint streamIndex) {
+    return engine.getCurrentActivity()->getCpuLoad();
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setWorkload(
+        JNIEnv *env, jobject, jdouble workload) {
+    engine.getCurrentActivity()->setWorkload(workload);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getState(JNIEnv *env, jobject instance, jint streamIndex) {
+    oboe::AudioStream *oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
+    if (oboeStream != nullptr) {
+        auto state = oboeStream->getState();
+        if (state != oboe::StreamState::Starting && state != oboe::StreamState::Started) {
+            oboe::Result result = oboeStream->waitForStateChange(
+                    oboe::StreamState::Uninitialized,
+                    &state, 0);
+
+            if (result != oboe::Result::OK){
+                if (result == oboe::Result::ErrorClosed) {
+                    state = oboe::StreamState::Closed;
+                } else if (result == oboe::Result::ErrorDisconnected){
+                    state = oboe::StreamState::Disconnected;
+                } else {
+                    state = oboe::StreamState::Unknown;
+                }
+            }
+        }
+        return (jint) state;
+    }
+    return -1;
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_AudioInputTester_getPeakLevel(JNIEnv *env,
+                                                          jobject instance,
+                                                          jint index) {
+    return engine.getCurrentActivity()->getPeakLevel(index);
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setUseCallback(JNIEnv *env, jclass type,
+                                                                      jboolean useCallback) {
+    ActivityContext::mUseCallback = useCallback;
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setCallbackReturnStop(JNIEnv *env, jclass type,
+                                                                      jboolean b) {
+    OboeStreamCallbackProxy::setCallbackReturnStop(b);
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_setCallbackSize(JNIEnv *env, jclass type,
+                                                            jint callbackSize) {
+    ActivityContext::callbackSize = callbackSize;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_isMMap(JNIEnv *env, jobject instance, jint streamIndex) {
+    return engine.getCurrentActivity()->isMMapUsed(streamIndex);
+}
+
+// ================= OboeAudioOutputStream ================================
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setToneEnabled(
+        JNIEnv *env, jobject, jboolean enabled) {
+    engine.getCurrentActivity()->setEnabled(enabled);
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setToneType(
+        JNIEnv *env, jobject, jint toneType) {
+// FIXME    engine.getCurrentActivity()->setToneType(toneType);
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setChannelEnabled(
+        JNIEnv *env, jobject, jint channelIndex, jboolean enabled) {
+    engine.getCurrentActivity()->setChannelEnabled(channelIndex, enabled);
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioOutputStream_setSignalType(
+        JNIEnv *env, jobject, jint signalType) {
+    engine.getCurrentActivity()->setSignalType(signalType);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_OboeAudioStream_getOboeVersionNumber(JNIEnv *env,
+                                                                          jclass type) {
+    return OBOE_VERSION_NUMBER;
+}
+
+// ==========================================================================
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_TestAudioActivity_setActivityType(JNIEnv *env,
+                                                                         jobject instance,
+                                                                         jint activityType) {
+    engine.setActivityType(activityType);
+}
+
+// ==========================================================================
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_TestInputActivity_saveWaveFile(JNIEnv *env,
+                                                                        jobject instance,
+                                                                        jstring fileName) {
+    const char *str = env->GetStringUTFChars(fileName, nullptr);
+    LOGD("nativeSaveFile(%s)", str);
+    jint result = engine.getCurrentActivity()->saveWaveFile(str);
+    env->ReleaseStringUTFChars(fileName, str);
+    return result;
+}
+
+// ==========================================================================
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_TestInputActivity_setMinimumFramesBeforeRead(JNIEnv *env,
+                                                                      jobject instance,
+                                                                      jint numFrames) {
+    engine.getCurrentActivity()->setMinimumFramesBeforeRead(numFrames);
+}
+
+// ==========================================================================
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_EchoActivity_setDelayTime(JNIEnv *env,
+                                                                         jobject instance,
+                                                                         jdouble delayTimeSeconds) {
+    engine.setDelayTime(delayTimeSeconds);
+}
+
+// ==========================================================================
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_RoundTripLatencyActivity_getAnalyzerProgress(JNIEnv *env,
+                                                                                    jobject instance) {
+    return engine.mActivityRoundTripLatency.getLatencyAnalyzer()->getProgress();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_RoundTripLatencyActivity_getMeasuredLatency(JNIEnv *env,
+                                                                                   jobject instance) {
+    return engine.mActivityRoundTripLatency.getLatencyAnalyzer()->getMeasuredLatency();
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_RoundTripLatencyActivity_getMeasuredConfidence(JNIEnv *env,
+                                                                                      jobject instance) {
+    return engine.mActivityRoundTripLatency.getLatencyAnalyzer()->getMeasuredConfidence();
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_RoundTripLatencyActivity_getBackgroundRMS(JNIEnv *env,
+                                                                                 jobject instance) {
+    return engine.mActivityRoundTripLatency.getLatencyAnalyzer()->getBackgroundRMS();
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_RoundTripLatencyActivity_getSignalRMS(JNIEnv *env,
+                                                                                 jobject instance) {
+    return engine.mActivityRoundTripLatency.getLatencyAnalyzer()->getSignalRMS();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_AnalyzerActivity_getMeasuredResult(JNIEnv *env,
+                                                                          jobject instance) {
+    return engine.mActivityRoundTripLatency.getLatencyAnalyzer()->getResult();
+}
+
+// ==========================================================================
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_AnalyzerActivity_getAnalyzerState(JNIEnv *env,
+                                                                         jobject instance) {
+    return ((ActivityFullDuplex *)engine.getCurrentActivity())->getState();
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_google_sample_oboe_manualtest_AnalyzerActivity_isAnalyzerDone(JNIEnv *env,
+                                                                       jobject instance) {
+    return ((ActivityFullDuplex *)engine.getCurrentActivity())->isAnalyzerDone();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_AnalyzerActivity_getResetCount(JNIEnv *env,
+                                                                          jobject instance) {
+    return ((ActivityFullDuplex *)engine.getCurrentActivity())->getResetCount();
+}
+
+// ==========================================================================
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_GlitchActivity_getGlitchCount(JNIEnv *env,
+                                                                     jobject instance) {
+    return engine.mActivityGlitches.getGlitchAnalyzer()->getGlitchCount();
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_GlitchActivity_getStateFrameCount(JNIEnv *env,
+                                                                     jobject instance,
+                                                                     jint state) {
+    return engine.mActivityGlitches.getGlitchAnalyzer()->getStateFrameCount(state);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_GlitchActivity_getSignalToNoiseDB(JNIEnv *env,
+                                                                         jobject instance) {
+    return engine.mActivityGlitches.getGlitchAnalyzer()->getSignalToNoiseDB();
+}
+JNIEXPORT jdouble JNICALL
+Java_com_google_sample_oboe_manualtest_GlitchActivity_getPeakAmplitude(JNIEnv *env,
+                                                                       jobject instance) {
+    return engine.mActivityGlitches.getGlitchAnalyzer()->getPeakAmplitude();
+}
+
+JNIEXPORT void JNICALL
+Java_com_google_sample_oboe_manualtest_GlitchActivity_setTolerance(JNIEnv *env,
+                                                                   jobject instance,
+                                                                   jfloat tolerance) {
+    if (engine.mActivityGlitches.getGlitchAnalyzer()) {
+        engine.mActivityGlitches.getGlitchAnalyzer()->setTolerance(tolerance);
+    }
+}
+
+JNIEXPORT jint JNICALL
+Java_com_google_sample_oboe_manualtest_ManualGlitchActivity_getGlitch(JNIEnv *env, jobject instance,
+                                                                      jfloatArray waveform_) {
+    float *waveform = env->GetFloatArrayElements(waveform_, nullptr);
+    jsize length = env->GetArrayLength(waveform_);
+    jsize numSamples = 0;
+    auto *analyzer = engine.mActivityGlitches.getGlitchAnalyzer();
+    if (analyzer) {
+        numSamples = analyzer->getLastGlitch(waveform, length);
+    }
+
+    env->ReleaseFloatArrayElements(waveform_, waveform, 0);
+    return numSamples;
+}
+
+}

+ 145 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/unused/unused.h

@@ -0,0 +1,145 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+
+#ifndef OBOETESTER_UNUSED_H
+#define OBOETESTER_UNUSED_H
+
+// Store this code for later use.
+#if 0
+
+/*
+
+FIR filter designed with
+http://t-filter.appspot.com
+
+sampling frequency: 48000 Hz
+
+* 0 Hz - 8000 Hz
+  gain = 1.2
+  desired ripple = 5 dB
+  actual ripple = 5.595266169703693 dB
+
+* 12000 Hz - 20000 Hz
+  gain = 0
+  desired attenuation = -40 dB
+  actual attenuation = -37.58691566571914 dB
+
+*/
+
+#define FILTER_TAP_NUM 11
+
+static const float sFilterTaps8000[FILTER_TAP_NUM] = {
+        -0.05944219353343189f,
+        -0.07303434839503208f,
+        -0.037690487672689066f,
+         0.1870480506596512f,
+         0.3910337357836833f,
+         0.5333672385425637f,
+         0.3910337357836833f,
+         0.1870480506596512f,
+        -0.037690487672689066f,
+        -0.07303434839503208f,
+        -0.05944219353343189f
+};
+
+class LowPassFilter {
+public:
+
+    /*
+     * Filter one input sample.
+     * @return filtered output
+     */
+    float filter(float input) {
+        float output = 0.0f;
+        mX[mCursor] = input;
+        // Index backwards over x.
+        int xIndex = mCursor + FILTER_TAP_NUM;
+        // Write twice so we avoid having to wrap in the middle of the convolution.
+        mX[xIndex] = input;
+        for (int i = 0; i < FILTER_TAP_NUM; i++) {
+            output += sFilterTaps8000[i] * mX[xIndex--];
+        }
+        if (++mCursor >= FILTER_TAP_NUM) {
+            mCursor = 0;
+        }
+        return output;
+    }
+
+    /**
+     * @return true if PASSED
+     */
+    bool test() {
+        // Measure the impulse of the filter at different phases so we exercise
+        // all the wraparound cases in the FIR.
+        for (int offset = 0; offset < (FILTER_TAP_NUM * 2); offset++ ) {
+            // LOGD("LowPassFilter: cursor = %d\n", mCursor);
+            // Offset by one each time.
+            if (filter(0.0f) != 0.0f) {
+                LOGD("ERROR: filter should return 0.0 before impulse response\n");
+                return false;
+            }
+            for (int i = 0; i < FILTER_TAP_NUM; i++) {
+                float output = filter((i == 0) ? 1.0f : 0.0f); // impulse
+                if (output != sFilterTaps8000[i]) {
+                    LOGD("ERROR: filter should return impulse response\n");
+                    return false;
+                }
+            }
+            for (int i = 0; i < FILTER_TAP_NUM; i++) {
+                if (filter(0.0f) != 0.0f) {
+                    LOGD("ERROR: filter should return 0.0 after impulse response\n");
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+private:
+    float   mX[FILTER_TAP_NUM * 2]{}; // twice as big as needed to avoid wrapping
+    int32_t mCursor = 0;
+};
+
+/**
+ * Low pass filter the recording using a simple FIR filter.
+ * Note that the lowpass filter cutoff tracks the sample rate.
+ * That is OK because the impulse width is a fixed number of samples.
+ */
+void lowPassFilter() {
+    for (int i = 0; i < mFrameCounter; i++) {
+        mData[i] = mLowPassFilter.filter(mData[i]);
+    }
+}
+
+/**
+ * Remove DC offset using a one-pole one-zero IIR filter.
+ */
+void dcBlocker() {
+    const float R = 0.996; // narrow notch at zero Hz
+    float x1 = 0.0;
+    float y1 = 0.0;
+    for (int i = 0; i < mFrameCounter; i++) {
+        const float x = mData[i];
+        const float y = x - x1 + (R * y1);
+        mData[i] = y;
+        y1 = y;
+        x1 = x;
+    }
+}
+#endif
+
+#endif //OBOETESTER_UNUSED_H

+ 132 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/util/WaveFileWriter.cpp

@@ -0,0 +1,132 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *     http://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 "WaveFileWriter.h"
+
+void WaveFileWriter::WaveFileWriter::write(float value) {
+    if (!headerWritten) {
+        writeHeader();
+    }
+    if (bitsPerSample == 24) {
+        writePCM24(value);
+    } else {
+        writePCM16(value);
+    }
+}
+
+void WaveFileWriter::write(float *buffer, int32_t startSample, int32_t numSamples) {
+    for (int32_t i = 0; i < numSamples; i++) {
+        write(buffer[startSample + i]);
+    }
+}
+
+void WaveFileWriter::writeIntLittle(int32_t n) {
+    writeByte(n);
+    writeByte(n >> 8);
+    writeByte(n >> 16);
+    writeByte(n >> 24);
+}
+
+void WaveFileWriter::writeShortLittle(int16_t n) {
+    writeByte(n);
+    writeByte(n >> 8);
+}
+
+void WaveFileWriter::writeFormatChunk() {
+    int32_t bytesPerSample = (bitsPerSample + 7) / 8;
+
+    writeByte('f');
+    writeByte('m');
+    writeByte('t');
+    writeByte(' ');
+    writeIntLittle(16); // chunk size
+    writeShortLittle(WAVE_FORMAT_PCM);
+    writeShortLittle((int16_t) mSamplesPerFrame);
+    writeIntLittle(mFrameRate);
+    // bytes/second
+    writeIntLittle(mFrameRate * mSamplesPerFrame * bytesPerSample);
+    // block align
+    writeShortLittle((int16_t) (mSamplesPerFrame * bytesPerSample));
+    writeShortLittle((int16_t) bitsPerSample);
+}
+
+void WaveFileWriter::writeDataChunkHeader() {
+    writeByte('d');
+    writeByte('a');
+    writeByte('t');
+    writeByte('a');
+    // Maximum size is not strictly correct but is commonly used
+    // when we do not know the final size.
+    writeIntLittle(INT32_MAX);
+}
+
+void WaveFileWriter::writeHeader() {
+    writeRiffHeader();
+    writeFormatChunk();
+    writeDataChunkHeader();
+    headerWritten = true;
+}
+
+// Write lower 8 bits. Upper bits ignored.
+void WaveFileWriter::writeByte(uint8_t b) {
+    mOutputStream->write(b);
+    bytesWritten += 1;
+}
+
+void WaveFileWriter::writePCM24(float value) {
+    // Offset before casting so that we can avoid using floor().
+    // Also round by adding 0.5 so that very small signals go to zero.
+    float temp = (PCM24_MAX * value) + 0.5 - PCM24_MIN;
+    int32_t sample = ((int) temp) + PCM24_MIN;
+    // clip to 24-bit range
+    if (sample > PCM24_MAX) {
+        sample = PCM24_MAX;
+    } else if (sample < PCM24_MIN) {
+        sample = PCM24_MIN;
+    }
+    // encode as little-endian
+    writeByte(sample); // little end
+    writeByte(sample >> 8); // middle
+    writeByte(sample >> 16); // big end
+}
+
+void WaveFileWriter::writePCM16(float value) {
+    // Offset before casting so that we can avoid using floor().
+    // Also round by adding 0.5 so that very small signals go to zero.
+    float temp = (INT16_MAX * value) + 0.5 - INT16_MIN;
+    int32_t sample = ((int) temp) + INT16_MIN;
+    if (sample > INT16_MAX) {
+        sample = INT16_MAX;
+    } else if (sample < INT16_MIN) {
+        sample = INT16_MIN;
+    }
+    writeByte(sample); // little end
+    writeByte(sample >> 8); // big end
+}
+
+void WaveFileWriter::writeRiffHeader() {
+    writeByte('R');
+    writeByte('I');
+    writeByte('F');
+    writeByte('F');
+    // Maximum size is not strictly correct but is commonly used
+    // when we do not know the final size.
+    writeIntLittle(INT32_MAX);
+    writeByte('W');
+    writeByte('A');
+    writeByte('V');
+    writeByte('E');
+}

+ 154 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/cpp/util/WaveFileWriter.h

@@ -0,0 +1,154 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *     http://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.
+ */
+
+// Based on the WaveFileWriter in Java from the open source JSyn library by Phil Burk
+// https://github.com/philburk/jsyn/blob/master/src/com/jsyn/util/WaveFileWriter.java
+
+#ifndef UTIL_WAVE_FILE_WRITER
+#define UTIL_WAVE_FILE_WRITER
+
+#include <cassert>
+#include <stdio.h>
+
+class WaveFileOutputStream {
+public:
+    virtual void write(uint8_t b) = 0;
+};
+
+/**
+ * Write audio data to a WAV file.
+ *
+ * <pre>
+ * <code>
+ * WaveFileWriter writer = new WaveFileWriter(waveFileOutputStream);
+ * writer.setFrameRate(48000);
+ * writer.setBitsPerSample(24);
+ * writer.write(floatArray, 0, numSamples);
+ * writer.close();
+ * </code>
+ * </pre>
+ *
+ */
+class WaveFileWriter {
+public:
+
+    /**
+     * Create an object that will write a WAV file image to the specified stream.
+     *
+     * @param outputStream stream to receive the bytes
+     * @throws FileNotFoundException
+     */
+    WaveFileWriter(WaveFileOutputStream *outputStream) {
+        mOutputStream = outputStream;
+    }
+
+    /**
+     * @param frameRate default is 44100
+     */
+    void setFrameRate(int32_t frameRate) {
+        mFrameRate = frameRate;
+    }
+
+    int32_t getFrameRate() const {
+        return mFrameRate;
+    }
+
+    /**
+     * For stereo, set this to 2. Default is mono = 1.
+     * Also known as ChannelCount
+     */
+    void setSamplesPerFrame(int32_t samplesPerFrame) {
+        mSamplesPerFrame = samplesPerFrame;
+    }
+
+    int32_t getSamplesPerFrame() const {
+        return mSamplesPerFrame;
+    }
+
+    /** Only 16 or 24 bit samples supported at the moment. Default is 16. */
+    void setBitsPerSample(int32_t bits) {
+        assert((bits == 16) || (bits == 24));
+        bitsPerSample = bits;
+    }
+
+    int32_t getBitsPerSample() const {
+        return bitsPerSample;
+    }
+
+    void close() {
+    }
+
+    /** Write single audio data value to the WAV file. */
+    void write(float value);
+
+    /**
+     * Write a buffer to the WAV file.
+     */
+    void write(float *buffer, int32_t startSample, int32_t numSamples);
+
+private:
+    /**
+     * Write a 32 bit integer to the stream in Little Endian format.
+     */
+    void writeIntLittle(int32_t n);
+
+    /**
+     * Write a 16 bit integer to the stream in Little Endian format.
+     */
+    void writeShortLittle(int16_t n);
+
+    /**
+     * Write an 'fmt ' chunk to the WAV file containing the given information.
+     */
+    void writeFormatChunk();
+
+    /**
+     * Write a 'data' chunk header to the WAV file. This should be followed by call to
+     * writeShortLittle() to write the data to the chunk.
+     */
+    void writeDataChunkHeader();
+
+    /**
+     * Write a simple WAV header for PCM data.
+     */
+    void writeHeader();
+
+    // Write lower 8 bits. Upper bits ignored.
+    void writeByte(uint8_t b);
+
+    void writePCM24(float value);
+
+    void writePCM16(float value);
+
+    /**
+     * Write a 'RIFF' file header and a 'WAVE' ID to the WAV file.
+     */
+    void writeRiffHeader();
+
+    static constexpr int WAVE_FORMAT_PCM = 1;
+    WaveFileOutputStream *mOutputStream = nullptr;
+    int32_t mFrameRate = 48000;
+    int32_t mSamplesPerFrame = 1;
+    int32_t bitsPerSample = 16;
+    int32_t bytesWritten = 0;
+    bool headerWritten = false;
+    static constexpr int32_t PCM24_MIN = -(1 << 23);
+    static constexpr int32_t PCM24_MAX = (1 << 23) - 1;
+
+};
+
+#endif /* UTIL_WAVE_FILE_WRITER */
+

+ 58 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceAdapter.java

@@ -0,0 +1,58 @@
+package com.google.sample.audio_device;
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import com.google.sample.oboe.manualtest.R;
+
+/**
+ * Provides views for a list of audio devices. Usually used as an Adapter for a Spinner or ListView.
+ */
+public class AudioDeviceAdapter extends ArrayAdapter<AudioDeviceListEntry> {
+
+    public AudioDeviceAdapter(Context context) {
+        super(context, R.layout.audio_devices);
+    }
+
+    @NonNull
+    @Override
+    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+        return getDropDownView(position, convertView, parent);
+    }
+
+    @Override
+    public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+        View rowView = convertView;
+        if (rowView == null) {
+            LayoutInflater inflater = LayoutInflater.from(parent.getContext());
+            rowView = inflater.inflate(R.layout.audio_devices, parent, false);
+        }
+
+        TextView deviceName = (TextView) rowView.findViewById(R.id.device_name);
+        AudioDeviceListEntry deviceInfo = getItem(position);
+        deviceName.setText(deviceInfo.getName());
+
+        return rowView;
+    }
+}

+ 140 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceInfoConverter.java

@@ -0,0 +1,140 @@
+package com.google.sample.audio_device;
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+import android.media.AudioDeviceInfo;
+
+class AudioDeviceInfoConverter {
+
+    /**
+     * Converts an {@link AudioDeviceInfo} object into a human readable representation
+     *
+     * @param adi The AudioDeviceInfo object to be converted to a String
+     * @return String containing all the information from the AudioDeviceInfo object
+     */
+    static String toString(AudioDeviceInfo adi){
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("Id: ");
+        sb.append(adi.getId());
+
+        sb.append("\nProduct name: ");
+        sb.append(adi.getProductName());
+
+        sb.append("\nType: ");
+        sb.append(typeToString(adi.getType()));
+
+        sb.append("\nIs source: ");
+        sb.append((adi.isSource() ? "Yes" : "No"));
+
+        sb.append("\nIs sink: ");
+        sb.append((adi.isSink() ? "Yes" : "No"));
+
+        sb.append("\nChannel counts: ");
+        int[] channelCounts = adi.getChannelCounts();
+        sb.append(intArrayToString(channelCounts));
+
+        sb.append("\nChannel masks: ");
+        int[] channelMasks = adi.getChannelMasks();
+        sb.append(intArrayToString(channelMasks));
+
+        sb.append("\nChannel index masks: ");
+        int[] channelIndexMasks = adi.getChannelIndexMasks();
+        sb.append(intArrayToString(channelIndexMasks));
+
+        sb.append("\nEncodings: ");
+        int[] encodings = adi.getEncodings();
+        sb.append(intArrayToString(encodings));
+
+        sb.append("\nSample Rates: ");
+        int[] sampleRates = adi.getSampleRates();
+        sb.append(intArrayToString(sampleRates));
+
+        return sb.toString();
+    }
+
+    /**
+     * Converts an integer array into a string where each int is separated by a space
+     *
+     * @param integerArray the integer array to convert to a string
+     * @return string containing all the integer values separated by spaces
+     */
+    private static String intArrayToString(int[] integerArray){
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < integerArray.length; i++){
+            sb.append(integerArray[i]);
+            if (i != integerArray.length -1) sb.append(" ");
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Converts the value from {@link AudioDeviceInfo#getType()} into a human
+     * readable string
+     * @param type One of the {@link AudioDeviceInfo}.TYPE_* values
+     *             e.g. AudioDeviceInfo.TYPE_BUILT_IN_SPEAKER
+     * @return string which describes the type of audio device
+     */
+    static String typeToString(int type){
+        switch (type) {
+            case AudioDeviceInfo.TYPE_AUX_LINE:
+                return "auxiliary line-level connectors";
+            case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP:
+                return "Bluetooth device supporting the A2DP profile";
+            case AudioDeviceInfo.TYPE_BLUETOOTH_SCO:
+                return "Bluetooth device typically used for telephony";
+            case AudioDeviceInfo.TYPE_BUILTIN_EARPIECE:
+                return "built-in earphone speaker";
+            case AudioDeviceInfo.TYPE_BUILTIN_MIC:
+                return "built-in microphone";
+            case AudioDeviceInfo.TYPE_BUILTIN_SPEAKER:
+                return "built-in speaker";
+            case AudioDeviceInfo.TYPE_BUS:
+                return "BUS";
+            case AudioDeviceInfo.TYPE_DOCK:
+                return "DOCK";
+            case AudioDeviceInfo.TYPE_FM:
+                return "FM";
+            case AudioDeviceInfo.TYPE_FM_TUNER:
+                return "FM tuner";
+            case AudioDeviceInfo.TYPE_HDMI:
+                return "HDMI";
+            case AudioDeviceInfo.TYPE_HDMI_ARC:
+                return "HDMI audio return channel";
+            case AudioDeviceInfo.TYPE_IP:
+                return "IP";
+            case AudioDeviceInfo.TYPE_LINE_ANALOG:
+                return "line analog";
+            case AudioDeviceInfo.TYPE_LINE_DIGITAL:
+                return "line digital";
+            case AudioDeviceInfo.TYPE_TELEPHONY:
+                return "telephony";
+            case AudioDeviceInfo.TYPE_TV_TUNER:
+                return "TV tuner";
+            case AudioDeviceInfo.TYPE_USB_ACCESSORY:
+                return "USB accessory";
+            case AudioDeviceInfo.TYPE_USB_DEVICE:
+                return "USB device";
+            case AudioDeviceInfo.TYPE_WIRED_HEADPHONES:
+                return "wired headphones";
+            case AudioDeviceInfo.TYPE_WIRED_HEADSET:
+                return "wired headset";
+            default:
+            case AudioDeviceInfo.TYPE_UNKNOWN:
+                return "unknown";
+        }
+    }
+}

+ 93 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceListEntry.java

@@ -0,0 +1,93 @@
+package com.google.sample.audio_device;
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+import android.annotation.TargetApi;
+import android.media.AudioDeviceInfo;
+import android.media.AudioManager;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * POJO which represents basic information for an audio device.
+ *
+ * Example: id: 8, deviceName: "built-in speaker"
+ */
+public class AudioDeviceListEntry {
+
+    private int mId;
+    private String mName;
+
+    public AudioDeviceListEntry(int deviceId, String deviceName){
+        mId = deviceId;
+        mName = deviceName;
+    }
+
+    public int getId() {
+        return mId;
+    }
+
+    public String getName(){
+        return mName;
+    }
+
+    public String toString(){
+        return getName();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        AudioDeviceListEntry that = (AudioDeviceListEntry) o;
+
+        if (mId != that.mId) return false;
+        return mName != null ? mName.equals(that.mName) : that.mName == null;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = mId;
+        result = 31 * result + (mName != null ? mName.hashCode() : 0);
+        return result;
+    }
+
+    /**
+     * Create a list of AudioDeviceListEntry objects from a list of AudioDeviceInfo objects.
+     *
+     * @param devices A list of {@Link AudioDeviceInfo} objects
+     * @param directionType Only audio devices with this direction will be included in the list.
+     *                      Valid values are GET_DEVICES_ALL, GET_DEVICES_OUTPUTS and
+     *                      GET_DEVICES_INPUTS.
+     * @return A list of AudioDeviceListEntry objects
+     */
+    @TargetApi(23)
+    static List<AudioDeviceListEntry> createListFrom(AudioDeviceInfo[] devices, int directionType){
+
+        List<AudioDeviceListEntry> listEntries = new Vector<>();
+        for (AudioDeviceInfo info : devices) {
+            if (directionType == AudioManager.GET_DEVICES_ALL ||
+                    (directionType == AudioManager.GET_DEVICES_OUTPUTS && info.isSink()) ||
+                    (directionType == AudioManager.GET_DEVICES_INPUTS && info.isSource())) {
+                listEntries.add(new AudioDeviceListEntry(info.getId(), info.getProductName() + " " +
+                                AudioDeviceInfoConverter.typeToString(info.getType())));
+            }
+        }
+        return listEntries;
+    }
+}

+ 127 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/audio_device/AudioDeviceSpinner.java

@@ -0,0 +1,127 @@
+package com.google.sample.audio_device;
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Resources.Theme;
+import android.media.AudioDeviceCallback;
+import android.media.AudioDeviceInfo;
+import android.media.AudioManager;
+import android.util.AttributeSet;
+import android.widget.Spinner;
+
+import com.google.sample.oboe.manualtest.R;
+
+import java.util.List;
+
+public class AudioDeviceSpinner extends Spinner {
+
+    private static final int AUTO_SELECT_DEVICE_ID = 0;
+    private static final String TAG = AudioDeviceSpinner.class.getName();
+    private int mDirectionType;
+    private AudioDeviceAdapter mDeviceAdapter;
+    private AudioManager mAudioManager;
+    private Context mContext;
+
+    public AudioDeviceSpinner(Context context){
+        super(context);
+        setup(context);
+    }
+
+    public AudioDeviceSpinner(Context context, int mode){
+        super(context, mode);
+        setup(context);
+    }
+
+    public AudioDeviceSpinner(Context context, AttributeSet attrs){
+        super(context, attrs);
+        setup(context);
+    }
+
+    public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr){
+        super(context, attrs, defStyleAttr);
+        setup(context);
+    }
+
+    public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode){
+        super(context, attrs, defStyleAttr, mode);
+        setup(context);
+    }
+
+    public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr,
+                              int defStyleRes, int mode){
+        super(context, attrs, defStyleAttr, defStyleRes, mode);
+        setup(context);
+    }
+
+    public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr,
+                              int defStyleRes, int mode, Theme popupTheme){
+        super(context, attrs, defStyleAttr, defStyleRes, mode, popupTheme);
+        setup(context);
+    }
+
+    private void setup(Context context){
+        mContext = context;
+
+        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+
+        mDeviceAdapter = new AudioDeviceAdapter(context);
+        setAdapter(mDeviceAdapter);
+
+        // Add a default entry to the list and select it
+        mDeviceAdapter.add(new AudioDeviceListEntry(AUTO_SELECT_DEVICE_ID,
+                mContext.getString(R.string.auto_select)));
+        setSelection(0);
+
+    }
+
+    @TargetApi(23)
+    public void setDirectionType(int directionType){
+        this.mDirectionType = directionType;
+        setupAudioDeviceCallback();
+    }
+
+    @TargetApi(23)
+    private void setupAudioDeviceCallback(){
+
+        // Note that we will immediately receive a call to onDevicesAdded with the list of
+        // devices which are currently connected.
+        mAudioManager.registerAudioDeviceCallback(new AudioDeviceCallback() {
+            @Override
+            public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
+                List<AudioDeviceListEntry> deviceList =
+                        AudioDeviceListEntry.createListFrom(addedDevices, mDirectionType);
+                if (deviceList.size() > 0){
+                    // Prevent duplicate entries caused by b/80138804
+                    for (AudioDeviceListEntry entry : deviceList){
+                        mDeviceAdapter.remove(entry);
+                    }
+                    mDeviceAdapter.addAll(deviceList);
+                }
+            }
+
+            public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
+                List<AudioDeviceListEntry> deviceList =
+                        AudioDeviceListEntry.createListFrom(removedDevices, mDirectionType);
+                for (AudioDeviceListEntry entry : deviceList){
+                    mDeviceAdapter.remove(entry);
+                }
+                setSelection(0);
+            }
+        }, null);
+    }
+}

+ 236 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AnalyzerActivity.java

@@ -0,0 +1,236 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.Manifest;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.support.annotation.NonNull;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+/**
+ * Activity to measure latency on a full duplex stream.
+ */
+public class AnalyzerActivity extends TestInputActivity {
+
+    private static final int MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE = 1001;
+
+    protected static final String KEY_FILE_NAME = "file";
+    protected static final String KEY_BUFFER_BURSTS = "buffer_bursts";
+
+    AudioOutputTester mAudioOutTester;
+    protected BufferSizeView mBufferSizeView;
+    protected String mResultFileName;
+    private String mTestResults;
+
+    // Note that these string must match the enum result_code in LatencyAnalyzer.h
+    String resultCodeToString(int resultCode) {
+        switch (resultCode) {
+            case 0:
+                return "OK";
+            case -99:
+                return "ERROR_NOISY";
+            case -98:
+                return "ERROR_VOLUME_TOO_LOW";
+            case -97:
+                return "ERROR_VOLUME_TOO_HIGH";
+            case -96:
+                return "ERROR_CONFIDENCE";
+            case -95:
+                return "ERROR_INVALID_STATE";
+            case -94:
+                return "ERROR_GLITCHES";
+            case -93:
+                return "ERROR_NO_LOCK";
+            default:
+                return "UNKNOWN";
+        }
+    }
+
+    public native int getAnalyzerState();
+    public native boolean isAnalyzerDone();
+    public native int getMeasuredResult();
+    public native int getResetCount();
+
+    @NonNull
+    protected String getCommonTestReport() {
+        StringBuffer report = new StringBuffer();
+        // Add some extra information for the remote tester.
+        report.append("build.fingerprint = " + Build.FINGERPRINT + "\n");
+        try {
+            PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
+            report.append(String.format("test.version = %s\n", pinfo.versionName));
+            report.append(String.format("test.version.code = %d\n", pinfo.versionCode));
+        } catch (PackageManager.NameNotFoundException e) {
+        }
+        report.append("time.millis = " + System.currentTimeMillis() + "\n");
+
+        // INPUT
+        report.append(mAudioInputTester.actualConfiguration.dump());
+        AudioStreamBase inStream = mAudioInputTester.getCurrentAudioStream();
+        report.append(String.format("in.burst.frames = %d\n", inStream.getFramesPerBurst()));
+        report.append(String.format("in.xruns = %d\n", inStream.getXRunCount()));
+
+        // OUTPUT
+        report.append(mAudioOutTester.actualConfiguration.dump());
+        AudioStreamBase outStream = mAudioOutTester.getCurrentAudioStream();
+        report.append(String.format("out.burst.frames = %d\n", outStream.getFramesPerBurst()));
+        int bufferSize = outStream.getBufferSizeInFrames();
+        report.append(String.format("out.buffer.size.frames = %d\n", bufferSize));
+        int bufferCapacity = outStream.getBufferCapacityInFrames();
+        report.append(String.format("out.buffer.capacity.frames = %d\n", bufferCapacity));
+        report.append(String.format("out.xruns = %d\n", outStream.getXRunCount()));
+
+        return report.toString();
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mAudioOutTester = addAudioOutputTester();
+        mBufferSizeView = (BufferSizeView) findViewById(R.id.buffer_size_view);
+        if (mBufferSizeView != null) {
+            mBufferSizeView.setAudioOutTester(mAudioOutTester);
+        }
+    }
+
+    @Override
+    protected void resetConfiguration() {
+        super.resetConfiguration();
+        mAudioOutTester.reset();
+
+        StreamContext streamContext = getFirstInputStreamContext();
+        if (streamContext != null) {
+            if (streamContext.configurationView != null) {
+                streamContext.configurationView.setFormat(StreamConfiguration.AUDIO_FORMAT_PCM_FLOAT);
+                streamContext.configurationView.setFormatConversionAllowed(true);
+            }
+        }
+        streamContext = getFirstOutputStreamContext();
+        if (streamContext != null) {
+            if (streamContext.configurationView != null) {
+                streamContext.configurationView.setFormat(StreamConfiguration.AUDIO_FORMAT_PCM_FLOAT);
+                streamContext.configurationView.setFormatConversionAllowed(true);
+            }
+        }
+    }
+
+    public void startAudio() {
+        if (mBufferSizeView != null && mBufferSizeView.isEnabled()) {
+            mBufferSizeView.updateBufferSize();
+        }
+        super.startAudio();
+    }
+
+    public void onStreamClosed() {
+        Toast.makeText(getApplicationContext(),
+                "Stream was closed or disconnected!",
+                Toast.LENGTH_SHORT)
+                .show();
+        stopAudioTest();
+    }
+
+    public void stopAudioTest() {
+    }
+
+    void writeTestResultIfPermitted(String resultString) {
+        // Here, thisActivity is the current activity
+        if (ContextCompat.checkSelfPermission(this,
+                Manifest.permission.WRITE_EXTERNAL_STORAGE)
+                != PackageManager.PERMISSION_GRANTED) {
+            mTestResults = resultString;
+            ActivityCompat.requestPermissions(this,
+                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
+                    MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
+        } else {
+            // Permission has already been granted
+            writeTestResult(resultString);
+        }
+    }
+
+    void maybeWriteTestResult(String resultString) {
+        if (mResultFileName == null) return;
+        writeTestResultIfPermitted(resultString);
+    }
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode,
+                                           String[] permissions,
+                                           int[] grantResults) {
+        switch (requestCode) {
+            case MY_PERMISSIONS_REQUEST_EXTERNAL_STORAGE: {
+                // If request is cancelled, the result arrays are empty.
+                if (grantResults.length > 0
+                        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+                    writeTestResult(mTestResults);
+                } else {
+                    showToast("Writing external storage needed for test results.");
+                }
+                return;
+            }
+        }
+    }
+
+    private void writeTestInBackground(final String resultString) {
+        new Thread() {
+            public void run() {
+                writeTestResult(resultString);
+            }
+        }.start();
+    }
+
+    // Run this in a background thread.
+    private void writeTestResult(String resultString) {
+        File resultFile = new File(mResultFileName);
+        Writer writer = null;
+        try {
+            writer = new OutputStreamWriter(new FileOutputStream(resultFile));
+            writer.write(resultString);
+        } catch (
+                IOException e) {
+            e.printStackTrace();
+            showErrorToast(" writing result file. " + e.getMessage());
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        mResultFileName = null;
+    }
+
+
+}

+ 40 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioInputTester.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.util.Log;
+
+class AudioInputTester extends AudioStreamTester{
+    private static AudioInputTester mInstance;
+
+    private AudioInputTester() {
+        super();
+        Log.i(TapToToneActivity.TAG, "create OboeAudioStream ---------");
+
+        mCurrentAudioStream = new OboeAudioInputStream();
+        requestedConfiguration.setDirection(StreamConfiguration.DIRECTION_INPUT);
+    }
+
+    public static synchronized AudioInputTester getInstance() {
+        if (mInstance == null) {
+            mInstance = new AudioInputTester();
+        }
+        return mInstance;
+    }
+
+    public native double getPeakLevel(int i);
+}

+ 203 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioMidiTester.java

@@ -0,0 +1,203 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+package com.google.sample.oboe.manualtest;
+
+
+import android.media.midi.MidiDeviceService;
+import android.media.midi.MidiReceiver;
+import android.util.Log;
+
+import com.mobileer.miditools.MidiConstants;
+import com.mobileer.miditools.MidiFramer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * Measure the latency of various output paths by playing a blip.
+ * Report the results back to the TestListeners.
+ */
+public class AudioMidiTester extends MidiDeviceService {
+
+    // Sometimes the service can be run without the MainActivity being run!
+    static {
+        // Must match name in CMakeLists.txt
+        System.loadLibrary("oboetester");
+    }
+
+    private static final float MAX_TOUCH_LATENCY = 0.200f;
+    private static final float MAX_OUTPUT_LATENCY = 0.600f;
+    private static final float ANALYSIS_TIME_MARGIN = 0.250f;
+
+    private static final float ANALYSIS_TIME_DELAY = MAX_OUTPUT_LATENCY;
+    private static final float ANALYSIS_TIME_TOTAL = MAX_TOUCH_LATENCY + MAX_OUTPUT_LATENCY;
+    private static final float ANALYSIS_TIME_MAX = ANALYSIS_TIME_TOTAL + ANALYSIS_TIME_MARGIN;
+    private static final int ANALYSIS_SAMPLE_RATE = 48000; // need not match output rate
+
+    private ArrayList<TestListener> mListeners = new ArrayList<TestListener>();
+    private MyMidiReceiver mReceiver = new MyMidiReceiver();
+    private MidiFramer mMidiFramer = new MidiFramer(mReceiver);
+    private boolean mRecordEnabled = true;
+
+    private static AudioMidiTester mInstance;
+    private AudioRecordThread mRecorder;
+    private TapLatencyAnalyser mTapLatencyAnalyser;
+
+    private AudioOutputTester mAudioOutputTester;
+
+    public static class TestResult {
+        public float[] samples;
+        public float[] filtered;
+        public int frameRate;
+        public TapLatencyAnalyser.TapLatencyEvent[] events;
+    }
+
+    public static interface TestListener {
+        public void onTestFinished(TestResult result);
+
+        public void onNoteOn(int pitch);
+    }
+
+    /**
+     * This is a Service so it is only created when a client requests the service.
+     */
+    public AudioMidiTester() {
+        mInstance = this;
+    }
+
+    public void addTestListener(TestListener listener) {
+        mListeners.add(listener);
+    }
+
+    public void removeTestListener(TestListener listener) {
+        mListeners.remove(listener);
+    }
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        if (mRecordEnabled) {
+            mRecorder = new AudioRecordThread(ANALYSIS_SAMPLE_RATE,
+                    1,
+                    (int) (ANALYSIS_TIME_MAX * ANALYSIS_SAMPLE_RATE));
+        }
+
+        mAudioOutputTester = AudioOutputTester.getInstance();
+
+        mTapLatencyAnalyser = new TapLatencyAnalyser();
+    }
+
+    @Override
+    public void onDestroy() {
+        // do stuff here
+        super.onDestroy();
+    }
+
+    public static AudioMidiTester getInstance() {
+        return mInstance;
+    }
+
+    class MyMidiReceiver extends MidiReceiver {
+        public void onSend(byte[] data, int offset,
+                           int count, long timestamp) throws IOException {
+            // parse MIDI
+            byte command = (byte) (data[0] & 0x0F0);
+            if (command == MidiConstants.STATUS_NOTE_ON) {
+                if (data[2] == 0) {
+                    noteOff(data[1]);
+                } else {
+                    noteOn(data[1]);
+                }
+            } else if (command == MidiConstants.STATUS_NOTE_OFF) {
+                noteOff(data[1]);
+            }
+            Log.i(TapToToneActivity.TAG, "MIDI command = " + command);
+        }
+    }
+
+    private void noteOn(byte b) {
+        setEnabled(true);
+        fireNoteOn(b);
+    }
+
+    private void fireNoteOn(byte pitch) {
+        for (TestListener listener : mListeners) {
+            listener.onNoteOn(pitch);
+        }
+    }
+
+    private void noteOff(byte b) {
+        setEnabled(false);
+    }
+
+    @Override
+    public MidiReceiver[] onGetInputPortReceivers() {
+        return new MidiReceiver[]{mMidiFramer};
+    }
+
+
+    public void start() throws IOException {
+        if (mRecordEnabled) {
+            mRecorder.startAudio();
+        }
+    }
+
+    public void setEnabled(boolean checked) {
+        mAudioOutputTester.setEnabled(checked);
+        if (checked && mRecordEnabled) {
+            // schedule an analysis to start in the near future
+            int numSamples = (int) (mRecorder.getSampleRate() * ANALYSIS_TIME_DELAY);
+            Runnable task = new Runnable() {
+                public void run() {
+                    new Thread() {
+                        public void run() {
+                            analyzeCapturedAudio();
+                        }
+                    }.start();
+                }
+            };
+
+            mRecorder.scheduleTask(numSamples, task);
+        }
+    }
+
+    private void analyzeCapturedAudio() {
+        if (!mRecordEnabled) return;
+        int numSamples = (int) (mRecorder.getSampleRate() * ANALYSIS_TIME_TOTAL);
+        float[] buffer = new float[numSamples];
+        mRecorder.setCaptureEnabled(false); // TODO wait for it to settle
+        int numRead = mRecorder.readMostRecent(buffer);
+
+        TestResult result = new TestResult();
+        result.samples = buffer;
+        result.frameRate = mRecorder.getSampleRate();
+        result.events = mTapLatencyAnalyser.analyze(buffer, 0, numRead);
+        result.filtered = mTapLatencyAnalyser.getFilteredBuffer();
+        mRecorder.setCaptureEnabled(true);
+        // notify listeners
+        for (TestListener listener : mListeners) {
+            listener.onTestFinished(result);
+        }
+    }
+
+
+    public void stop() {
+        if (mRecordEnabled) {
+            mRecorder.stopAudio();
+        }
+    }
+
+}

+ 60 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioOutputTester.java

@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.util.Log;
+
+public class AudioOutputTester extends AudioStreamTester {
+
+    protected OboeAudioOutputStream mOboeAudioOutputStream;
+
+    private static AudioOutputTester mInstance;
+
+    public static synchronized AudioOutputTester getInstance() {
+        if (mInstance == null) {
+            mInstance = new AudioOutputTester();
+        }
+        return mInstance;
+    }
+
+    private AudioOutputTester() {
+        super();
+        Log.i(TapToToneActivity.TAG, "create OboeAudioOutputStream ---------");
+        mOboeAudioOutputStream = new OboeAudioOutputStream();
+        mCurrentAudioStream = mOboeAudioOutputStream;
+        setToneType(OboeAudioOutputStream.TONE_TYPE_SINE);
+        setEnabled(false);
+        requestedConfiguration.setDirection(StreamConfiguration.DIRECTION_OUTPUT);
+    }
+
+    public void setToneType(int index) {
+        Log.i(TapToToneActivity.TAG, "setToneType(" + index + ")");
+        mOboeAudioOutputStream.setToneType(index);
+    }
+
+    public void setEnabled(boolean flag) {
+        mOboeAudioOutputStream.setToneEnabled(flag);
+    }
+
+    public void setChannelEnabled(int channelIndex, boolean enabled)  {
+        mOboeAudioOutputStream.setChannelEnabled(channelIndex, enabled);
+    }
+
+    public void setSignalType(int type) {
+        mOboeAudioOutputStream.setSignalType(type);
+    }
+}

+ 156 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioRecordThread.java

@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+
+import android.media.AudioFormat;
+import android.media.AudioRecord;
+import android.media.MediaRecorder;
+
+/**
+ * Abstract class for recording.
+ * Call processBuffer(buffer) when data is read.
+ */
+class AudioRecordThread implements Runnable {
+    private static final String TAG = "AudioRecordThread";
+
+    private final int mSampleRate;
+    private final int mChannelCount;
+    private Thread mThread;
+    protected boolean mGo;
+    private AudioRecord mRecorder;
+    private CircularCaptureBuffer mCaptureBuffer;
+    protected float[] mBuffer = new float[256];
+    private static int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_FLOAT;
+    private Runnable mTask;
+    private int mTaskCountdown;
+    private boolean mCaptureEnabled = true;
+
+    public AudioRecordThread(int frameRate, int channelCount, int maxFrames) {
+        mSampleRate = frameRate;
+        mChannelCount = channelCount;
+        mCaptureBuffer = new CircularCaptureBuffer(maxFrames);
+    }
+
+    private void createRecorder() {
+        int channelConfig = (mChannelCount == 1)
+                ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO;
+        int audioFormat = AudioFormat.ENCODING_PCM_FLOAT;
+        int minRecordBuffSizeInBytes = AudioRecord.getMinBufferSize(mSampleRate,
+                channelConfig,
+                audioFormat);
+        mRecorder = new AudioRecord(
+                MediaRecorder.AudioSource.VOICE_RECOGNITION,
+                mSampleRate,
+                channelConfig,
+                audioFormat,
+                2 * minRecordBuffSizeInBytes);
+        if (mRecorder.getState() == AudioRecord.STATE_UNINITIALIZED) {
+            throw new RuntimeException("Could not make the AudioRecord - UNINITIALIZED");
+        }
+    }
+
+    @Override
+    public void run() {
+        startAudioRecording();
+
+        while (mGo) {
+            int result = handleAudioPeriod();
+            if (result < 0) {
+                mGo = false;
+            }
+        }
+
+        stopAudioRecording();
+    }
+
+    public void startAudio() {
+        if (mThread == null) {
+            mGo = true;
+            mThread = new Thread(this);
+            mThread.start();
+        }
+    }
+
+    public void stopAudio() {
+        mGo = false;
+        if (mThread != null) {
+            try {
+                mThread.join(1000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            mThread = null;
+        }
+    }
+
+    public int getSampleRate() {
+        return mSampleRate;
+    }
+
+    /**
+     * @return number of samples read or negative error
+     */
+    private int handleAudioPeriod() {
+        int numSamplesRead = mRecorder.read(mBuffer, 0, mBuffer.length,
+                AudioRecord.READ_BLOCKING);
+        if (numSamplesRead <= 0) {
+            return numSamplesRead;
+        } else {
+            if (mTaskCountdown > 0) {
+                mTaskCountdown -= numSamplesRead;
+                if (mTaskCountdown <= 0) {
+                    mTaskCountdown = 0;
+                    new Thread(mTask).start(); // run asynchronously with audio thread
+                }
+            }
+            if (mCaptureEnabled) {
+                return mCaptureBuffer.write(mBuffer, 0, numSamplesRead);
+            } else {
+                return numSamplesRead;
+            }
+        }
+    }
+
+    private void startAudioRecording() {
+        stopAudioRecording();
+        createRecorder();
+        mRecorder.startRecording();
+    }
+
+    private void stopAudioRecording() {
+        if (mRecorder != null) {
+            mRecorder.stop();
+            mRecorder.release();
+            mRecorder = null;
+        }
+    }
+
+    public void scheduleTask(int numSamples, Runnable task) {
+        mTask = task;
+        mTaskCountdown = numSamples;
+    }
+
+    public void setCaptureEnabled(boolean captureEnabled) {
+        mCaptureEnabled = captureEnabled;
+    }
+
+    public int readMostRecent(float[] buffer) {
+        return mCaptureBuffer.readMostRecent(buffer);
+    }
+
+}

+ 176 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioStreamBase.java

@@ -0,0 +1,176 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import java.io.IOException;
+
+/**
+ * Base class for any audio input or output.
+ */
+public abstract class AudioStreamBase {
+
+    private StreamConfiguration mRequestedStreamConfiguration;
+    private StreamConfiguration mActualStreamConfiguration;
+
+    private int mBufferSizeInFrames;
+
+    public StreamStatus getStreamStatus() {
+        StreamStatus status = new StreamStatus();
+        status.bufferSize = getBufferSizeInFrames();
+        status.xRunCount = getXRunCount();
+        status.framesRead = getFramesRead();
+        status.framesWritten = getFramesWritten();
+        status.callbackCount = getCallbackCount();
+        status.latency = getLatency();
+        status.cpuLoad = getCpuLoad();
+        status.state = getState();
+        return status;
+    }
+
+    /**
+     * Changes dynamic at run-time.
+     */
+    public static class StreamStatus {
+        public int bufferSize;
+        public int xRunCount;
+        public long framesWritten;
+        public long framesRead;
+        public double latency; // msec
+        public int state;
+        public long callbackCount;
+        public int framesPerCallback;
+        public double cpuLoad;
+
+        // These are constantly changing.
+        String dump(int framesPerBurst) {
+            if (bufferSize < 0 || framesWritten < 0) {
+                return "idle";
+            }
+            StringBuffer buffer = new StringBuffer();
+
+            buffer.append("frames written " + framesWritten + " - read " + framesRead
+                    + " = " + (framesWritten - framesRead) + "\n");
+
+            String latencyText = (latency < 0.0)
+                    ? "?"
+                    : String.format("%6.1f ms", latency);
+            String cpuLoadText = String.format("%2d%c", (int)(cpuLoad * 100), '%');
+            buffer.append(
+                    convertStateToString(state)
+                    + ", #cb=" + callbackCount
+                    + ", f/cb=" + String.format("%3d", framesPerCallback)
+                    + ", latnc = " + latencyText
+                    + ", " + cpuLoadText + " cpu"
+                    + "\n");
+
+            buffer.append("buffer size = ");
+            if (bufferSize < 0) {
+                buffer.append("?");
+            } else {
+                int numBuffers = bufferSize / framesPerBurst;
+                int remainder = bufferSize - (numBuffers * framesPerBurst);
+                buffer.append(bufferSize + " = (" + numBuffers + " * " + framesPerBurst + ") + " + remainder);
+            }
+            buffer.append(",   xRun# = " + ((xRunCount < 0) ? "?" : xRunCount) + "\n");
+
+            return buffer.toString();
+        }
+        /**
+         * Converts ints from Oboe index to human-readable stream state
+         */
+        private String convertStateToString(int stateId) {
+            final String[] STATE_ARRAY = {"Uninit.", "Unknown", "Open", "Starting", "Started",
+                    "Pausing", "Paused", "Flushing", "Flushed",
+                    "Stopping", "Stopped", "Closing", "Closed", "Disconn."};
+            if (stateId < 0 || stateId >= STATE_ARRAY.length) {
+                return "Invalid - " + stateId;
+            }
+            return STATE_ARRAY[stateId];
+        }
+    }
+
+    /**
+     *
+     * @param requestedConfiguration
+     * @param actualConfiguration
+     * @param bufferSizeInFrames
+     * @throws IOException
+     */
+    public void open(StreamConfiguration requestedConfiguration,
+                     StreamConfiguration actualConfiguration,
+                     int bufferSizeInFrames) throws IOException {
+        mRequestedStreamConfiguration = requestedConfiguration;
+        mActualStreamConfiguration = actualConfiguration;
+        mBufferSizeInFrames = bufferSizeInFrames;
+    }
+
+    public abstract boolean isInput();
+
+    public void startPlayback() throws IOException {}
+
+    public void stopPlayback() throws IOException {}
+
+    public abstract int write(float[] buffer, int offset, int length);
+
+    public abstract void close();
+
+    public int getChannelCount() {
+        return mActualStreamConfiguration.getChannelCount();
+    }
+
+    public int getSampleRate() {
+        return mActualStreamConfiguration.getSampleRate();
+    }
+
+    public int getFramesPerBurst() {
+        return mActualStreamConfiguration.getFramesPerBurst();
+    }
+
+    public int getBufferCapacityInFrames() {
+        return mBufferSizeInFrames;
+    }
+
+    public int getBufferSizeInFrames() {
+        return mBufferSizeInFrames;
+    }
+
+    public int setBufferSizeInFrames(int bufferSize) {
+        throw new UnsupportedOperationException("bufferSize cannot be changed");
+    }
+
+    public long getCallbackCount() { return -1; }
+
+    public long getFramesWritten() { return -1; }
+
+    public long getFramesRead() { return -1; }
+
+    public double getLatency() { return -1.0; }
+
+    public double getCpuLoad() { return 0.0; }
+
+    public int getState() { return -1; }
+
+    public boolean isThresholdSupported() {
+        return false;
+    }
+
+    public void setWorkload(double workload) {}
+
+    public abstract int getXRunCount();
+
+
+}

+ 51 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AudioStreamTester.java

@@ -0,0 +1,51 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import java.io.IOException;
+
+class AudioStreamTester {
+    protected AudioStreamBase mCurrentAudioStream;
+    StreamConfiguration  requestedConfiguration = new StreamConfiguration();
+    StreamConfiguration  actualConfiguration = new StreamConfiguration();
+
+    AudioStreamBase getCurrentAudioStream() {
+        return mCurrentAudioStream;
+    }
+
+    public void open() throws IOException {
+        mCurrentAudioStream.open(requestedConfiguration, actualConfiguration,
+                -1);
+    }
+
+    public void reset() {
+        requestedConfiguration.reset(); // TODO consider making new ones
+        actualConfiguration.reset();
+    }
+
+    public void close() {
+        mCurrentAudioStream.close();
+    }
+
+    public void startPlayback() throws IOException {
+        mCurrentAudioStream.startPlayback();
+    }
+
+    public void setWorkload(double workload) {
+        mCurrentAudioStream.setWorkload(workload);
+    }
+}

+ 328 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/AutoGlitchActivity.java

@@ -0,0 +1,328 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import java.io.IOException;
+import java.util.Date;
+
+public class AutoGlitchActivity extends GlitchActivity implements Runnable {
+
+    private static final int SETUP_TIME_SECONDS = 4; // Time for the stream to settle.
+    private static final int DEFAULT_DURATION_SECONDS = 8; // Run time for each test.
+    private static final int DEFAULT_GAP_MILLIS = 400; // Run time for each test.
+    private static final String TEXT_SKIP = "SKIP";
+    public static final String TEXT_PASS = "PASS";
+    public static final String TEXT_FAIL = "FAIL !!!!";
+
+    private TextView mAutoTextView;
+
+    private Thread mAutoThread;
+    private volatile boolean mThreadEnabled = false;
+    int mTestCount = 0;
+    private int mDurationSeconds = DEFAULT_DURATION_SECONDS;
+    private int mGapMillis = DEFAULT_GAP_MILLIS;
+    private StringBuffer mFailedSummary;
+    private int mPassCount = 0;
+    private int mFailCount = 0;
+    private Spinner mDurationSpinner;
+
+    // Test with these configurations.
+    private static final int[] PERFORMANCE_MODES = {
+            StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
+            StreamConfiguration.PERFORMANCE_MODE_NONE
+    };
+    private static final int[] SAMPLE_RATES = { 48000, 44100, 16000 };
+
+    private class DurationSpinnerListener implements android.widget.AdapterView.OnItemSelectedListener {
+        @Override
+        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
+            String text = parent.getItemAtPosition(pos).toString();
+            mDurationSeconds = Integer.parseInt(text);
+        }
+
+        @Override
+        public void onNothingSelected(AdapterView<?> parent) {
+            mDurationSeconds = DEFAULT_DURATION_SECONDS;
+        }
+    }
+
+    @Override
+    protected void inflateActivity() {
+        setContentView(R.layout.activity_auto_glitches);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mAutoTextView = (TextView) findViewById(R.id.text_log);
+        mAutoTextView.setMovementMethod(new ScrollingMovementMethod());
+
+        mDurationSpinner = (Spinner) findViewById(R.id.spinner_glitch_duration);
+        mDurationSpinner.setOnItemSelectedListener(new DurationSpinnerListener());
+    }
+
+    // Write to scrollable TextView
+    private void log(final String text) {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mAutoTextView.append(text);
+                mAutoTextView.append("\n");
+            }
+        });
+    }
+    private void logClear() {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mAutoTextView.setText("");
+            }
+        });
+    }
+
+    public void startAudioTest() {
+        mThreadEnabled = true;
+        mAutoThread = new Thread(this);
+        mAutoThread.start();
+    }
+
+    // Only call from UI thread.
+    @Override
+    public void onTestFinished() {
+        super.onTestFinished();
+    }
+
+    public void stopAudioTest() {
+        try {
+            if (mAutoThread != null) {
+                mThreadEnabled = false;
+                mAutoThread.interrupt();
+                mAutoThread.join(100);
+                mAutoThread = null;
+            }
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    // Share text from log via GMail, Drive or other method.
+    public void onShareResult(View view) {
+        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
+        sharingIntent.setType("text/plain");
+
+        String subjectText = "OboeTester AutoGlitch result " + getTimestampString();
+        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subjectText);
+
+        String shareBody = mAutoTextView.getText().toString();
+        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
+
+        startActivity(Intent.createChooser(sharingIntent, "Share using:"));
+    }
+
+    private String getConfigText(StreamConfiguration config) {
+        return ((config.getDirection() == StreamConfiguration.DIRECTION_OUTPUT) ? "OUT" : "IN")
+                + ", SR = " + config.getSampleRate()
+                + ", Perf = " + StreamConfiguration.convertPerformanceModeToText(
+                        config.getPerformanceMode())
+                + ", " + StreamConfiguration.convertSharingModeToText(config.getSharingMode())
+                + ", ch = " + config.getChannelCount();
+    }
+
+    private void testConfiguration(int perfMode,
+                                   int sharingMode,
+                                   int sampleRate,
+                                   int inChannels,
+                                   int outChannels) throws InterruptedException {
+
+        // Configure settings
+        StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration;
+        StreamConfiguration actualInConfig = mAudioInputTester.actualConfiguration;
+        StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration;
+        StreamConfiguration actualOutConfig = mAudioOutTester.actualConfiguration;
+
+        requestedInConfig.reset();
+        requestedOutConfig.reset();
+
+        requestedInConfig.setPerformanceMode(perfMode);
+        requestedOutConfig.setPerformanceMode(perfMode);
+
+        requestedInConfig.setSharingMode(sharingMode);
+        requestedOutConfig.setSharingMode(sharingMode);
+
+        requestedInConfig.setSampleRate(sampleRate);
+        requestedOutConfig.setSampleRate(sampleRate);
+
+        requestedInConfig.setChannelCount(inChannels);
+        requestedOutConfig.setChannelCount(outChannels);
+
+        log("========================== #" + mTestCount);
+        log("Requested:");
+        log(getConfigText(requestedInConfig));
+        log(getConfigText(requestedOutConfig));
+
+        // Give previous stream time to close and release resources. Avoid race conditions.
+        Thread.sleep(1000);
+        boolean openFailed = false;
+        try {
+            super.startAudioTest(); // this will fill in actualConfig
+            log("Actual:");
+            log(getConfigText(actualInConfig));
+            log(getConfigText(actualOutConfig));
+            // Set output size to a level that will avoid glitches.
+            AudioStreamBase stream = mAudioOutTester.getCurrentAudioStream();
+            int sizeFrames = stream.getBufferCapacityInFrames() / 2;
+            stream.setBufferSizeInFrames(sizeFrames);
+        } catch (IOException e) {
+            openFailed = true;
+            log(e.getMessage());
+        }
+
+        // The test would only be worth running if we got the configuration we requested on input or output.
+        boolean valid = true;
+        // No point running the test if we don't get the sharing mode we requested.
+        if (!openFailed && actualInConfig.getSharingMode() != sharingMode
+                && actualOutConfig.getSharingMode() != sharingMode) {
+            log("did not get requested sharing mode");
+            valid = false;
+        }
+        // We don't skip based on performance mode because if you request LOW_LATENCY you might
+        // get a smaller burst than if you request NONE.
+
+        if (!openFailed && valid) {
+            Thread.sleep(mDurationSeconds * 1000);
+        }
+        int inXRuns = 0;
+        int outXRuns = 0;
+
+        if (!openFailed) {
+            // get xRuns before closing the streams.
+            inXRuns = mAudioInputTester.getCurrentAudioStream().getXRunCount();
+            outXRuns = mAudioOutTester.getCurrentAudioStream().getXRunCount();
+
+            super.stopAudioTest();
+        }
+
+        if (valid) {
+            if (openFailed) {
+                mFailedSummary.append("------ #" + mTestCount);
+                mFailedSummary.append("\n");
+                mFailedSummary.append(getConfigText(requestedInConfig));
+                mFailedSummary.append("\n");
+                mFailedSummary.append(getConfigText(requestedOutConfig));
+                mFailedSummary.append("\n");
+                mFailedSummary.append("Open failed!\n");
+                mFailCount++;
+            } else {
+                log("Result:");
+                boolean passed = (getMaxSecondsWithNoGlitch()
+                        > (mDurationSeconds - SETUP_TIME_SECONDS));
+                String resultText = getShortReport();
+                resultText += ", xruns = " + inXRuns + "/" + outXRuns;
+                resultText += ", " + (passed ? TEXT_PASS : TEXT_FAIL);
+                log(resultText);
+                if (!passed) {
+                    mFailedSummary.append("------ #" + mTestCount);
+                    mFailedSummary.append("\n");
+                    mFailedSummary.append("  ");
+                    mFailedSummary.append(getConfigText(actualInConfig));
+                    mFailedSummary.append("\n");
+                    mFailedSummary.append("    ");
+                    mFailedSummary.append(resultText);
+                    mFailedSummary.append("\n");
+                    mFailCount++;
+                } else {
+                    mPassCount++;
+                }
+            }
+        } else {
+            log(TEXT_SKIP);
+        }
+        // Give hardware time to settle between tests.
+        Thread.sleep(mGapMillis);
+        mTestCount++;
+    }
+
+    private void testConfiguration(int performanceMode,
+                                   int sharingMode,
+                                   int sampleRate) throws InterruptedException {
+        testConfiguration(performanceMode,
+                sharingMode,
+                sampleRate, 1, 2);
+        testConfiguration(performanceMode,
+                sharingMode,
+                sampleRate, 2, 1);
+    }
+
+
+    @Override
+    public void run() {
+        logClear();
+        log("=== STARTED at " + new Date());
+        log(Build.MANUFACTURER + " " + Build.PRODUCT);
+        log(Build.DISPLAY);
+        mFailedSummary = new StringBuffer();
+        mTestCount = 0;
+        mPassCount = 0;
+        mFailCount = 0;
+        try {
+            testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
+                    StreamConfiguration.SHARING_MODE_EXCLUSIVE,
+                    0);
+            testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
+                    StreamConfiguration.SHARING_MODE_SHARED,
+                    0);
+
+            for (int perfMode : PERFORMANCE_MODES) {
+                for (int sampleRate : SAMPLE_RATES) {
+                    testConfiguration(perfMode,
+                            StreamConfiguration.SHARING_MODE_SHARED,
+                            sampleRate);
+                }
+            }
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } finally {
+            super.stopAudioTest();
+            log("\n==== SUMMARY ========");
+            if (mFailCount > 0) {
+                log(mPassCount + " passed. " + mFailCount + " failed.");
+                log("These tests FAILED:");
+                log(mFailedSummary.toString());
+            } else {
+                log("All tests PASSED.");
+            }
+            log("== FINISHED at " + new Date());
+            runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    onTestFinished();
+                }
+            });
+        }
+    }
+
+}

+ 143 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/BufferSizeView.java

@@ -0,0 +1,143 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+
+
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.widget.LinearLayout;
+
+public class BufferSizeView extends LinearLayout {
+
+    AudioOutputTester mAudioOutTester;
+
+    protected static final int FADER_THRESHOLD_MAX = 1000; // must match layout
+    protected TextView mTextThreshold;
+    protected SeekBar mFaderThreshold;
+    protected ExponentialTaper mTaperThreshold;
+    private int mCachedCapacity;
+
+    private SeekBar.OnSeekBarChangeListener mThresholdListener = new SeekBar.OnSeekBarChangeListener() {
+        @Override
+        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+            setBufferSizeByPosition(progress);
+        }
+
+        @Override
+        public void onStartTrackingTouch(SeekBar seekBar) {
+        }
+
+        @Override
+        public void onStopTrackingTouch(SeekBar seekBar) {
+        }
+    };
+
+    public BufferSizeView(Context context) {
+        super(context);
+        initializeViews(context);
+    }
+
+    public BufferSizeView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initializeViews(context);
+    }
+
+    public BufferSizeView(Context context,
+                                   AttributeSet attrs,
+                                   int defStyle) {
+        super(context, attrs, defStyle);
+        initializeViews(context);
+    }
+
+    public AudioOutputTester getAudioOutTester() {
+        return mAudioOutTester;
+    }
+
+    public void setAudioOutTester(AudioOutputTester audioOutTester) {
+        mAudioOutTester = audioOutTester;
+    }
+
+    void setFaderNormalizedProgress(double fraction) {
+        mFaderThreshold.setProgress((int)(fraction * FADER_THRESHOLD_MAX));
+    }
+
+    /**
+     * Inflates the views in the layout.
+     *
+     * @param context
+     *           the current context for the view.
+     */
+    private void initializeViews(Context context) {
+        LayoutInflater inflater = (LayoutInflater) context
+                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        inflater.inflate(R.layout.buffer_size_view, this);
+
+        mTextThreshold = (TextView) findViewById(R.id.textThreshold);
+        mFaderThreshold = (SeekBar) findViewById(R.id.faderThreshold);
+        mFaderThreshold.setOnSeekBarChangeListener(mThresholdListener);
+        mTaperThreshold = new ExponentialTaper(0.0, 1.0, 10.0);
+        mFaderThreshold.setProgress(0);
+    }
+
+    private void setBufferSizeByPosition(int progress) {
+        StringBuffer message = new StringBuffer();
+        double normalizedThreshold = mTaperThreshold.linearToExponential(
+                ((double)progress)/FADER_THRESHOLD_MAX);
+        if (normalizedThreshold < 0.0) normalizedThreshold = 0.0;
+        else if (normalizedThreshold > 1.0) normalizedThreshold = 1.0;
+        int  percent = (int) (normalizedThreshold * 100);
+        message.append("bufferSize = " + percent + "%");
+
+        OboeAudioStream stream = null;
+        int sizeFrames = 0;
+        if (getAudioOutTester()  != null) {
+            stream = (OboeAudioStream) getAudioOutTester().getCurrentAudioStream();
+            if (stream != null) {
+                int capacity = stream.getBufferCapacityInFrames();
+                if (capacity > 0) mCachedCapacity = capacity;
+            }
+        }
+        if (mCachedCapacity > 0) {
+            sizeFrames = (int) (normalizedThreshold * mCachedCapacity);
+            message.append(" = " + sizeFrames);
+            if (stream != null) {
+                stream.setBufferSizeInFrames(sizeFrames);
+            }
+            int bufferSize = getAudioOutTester().getCurrentAudioStream().getBufferSizeInFrames();
+            if (bufferSize >= 0) {
+                message.append(" / " + bufferSize);
+            }
+            message.append(" / " + mCachedCapacity);
+        }
+        mTextThreshold.setText(message.toString());
+    }
+
+    public void updateBufferSize() {
+        int progress = mFaderThreshold.getProgress();
+        setBufferSizeByPosition(progress);
+    }
+
+    @Override
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        mFaderThreshold.setEnabled(enabled);
+    }
+}

+ 104 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/CircularCaptureBuffer.java

@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+
+/**
+ * Circular buffer for continuously capturing audio then reading the previous N samples.
+ * Can hold from zero to max frames.
+ */
+public class CircularCaptureBuffer {
+
+    private float[] mData;
+    private int mCursor;
+    private int mNumValidSamples;
+
+    public CircularCaptureBuffer(int maxSamples) {
+        mData = new float[maxSamples];
+    }
+
+    public int write(float[] buffer) {
+        return write(buffer, 0, buffer.length);
+    }
+
+    public int write(float[] buffer, int offset, int numSamples) {
+        if (numSamples > mData.length) {
+            throw new IllegalArgumentException("Tried to write more than maxSamples.");
+        }
+        if ((mCursor + numSamples) > mData.length) {
+            // Wraps so write in two parts.
+            int numWrite1 = mData.length - mCursor;
+            System.arraycopy(buffer, offset, mData, mCursor, numWrite1);
+            offset += numWrite1;
+            int numWrite2 = numSamples - numWrite1;
+            System.arraycopy(buffer, offset, mData, 0, numWrite2);
+            mCursor = numWrite2;
+        } else {
+            System.arraycopy(buffer, offset, mData, mCursor, numSamples);
+            mCursor += numSamples;
+            if (mCursor == mData.length) {
+                mCursor = 0;
+            }
+        }
+        mNumValidSamples += numSamples;
+        if (mNumValidSamples > mData.length) {
+            mNumValidSamples = mData.length;
+        }
+        return numSamples;
+    }
+
+    public int readMostRecent(float[] buffer) {
+        return readMostRecent(buffer, 0, buffer.length);
+    }
+
+    /**
+     * Read the most recently written samples.
+     * @param buffer
+     * @param offset
+     * @param numSamples
+     * @return number of samples read
+     */
+    public int readMostRecent(float[] buffer, int offset, int numSamples) {
+
+        if (numSamples > mNumValidSamples) {
+            numSamples = mNumValidSamples;
+        }
+        int cursor = mCursor; // read once in case it gets updated by another thread
+        // Read in two parts.
+        if ((cursor - numSamples) < 0) {
+            int numRead1 = numSamples - cursor;
+            System.arraycopy(mData, mData.length - numRead1, buffer, offset, numRead1);
+            offset += numRead1;
+            int numRead2 = cursor;
+            System.arraycopy(mData, 0, buffer, offset, numRead2);
+        } else {
+            System.arraycopy(mData, cursor - numSamples, buffer, offset, numSamples);
+        }
+
+        return numSamples;
+    }
+
+    public void erase() {
+        mNumValidSamples = 0;
+        mCursor = 0;
+    }
+
+    public int getSize() {
+        return mData.length;
+    }
+
+}

+ 140 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/EchoActivity.java

@@ -0,0 +1,140 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import java.io.IOException;
+
+/**
+ * Activity to capture audio and then send a delayed copy to output.
+ * There is a fader for setting delay time
+ */
+public class EchoActivity extends TestInputActivity {
+
+    AudioOutputTester mAudioOutTester;
+
+    protected TextView mTextDelayTime;
+    protected SeekBar mFaderDelayTime;
+    protected ExponentialTaper mTaperDelayTime;
+    private static final double MIN_DELAY_TIME_SECONDS = 0.0;
+    private static final double MAX_DELAY_TIME_SECONDS = 3.0;
+    private double mDelayTime;
+    private Button mStartButton;
+    private Button mStopButton;
+
+    protected static final int MAX_DELAY_TIME_PROGRESS = 1000;
+
+    private SeekBar.OnSeekBarChangeListener mDelayListener = new SeekBar.OnSeekBarChangeListener() {
+        @Override
+        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+            setDelayTimeByPosition(progress);
+        }
+
+        @Override
+        public void onStartTrackingTouch(SeekBar seekBar) {
+        }
+
+        @Override
+        public void onStopTrackingTouch(SeekBar seekBar) {
+        }
+    };
+
+    @Override
+    protected void inflateActivity() {
+        setContentView(R.layout.activity_echo);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        updateEnabledWidgets();
+
+        mAudioOutTester = addAudioOutputTester();
+
+        mStartButton = (Button) findViewById(R.id.button_start_echo);
+        mStopButton = (Button) findViewById(R.id.button_stop_echo);
+        mStopButton.setEnabled(false);
+
+        mTextDelayTime = (TextView) findViewById(R.id.text_delay_time);
+        mFaderDelayTime = (SeekBar) findViewById(R.id.fader_delay_time);
+        mFaderDelayTime.setOnSeekBarChangeListener(mDelayListener);
+        mTaperDelayTime = new ExponentialTaper(
+                MIN_DELAY_TIME_SECONDS,
+                MAX_DELAY_TIME_SECONDS,
+                100.0);
+        mFaderDelayTime.setProgress(MAX_DELAY_TIME_PROGRESS / 2);
+
+        hideSettingsViews();
+    }
+
+    private void setDelayTimeByPosition(int progress) {
+        mDelayTime = mTaperDelayTime.linearToExponential(
+                ((double)progress)/MAX_DELAY_TIME_PROGRESS);
+        setDelayTime(mDelayTime);
+        mTextDelayTime.setText("DelayLine: " + (int)(mDelayTime * 1000) + " (msec)");
+    }
+
+    private native void setDelayTime(double delayTimeSeconds);
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        setActivityType(ACTIVITY_ECHO);
+    }
+
+    @Override
+    protected void resetConfiguration() {
+        super.resetConfiguration();
+        mAudioOutTester.reset();
+    }
+
+    public void onStartEcho(View view) {
+        try {
+            openAudio();
+            startAudio();
+            setDelayTime(mDelayTime);
+            mStartButton.setEnabled(false);
+            mStopButton.setEnabled(true);
+            keepScreenOn(true);
+        } catch (IOException e) {
+            showErrorToast(e.getMessage());
+        }
+    }
+
+    public void onStopEcho(View view) {
+        stopAudio();
+        closeAudio();
+        mStartButton.setEnabled(true);
+        mStopButton.setEnabled(false);
+        keepScreenOn(false);
+    }
+
+    @Override
+    boolean isOutput() {
+        return false;
+    }
+
+    @Override
+    public void setupEffects(int sessionId) {
+    }
+}

+ 67 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/ExponentialTaper.java

@@ -0,0 +1,67 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+/**
+ * Maps integer range info to a double value along an exponential scale.
+ *
+ * <pre>
+ *
+ *   x = ival / mResolution
+ *   f(x) = a*(root**bx)
+ *   f(0.0) = dmin
+ *   f(1.0) = dmax
+ *
+ *   f(0.0) = a * 1.0 => a = dmin
+ *   f(1.0) = dmin * root**b = dmax
+ *   b = log(dmax / dmin) / log(root)
+ *
+ * </pre>
+ */
+
+public class ExponentialTaper {
+    private double offset = 0.0;
+    private double a = 1.0;
+    private double b = 2.0;
+    private static final double ROOT = 10.0; // because we are using log10
+
+    public ExponentialTaper(double dmin, double dmax) {
+        this(dmin, dmax, 10000.0);
+    }
+
+    public ExponentialTaper(double dmin, double dmax, double maxRatio) {
+        a = dmax;
+        double curvature;
+        if (dmax > dmin * maxRatio) {
+            offset = dmax / maxRatio;
+            a = offset;
+            curvature = (dmax + offset) / offset;
+        } else {
+            curvature = dmax / dmin;
+            a = dmin;
+        }
+        b = Math.log10(curvature);
+    }
+
+    public double linearToExponential(double linear) {
+        return a * Math.pow(ROOT,  b * linear) - offset;
+    }
+
+    public double exponentialToLinear(double exponential) {
+        return Math.log((exponential + offset) / a) / (b * Math.log(ROOT));
+    }
+}

+ 112 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/FastButton.java

@@ -0,0 +1,112 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.text.TextPaint;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+
+/**
+ * Button-like View that responds quickly to touch events.
+ */
+public class FastButton extends TextView {
+
+    public FastButton(Context context) {
+        super(context);
+    }
+
+    public FastButton(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public FastButton(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+    }
+
+    private ArrayList<FastButtonListener> mListeners = new ArrayList<FastButtonListener>();
+
+    /**
+     * Implement this to receive keyboard events.
+     */
+    public interface FastButtonListener {
+        /**
+         * This will be called when a key is pressed.
+         */
+        public void onKeyDown(int id);
+
+        /**
+         * This will be called when a key is pressed.
+         */
+        public void onKeyUp(int id);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        super.onTouchEvent(event);
+        int action = event.getActionMasked();
+        // Track individual fingers.
+        int pointerIndex = event.getActionIndex();
+        int id = event.getPointerId(pointerIndex);
+        switch (action) {
+            case MotionEvent.ACTION_DOWN:
+            case MotionEvent.ACTION_POINTER_DOWN:
+                fireKeyDown(id);
+                break;
+            case MotionEvent.ACTION_MOVE:
+                break;
+            case MotionEvent.ACTION_UP:
+            case MotionEvent.ACTION_POINTER_UP:
+                fireKeyUp(id);
+                break;
+        }
+        // Must return true or we do not get the ACTION_MOVE and
+        // ACTION_UP events.
+        return true;
+    }
+
+    private void fireKeyDown(int id) {
+        for (FastButtonListener listener : mListeners) {
+            listener.onKeyDown(id);
+        }
+        invalidate();
+    }
+
+    private void fireKeyUp(int id) {
+        for (FastButtonListener listener : mListeners) {
+            listener.onKeyUp(id);
+        }
+        invalidate();
+    }
+
+    public void addFastButtonListener(FastButtonListener listener) {
+        mListeners.add(listener);
+    }
+
+    public void removeFastButtonListener(FastButtonListener listener) {
+        mListeners.remove(listener);
+    }
+}

+ 337 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/GlitchActivity.java

@@ -0,0 +1,337 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import java.io.IOException;
+
+/**
+ * Activity to measure the number of glitches.
+ */
+public class GlitchActivity extends AnalyzerActivity {
+    private TextView mAnalyzerTextView;
+    private Button mStartButton;
+    private Button mStopButton;
+    private Button mShareButton;
+
+    // These must match the values in LatencyAnalyzer.h
+    final static int STATE_IDLE = 0;
+    final static int STATE_IMMUNE = 1;
+    final static int STATE_WAITING_FOR_SIGNAL = 2;
+    final static int STATE_WAITING_FOR_LOCK = 3;
+    final static int STATE_LOCKED = 4;
+    final static int STATE_GLITCHING = 5;
+    String mLastGlitchReport;
+
+    native int getStateFrameCount(int state);
+    native int getGlitchCount();
+    native double getSignalToNoiseDB();
+    native double getPeakAmplitude();
+
+    // Note that these strings must match the enum result_code in LatencyAnalyzer.h
+    String stateToString(int resultCode) {
+        switch (resultCode) {
+            case STATE_IDLE:
+                return "IDLE";
+            case STATE_IMMUNE:
+                return "IMMUNE";
+            case STATE_WAITING_FOR_SIGNAL:
+                return "WAITING_FOR_SIGNAL";
+            case STATE_WAITING_FOR_LOCK:
+                return "WAITING_FOR_LOCK";
+            case STATE_LOCKED:
+                return "LOCKED";
+            case STATE_GLITCHING:
+                return "GLITCHING";
+            default:
+                return "UNKNOWN";
+        }
+    }
+
+    // Periodically query for glitches from the native detector.
+    protected class GlitchSniffer {
+        public static final int SNIFFER_UPDATE_PERIOD_MSEC = 100;
+        public static final int SNIFFER_UPDATE_DELAY_MSEC = 200;
+
+        private long mTimeAtStart;
+        private long mTimeOfLastGlitch;
+        private double mSecondsWithoutGlitches;
+        private double mMaxSecondsWithoutGlitches;
+        private int mLastGlitchCount;
+        private int mLastUnlockedFrames;
+        private int mLastLockedFrames;
+        private int mLastGlitchFrames;
+
+        private int mStartResetCount;
+        private int mLastResetCount;
+        private int mPreviousState;
+
+        private double mSignalToNoiseDB;
+        private double mPeakAmplitude;
+        private Handler mHandler = new Handler(Looper.getMainLooper()); // UI thread
+        private volatile boolean mEnabled = true;
+
+        private void startSniffer() {
+            long now = System.currentTimeMillis();
+            mTimeAtStart = now;
+            mTimeOfLastGlitch = now;
+            mLastUnlockedFrames = 0;
+            mLastLockedFrames = 0;
+            mLastGlitchFrames = 0;
+            mSecondsWithoutGlitches = 0.0;
+            mMaxSecondsWithoutGlitches = 0.0;
+            mLastGlitchCount = 0;
+            mStartResetCount = mLastResetCount;
+            // Start the initial runnable task by posting through the handler
+            mEnabled = true;
+            mHandler.postDelayed(runnableCode, SNIFFER_UPDATE_DELAY_MSEC);
+        }
+
+        private void stopSniffer() {
+            mEnabled = false;
+            if (mHandler != null) {
+                mHandler.removeCallbacks(runnableCode);
+            }
+
+            runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    updateStatusText();
+                }
+            });
+        }
+
+        private Runnable runnableCode = new Runnable() {
+            @Override
+            public void run() {
+                int state = getAnalyzerState();
+                mSignalToNoiseDB = getSignalToNoiseDB();
+                mPeakAmplitude = getPeakAmplitude();
+                mPreviousState = state;
+
+                long now = System.currentTimeMillis();
+                int glitchCount = getGlitchCount();
+                int resetCount = getResetCount();
+                mLastUnlockedFrames = getStateFrameCount(STATE_WAITING_FOR_LOCK);
+                int lockedFrames = getStateFrameCount(STATE_LOCKED);
+                int glitchFrames = getStateFrameCount(STATE_GLITCHING);
+
+                if (glitchFrames > mLastGlitchFrames || glitchCount > mLastGlitchCount) {
+                    mTimeOfLastGlitch = now;
+                    mSecondsWithoutGlitches = 0.0;
+                    onGlitchDetected();
+                } else if (lockedFrames > mLastLockedFrames) {
+                    mSecondsWithoutGlitches = (now - mTimeOfLastGlitch) / 1000.0;
+                }
+
+                if (resetCount > mLastResetCount) {
+                    mLastResetCount = resetCount;
+                }
+
+                if (mSecondsWithoutGlitches > mMaxSecondsWithoutGlitches) {
+                    mMaxSecondsWithoutGlitches = mSecondsWithoutGlitches;
+                }
+
+                mLastGlitchCount = glitchCount;
+                mLastGlitchFrames = glitchFrames;
+                mLastLockedFrames = lockedFrames;
+                mLastResetCount = resetCount;
+
+                updateStatusText();
+
+                // Reschedule so this task repeats
+                if (mEnabled) {
+                    mHandler.postDelayed(runnableCode, SNIFFER_UPDATE_PERIOD_MSEC);
+                }
+            }
+        };
+
+        String getCurrentStatusReport() {
+            long now = System.currentTimeMillis();
+            double totalSeconds = (now - mTimeAtStart) / 1000.0;
+
+            StringBuffer message = new StringBuffer();
+            message.append("state = " + stateToString(mPreviousState) + "\n");
+            message.append(String.format("unlocked.frames = %d\n", mLastUnlockedFrames));
+            message.append(String.format("locked.frames = %d\n", mLastLockedFrames));
+            message.append(String.format("glitch.frames = %d\n", mLastGlitchFrames));
+            message.append(String.format("reset.count = %d\n", mLastResetCount - mStartResetCount));
+            message.append(String.format("peak.amplitude = %8.6f\n", mPeakAmplitude));
+            if (mLastLockedFrames > 0) {
+                message.append(String.format("signal.noise.ratio.db = %5.1f\n", mSignalToNoiseDB));
+            }
+            message.append(String.format("time.total = %8.2f seconds\n", totalSeconds));
+            if (mLastLockedFrames > 0) {
+                message.append(String.format("time.no.glitches = %8.2f\n", mSecondsWithoutGlitches));
+                message.append(String.format("max.time.no.glitches = %8.2f\n",
+                        mMaxSecondsWithoutGlitches));
+                message.append(String.format("glitch.count = %d\n", mLastGlitchCount));
+            }
+            return message.toString();
+        }
+
+        public String getShortReport() {
+            String resultText = "#glitches = " + getLastGlitchCount()
+                    + ", #resets = " + getLastResetCount()
+                    + ", max no glitch = " + getMaxSecondsWithNoGlitch() + " secs\n";
+            resultText += String.format("SNR = %5.1f db", mSignalToNoiseDB);
+            resultText += ", #locked = " + mLastLockedFrames;
+            return resultText;
+        }
+
+        private void updateStatusText() {
+            mLastGlitchReport = getCurrentStatusReport();
+            setAnalyzerText(mLastGlitchReport);
+        }
+
+        public double getMaxSecondsWithNoGlitch() {
+            return mMaxSecondsWithoutGlitches;
+        }
+
+        public int getLastGlitchCount() {
+            return mLastGlitchCount;
+        }
+        public int getLastResetCount() {
+            return mLastResetCount;
+        }
+    }
+
+    // Called on UI thread
+    protected void onGlitchDetected() {
+    }
+
+    private GlitchSniffer mGlitchSniffer = new GlitchSniffer();
+
+    private void setAnalyzerText(String s) {
+        mAnalyzerTextView.setText(s);
+    }
+
+    /**
+     * Set tolerance to deviations from expected value.
+     * The normalized value will be converted in the native code.
+     * @param tolerance normalized between 0.0 and 1.0
+     */
+    public native void setTolerance(float tolerance);
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mStartButton = (Button) findViewById(R.id.button_start);
+        mStopButton = (Button) findViewById(R.id.button_stop);
+        mStopButton.setEnabled(false);
+        mShareButton = (Button) findViewById(R.id.button_share);
+        mShareButton.setEnabled(false);
+        mAnalyzerTextView = (TextView) findViewById(R.id.text_status);
+        updateEnabledWidgets();
+        hideSettingsViews();
+        // TODO hide sample rate menu
+        StreamContext streamContext = getFirstInputStreamContext();
+        if (streamContext != null) {
+            if (streamContext.configurationView != null) {
+                streamContext.configurationView.hideSampleRateMenu();
+            }
+        }
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        setActivityType(ACTIVITY_GLITCHES);
+        mStartButton.setEnabled(true);
+        mStopButton.setEnabled(false);
+        mShareButton.setEnabled(false);
+    }
+
+    @Override
+    protected void onStop() {
+        stopAudioTest();
+        super.onStop();
+    }
+
+    // Called on UI thread
+    public void onStartAudioTest(View view) throws IOException {
+        startAudioTest();
+        mStartButton.setEnabled(false);
+        mStopButton.setEnabled(true);
+        mShareButton.setEnabled(false);
+        keepScreenOn(true);
+    }
+
+    public void startAudioTest() throws IOException {
+        openAudio();
+        startAudio();
+        mGlitchSniffer.startSniffer();
+        onTestBegan();
+    }
+
+    public void onCancel(View view) {
+        stopAudioTest();
+        onTestFinished();
+    }
+
+    // Called on UI thread
+    public void onStopAudioTest(View view) {
+        stopAudioTest();
+        onTestFinished();
+        keepScreenOn(false);
+    }
+
+    // Must be called on UI thread.
+    public void onTestBegan() {
+    }
+
+    // Must be called on UI thread.
+    public void onTestFinished() {
+        mStartButton.setEnabled(true);
+        mStopButton.setEnabled(false);
+        mShareButton.setEnabled(true);
+    }
+
+    public void stopAudioTest() {
+        mGlitchSniffer.stopSniffer();
+        stopAudio();
+        closeAudio();
+    }
+
+    @Override
+    boolean isOutput() {
+        return false;
+    }
+
+    @Override
+    public void setupEffects(int sessionId) {
+    }
+
+    public double getMaxSecondsWithNoGlitch() {
+        return mGlitchSniffer.getMaxSecondsWithNoGlitch();
+    }
+
+    public String getShortReport() {
+        return mGlitchSniffer.getShortReport();
+    }
+
+    @Override
+    String getWaveTag() {
+        return "glitches";
+    }
+}

+ 64 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/InputMarginView.java

@@ -0,0 +1,64 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.LinearLayout;
+
+import java.util.ArrayList;
+
+/**
+ * View for editing an input stream margin to avoid glitches.
+ *
+ * TODO: Is this class actually needed?
+ */
+
+public class InputMarginView extends LinearLayout {
+
+    public InputMarginView(Context context) {
+        super(context);
+        initializeViews(context);
+    }
+
+    public InputMarginView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initializeViews(context);
+    }
+
+    public InputMarginView(Context context,
+                           AttributeSet attrs,
+                           int defStyle) {
+        super(context, attrs, defStyle);
+        initializeViews(context);
+    }
+
+    /**
+     * Inflates the views in the layout.
+     *
+     * @param context
+     *           the current context for the view.
+     */
+    private void initializeViews(Context context) {
+        LayoutInflater inflater = (LayoutInflater) context
+                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        inflater.inflate(R.layout.input_margin_view, this);
+    }
+}

+ 260 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/MainActivity.java

@@ -0,0 +1,260 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.graphics.Point;
+import android.media.AudioManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Display;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.CheckBox;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * Select various Audio tests.
+ */
+
+public class MainActivity extends Activity {
+
+    private static final String KEY_TEST_NAME = "test";
+    public static final String VALUE_TEST_NAME_LATENCY = "latency";
+    public static final String VALUE_TEST_NAME_GLITCH = "glitch";
+
+    static {
+        // Must match name in CMakeLists.txt
+        System.loadLibrary("oboetester");
+    }
+
+
+    private Spinner mModeSpinner;
+    private TextView mCallbackSizeTextView;
+    protected TextView mDeviceView;
+    private TextView mVersionTextView;
+    private TextView mBuildTextView;
+    private Bundle mBundleFromIntent;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+
+        logScreenSize();
+
+        mVersionTextView = (TextView) findViewById(R.id.versionText);
+        mCallbackSizeTextView = (TextView) findViewById(R.id.callbackSize);
+
+        mDeviceView = (TextView) findViewById(R.id.deviceView);
+        updateNativeAudioUI();
+
+        // Set mode, eg. MODE_IN_COMMUNICATION
+        mModeSpinner = (Spinner) findViewById(R.id.spinnerAudioMode);
+        mModeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
+                long mode = mModeSpinner.getSelectedItemId();
+                AudioManager myAudioMgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+                myAudioMgr.setMode((int)mode);
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> adapterView) {
+            }
+        });
+
+        try {
+            PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
+            int oboeVersion = OboeAudioStream.getOboeVersionNumber();
+            int oboeMajor = (oboeVersion >> 24) & 0xFF;
+            int oboeMinor = (oboeVersion >> 16) & 0xFF;
+            int oboePatch = oboeVersion & 0xFF;
+            mVersionTextView.setText("Test v (" + pinfo.versionCode + ") " + pinfo.versionName
+                    + ", Oboe v " + oboeMajor + "." + oboeMinor + "." + oboePatch);
+        } catch (PackageManager.NameNotFoundException e) {
+            mVersionTextView.setText(e.getMessage());
+        }
+
+        mBuildTextView = (TextView) findViewById(R.id.text_build_info);
+        mBuildTextView.setText(Build.DISPLAY);
+
+
+        saveIntentBundleForLaterProcessing(getIntent());
+    }
+
+    private void logScreenSize() {
+        Display display = getWindowManager().getDefaultDisplay();
+        Point size = new Point();
+        display.getSize(size);
+        int width = size.x;
+        int height = size.y;
+        Log.i(TestAudioActivity.TAG, "Screen size = " + size.x + " * " + size.y);
+    }
+
+    @Override
+    public void onNewIntent(Intent intent) {
+        saveIntentBundleForLaterProcessing(intent);
+    }
+
+    // This will get processed during onResume.
+    private void saveIntentBundleForLaterProcessing(Intent intent) {
+        mBundleFromIntent = intent.getExtras();
+    }
+
+    private void processBundleFromIntent() {
+        if (mBundleFromIntent == null) {
+            return;
+        }
+
+        if (mBundleFromIntent.containsKey(KEY_TEST_NAME)) {
+            String testName = mBundleFromIntent.getString(KEY_TEST_NAME);
+            if (VALUE_TEST_NAME_LATENCY.equals(testName)) {
+                Intent intent = new Intent(this, RoundTripLatencyActivity.class);
+                intent.putExtras(mBundleFromIntent);
+                startActivity(intent);
+            } else if (VALUE_TEST_NAME_GLITCH.equals(testName)) {
+                Intent intent = new Intent(this, ManualGlitchActivity.class);
+                intent.putExtras(mBundleFromIntent);
+                startActivity(intent);
+            }
+        }
+        mBundleFromIntent = null;
+    }
+
+    @Override
+    public void onResume(){
+        super.onResume();
+        NativeEngine.setWorkaroundsEnabled(false);
+        processBundleFromIntent();
+    }
+
+    private void updateNativeAudioUI() {
+        AudioManager myAudioMgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+        String audioManagerSampleRate = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
+        String audioManagerFramesPerBurst = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
+        mDeviceView.setText("Java AudioManager: rate = " + audioManagerSampleRate +
+                ", burst = " + audioManagerFramesPerBurst);
+    }
+
+    public void onLaunchTestOutput(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, TestOutputActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchTestInput(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, TestInputActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchTapToTone(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, TapToToneActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchRecorder(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, RecorderActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchEcho(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, EchoActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchRoundTripLatency(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, RoundTripLatencyActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchManualGlitchTest(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, ManualGlitchActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchAutoGlitchTest(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, AutoGlitchActivity.class);
+        startActivity(intent);
+    }
+
+    public void onLaunchTestDisconnect(View view) {
+        updateCallbackSize();
+        Intent intent = new Intent(this, TestDisconnectActivity.class);
+        startActivity(intent);
+    }
+
+    public void onUseCallbackClicked(View view) {
+        CheckBox checkBox = (CheckBox) view;
+        OboeAudioStream.setUseCallback(checkBox.isChecked());
+    }
+
+    protected void showErrorToast(String message) {
+        showToast("Error: " + message);
+    }
+
+    protected void showToast(final String message) {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Toast.makeText(MainActivity.this,
+                        message,
+                        Toast.LENGTH_SHORT).show();
+            }
+        });
+    }
+
+    private void updateCallbackSize() {
+        CharSequence chars = mCallbackSizeTextView.getText();
+        String text = chars.toString();
+        int callbackSize = 0;
+        try {
+            callbackSize = Integer.parseInt(text);
+        } catch (NumberFormatException e) {
+            showErrorToast("Badly formated callback size: " + text);
+            mCallbackSizeTextView.setText("0");
+        }
+        OboeAudioStream.setCallbackSize(callbackSize);
+    }
+
+    public void onSetSpeakerphoneOn(View view) {
+        CheckBox checkBox = (CheckBox) view;
+        boolean enabled = checkBox.isChecked();
+        AudioManager myAudioMgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+        myAudioMgr.setSpeakerphoneOn(enabled);
+    }
+
+    public void onEnableWorkarounds(View view) {
+        CheckBox checkBox = (CheckBox) view;
+        boolean enabled = checkBox.isChecked();
+        NativeEngine.setWorkaroundsEnabled(enabled);
+    }
+}

+ 286 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/ManualGlitchActivity.java

@@ -0,0 +1,286 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import java.io.IOException;
+import java.util.stream.Stream;
+
+public class ManualGlitchActivity extends GlitchActivity {
+
+    public static final String KEY_IN_PERF = "in_perf";
+    public static final String KEY_OUT_PERF = "out_perf";
+    public static final String VALUE_PERF_LOW_LATENCY = "lowlat";
+    public static final String VALUE_PERF_POWERSAVE = "powersave";
+    public static final String VALUE_PERF_NONE = "none";
+
+    public static final String KEY_IN_SHARING = "in_sharing";
+    public static final String KEY_OUT_SHARING = "out_sharing";
+    public static final String VALUE_SHARING_EXCLUSIVE = "exclusive";
+    public static final String VALUE_SHARING_SHARED = "shared";
+
+    public static final String KEY_SAMPLE_RATE = "sample_rate";
+    public static final int VALUE_DEFAULT_SAMPLE_RATE = 48000;
+
+    public static final String KEY_IN_PRESET = "in_preset";
+
+    public static final String KEY_IN_CHANNELS = "in_channels";
+    public static final String KEY_OUT_CHANNELS = "out_channels";
+    public static final int VALUE_DEFAULT_CHANNELS = 2;
+
+    public static final String KEY_DURATION = "duration";
+    public static final int VALUE_DEFAULT_DURATION = 10;
+
+    public static final String KEY_BUFFER_BURSTS = "buffer_bursts";
+    public static final int VALUE_DEFAULT_BUFFER_BURSTS = 2;
+
+    public static final String KEY_TOLERANCE = "tolerance";
+    private static final float DEFAULT_TOLERANCE = 0.1f;
+
+    private TextView mTextTolerance;
+    private SeekBar mFaderTolerance;
+    protected ExponentialTaper mTaperTolerance;
+    private WaveformView mWaveformView;
+    private float[] mWaveform = new float[256];
+    private boolean mTestRunningByIntent;
+    private Bundle mBundleFromIntent;
+
+    private float   mTolerance = DEFAULT_TOLERANCE;
+
+    private SeekBar.OnSeekBarChangeListener mToleranceListener = new SeekBar.OnSeekBarChangeListener() {
+        @Override
+        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+            setToleranceProgress(progress);
+        }
+
+        @Override
+        public void onStartTrackingTouch(SeekBar seekBar) {
+        }
+
+        @Override
+        public void onStopTrackingTouch(SeekBar seekBar) {
+        }
+    };
+
+    protected void setToleranceProgress(int progress) {
+        float tolerance = (float) mTaperTolerance.linearToExponential(
+                ((double)progress) / FADER_PROGRESS_MAX);
+        setTolerance(tolerance);
+        mTextTolerance.setText("Tolerance = " + String.format("%5.3f", tolerance));
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mBundleFromIntent = getIntent().getExtras();
+
+        mTextTolerance = (TextView) findViewById(R.id.textTolerance);
+        mFaderTolerance = (SeekBar) findViewById(R.id.faderTolerance);
+        mTaperTolerance = new ExponentialTaper(0.0, 0.5, 100.0);
+        mFaderTolerance.setOnSeekBarChangeListener(mToleranceListener);
+        setToleranceFader(DEFAULT_TOLERANCE);
+
+        mWaveformView = (WaveformView) findViewById(R.id.waveview_audio);
+    }
+
+    private void setToleranceFader(float tolerance) {
+        int progress = (int) Math.round((mTaperTolerance.exponentialToLinear(
+                tolerance) * FADER_PROGRESS_MAX));
+        mFaderTolerance.setProgress(progress);
+    }
+
+    @Override
+    protected void inflateActivity() {
+        setContentView(R.layout.activity_manual_glitches);
+    }
+
+    @Override
+    public void onResume(){
+        super.onResume();
+        processBundleFromIntent();
+    }
+
+    @Override
+    public void onNewIntent(Intent intent) {
+        mBundleFromIntent = intent.getExtras();
+    }
+
+    private void processBundleFromIntent() {
+        if (mBundleFromIntent == null) {
+            return;
+        }
+        if (mTestRunningByIntent) {
+            return;
+        }
+
+        mResultFileName = null;
+        if (mBundleFromIntent.containsKey(KEY_FILE_NAME)) {
+            mTestRunningByIntent = true;
+            mResultFileName = mBundleFromIntent.getString(KEY_FILE_NAME);
+
+            // Delay the test start to avoid race conditions.
+            Handler handler = new Handler(Looper.getMainLooper()); // UI thread
+            handler.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    startAutomaticTest();
+                }
+            }, 500); // TODO where is the race, close->open?
+
+        }
+    }
+
+    private int getPerfFromText(String text) {
+        if (VALUE_PERF_NONE.equals(text)) {
+            return StreamConfiguration.PERFORMANCE_MODE_NONE;
+        } else if (VALUE_PERF_POWERSAVE.equals(text)) {
+            return StreamConfiguration.PERFORMANCE_MODE_POWER_SAVING;
+        } else {
+            return StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY;
+        }
+    }
+
+    private int getSharingFromText(String text) {
+        if (VALUE_SHARING_SHARED.equals(text)) {
+            return StreamConfiguration.SHARING_MODE_SHARED;
+        } else {
+            return StreamConfiguration.SHARING_MODE_EXCLUSIVE;
+        }
+    }
+
+    void configureStreamsFromBundle(Bundle bundle) {
+
+        // Configure settings
+        StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration;
+        StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration;
+
+        requestedInConfig.reset();
+        requestedOutConfig.reset();
+
+        // Extract parameters from the bundle.
+        String text = bundle.getString(KEY_IN_PERF, VALUE_PERF_LOW_LATENCY);
+        int perfMode = getPerfFromText(text);
+        requestedInConfig.setPerformanceMode(perfMode);
+
+        text = bundle.getString(KEY_OUT_PERF, VALUE_PERF_LOW_LATENCY);
+        perfMode = getPerfFromText(text);
+        requestedOutConfig.setPerformanceMode(perfMode);
+
+        text = bundle.getString(KEY_IN_SHARING, VALUE_SHARING_EXCLUSIVE);
+        int sharingMode = getSharingFromText(text);
+        requestedInConfig.setSharingMode(sharingMode);
+        text = bundle.getString(KEY_OUT_SHARING, VALUE_SHARING_EXCLUSIVE);
+        sharingMode = getSharingFromText(text);
+        requestedOutConfig.setSharingMode(sharingMode);
+
+        int sampleRate = bundle.getInt(KEY_SAMPLE_RATE, VALUE_DEFAULT_SAMPLE_RATE);
+        requestedInConfig.setSampleRate(sampleRate);
+        requestedOutConfig.setSampleRate(sampleRate);
+
+        float tolerance = bundle.getFloat(KEY_TOLERANCE, DEFAULT_TOLERANCE);
+        setToleranceFader(tolerance);
+        setTolerance(tolerance);
+        mTolerance = tolerance;
+
+        int inChannels = bundle.getInt(KEY_IN_CHANNELS, VALUE_DEFAULT_CHANNELS);
+        requestedInConfig.setChannelCount(inChannels);
+        int outChannels = bundle.getInt(KEY_OUT_CHANNELS, VALUE_DEFAULT_CHANNELS);
+        requestedOutConfig.setChannelCount(outChannels);
+
+        String defaultText = StreamConfiguration.convertInputPresetToText(
+                StreamConfiguration.INPUT_PRESET_VOICE_RECOGNITION);
+        text = bundle.getString(KEY_IN_PRESET, defaultText);
+        int inputPreset = StreamConfiguration.convertTextToInputPreset(text);
+        requestedInConfig.setInputPreset(inputPreset);
+    }
+
+    public void startAudioTest() throws IOException {
+        super.startAudioTest();
+        setToleranceProgress(mFaderTolerance.getProgress());
+    }
+
+    void startAutomaticTest() {
+        configureStreamsFromBundle(mBundleFromIntent);
+
+        int durationSeconds = mBundleFromIntent.getInt(KEY_DURATION, VALUE_DEFAULT_DURATION);
+        int numBursts = mBundleFromIntent.getInt(KEY_BUFFER_BURSTS, VALUE_DEFAULT_BUFFER_BURSTS);
+        mBundleFromIntent = null;
+
+        try {
+            onStartAudioTest(null);
+            int sizeFrames = mAudioOutTester.getCurrentAudioStream().getFramesPerBurst() * numBursts;
+            mAudioOutTester.getCurrentAudioStream().setBufferSizeInFrames(sizeFrames);
+
+            // Schedule the end of the test.
+            Handler handler = new Handler(Looper.getMainLooper()); // UI thread
+            handler.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    stopAutomaticTest();
+                }
+            }, durationSeconds * 1000);
+        } catch (IOException e) {
+            String report = "Open failed: " + e.getMessage();
+            maybeWriteTestResult(report);
+            mTestRunningByIntent = false;
+        }
+
+    }
+
+    void stopAutomaticTest() {
+        String report = getCommonTestReport()
+                + String.format("tolerance = %5.3f\n", mTolerance)
+                + mLastGlitchReport;
+        onStopAudioTest(null);
+        maybeWriteTestResult(report);
+        mTestRunningByIntent = false;
+    }
+
+    // Only call from UI thread.
+    @Override
+    public void onTestFinished() {
+        super.onTestFinished();
+    }
+    // Only call from UI thread.
+    @Override
+    public void onTestBegan() {
+        mWaveformView.clearSampleData();
+        mWaveformView.postInvalidate();
+        super.onTestBegan();
+    }
+
+    // Called on UI thread
+    @Override
+    protected void onGlitchDetected() {
+        int numSamples = getGlitch(mWaveform);
+        mWaveformView.setSampleData(mWaveform, 0, numSamples);
+        mWaveformView.postInvalidate();
+    }
+
+    private float[] getGlitchWaveform() {
+        return mWaveform;
+    }
+
+    private native int getGlitch(float[] mWaveform);
+
+}

+ 10 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/NativeEngine.java

@@ -0,0 +1,10 @@
+package com.google.sample.oboe.manualtest;
+
+public class NativeEngine {
+
+    static native boolean isMMapSupported();
+
+    static native boolean isMMapExclusiveSupported();
+
+    static native void setWorkaroundsEnabled(boolean enabled);
+}

+ 26 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/OboeAudioInputStream.java

@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+class OboeAudioInputStream extends OboeAudioStream {
+
+    @Override
+    public boolean isInput() {
+        return true;
+    }
+
+}

+ 42 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/OboeAudioOutputStream.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+/**
+ * Native synthesizer and audio output.
+ */
+public class OboeAudioOutputStream extends OboeAudioStream {
+
+    // WARNING - must match order in strings.xml
+    public static final int TONE_TYPE_SAW_PING = 0;
+    public static final int TONE_TYPE_SINE = 1;
+    public static final int TONE_TYPE_IMPULSE = 2;
+    public static final int TONE_TYPE_SAWTOOTH = 3;
+
+    @Override
+    public boolean isInput() {
+        return false;
+    }
+
+    public native void setToneEnabled(boolean enabled);
+
+    public native void setToneType(int index);
+
+    public native void setChannelEnabled(int channelIndex, boolean enabled);
+
+    public native void setSignalType(int type);
+}

+ 255 - 0
love/src/jni/oboe/apps/OboeTester/app/src/main/java/com/google/sample/oboe/manualtest/OboeAudioStream.java

@@ -0,0 +1,255 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * 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
+ *
+ *      http://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.
+ */
+
+package com.google.sample.oboe.manualtest;
+
+import java.io.IOException;
+
+/**
+ * Implementation of an AudioStreamBase using Oboe.
+ */
+
+abstract class OboeAudioStream extends AudioStreamBase {
+    private static final int INVALID_STREAM_INDEX = -1;
+    int streamIndex = INVALID_STREAM_INDEX;
+
+    @Override
+    public void stopPlayback() throws IOException {
+        int result = stopPlaybackNative();
+        if (result < 0) {
+            throw new IOException("Stop Playback failed! result = " + result);
+        }
+    }
+
+    public native int stopPlaybackNative();
+
+    @Override
+    public void startPlayback() throws IOException {
+        int result = startPlaybackNative();
+        if (result < 0) {
+            throw new IOException("Start Playback failed! result = " + result);
+        }
+    }
+
+    public native int startPlaybackNative();
+
+    // Write disabled because the synth is in native code.
+    @Override
+    public int write(float[] buffer, int offset, int length) {
+        return 0;
+    }
+
+    @Override
+    public void open(StreamConfiguration requestedConfiguration,
+                     StreamConfiguration actualConfiguration, int bufferSizeInFrames) throws IOException {
+        super.open(requestedConfiguration, actualConfiguration, bufferSizeInFrames);
+        int result = openNative(requestedConfiguration.getNativeApi(),
+                requestedConfiguration.getSampleRate(),
+                requestedConfiguration.getChannelCount(),
+                requestedConfiguration.getFormat(),
+                requestedConfiguration.getSharingMode(),
+                requestedConfiguration.getPerformanceMode(),
+                requestedConfiguration.getInputPreset(),
+                requestedConfiguration.getDeviceId(),
+                requestedConfiguration.getSessionId(),
+                requestedConfiguration.getFramesPerBurst(),
+                requestedConfiguration.getChannelConversionAllowed(),
+                requestedConfiguration.getFormatConversionAllowed(),
+                requestedConfiguration.getRateConversionQuality(),
+                requestedConfiguration.isMMap(),
+                isInput()
+        );
+        if (result < 0) {
+            streamIndex = INVALID_STREAM_INDEX;
+            throw new IOException("Open failed! result = " + result);
+        } else {
+            streamIndex = result;
+        }
+        actualConfiguration.setNativeApi(getNativeApi());
+        actualConfiguration.setSampleRate(getSampleRate());
+        actualConfiguration.setSharingMode(getSharingMode());
+        actualConfiguration.setPerformanceMode(getPerformanceMode());
+        actualConfiguration.setInputPreset(getInputPreset());
+        actualConfiguration.setFramesPerBurst(getFramesPerBurst());
+        actualConfiguration.setBufferCapacityInFrames(getBufferCapacityInFrames());
+        actualConfiguration.setChannelCount(getChannelCount());
+        actualConfiguration.setDeviceId(getDeviceId());
+        actualConfiguration.setSessionId(getSessionId());
+        actualConfiguration.setFormat(getFormat());
+        actualConfiguration.setMMap(isMMap());
+        actualConfiguration.setDirection(isInput()
+                ? StreamConfiguration.DIRECTION_INPUT
+                : StreamConfiguration.DIRECTION_OUTPUT);
+    }
+
+    private native int openNative(
+            int nativeApi,
+            int sampleRate,
+            int channelCount,
+            int format,
+            int sharingMode,
+            int performanceMode,
+            int inputPreset,
+            int deviceId,
+            int sessionId,
+            int framesPerRead,
+            boolean channelConversionAllowed,
+            boolean formatConversionAllowed,
+            int rateConversionQuality,
+            boolean isMMap,
+            boolean isInput);
+
+    @Override
+    public void close() {
+        if (streamIndex >= 0) {
+            close(streamIndex);
+            streamIndex = INVALID_STREAM_INDEX;
+        }
+    }
+    public native void close(int streamIndex);
+
+    @Override
+    public int getBufferCapacityInFrames() {
+        return getBufferCapacityInFrames(streamIndex);
+    }
+    private native int getBufferCapacityInFrames(int streamIndex);
+
+    @Override
+    public int getBufferSizeInFrames() {
+        return getBufferSizeInFrames(streamIndex);
+    }
+    private native int getBufferSizeInFrames(int streamIndex);
+
+    @Override
+    public boolean isThresholdSupported() {
+        return true;
+    }
+
+    @Override
+    public int setBufferSizeInFrames(int thresholdFrames) {
+        return setBufferSizeInFrames(streamIndex, thresholdFrames);
+    }
+    private native int setBufferSizeInFrames(int streamIndex, int thresholdFrames);
+
+    public int getNativeApi() {
+        return getNativeApi(streamIndex);
+    }
+    public native int getNativeApi(int streamIndex);
+
+    @Override
+    public int getFramesPerBurst() {
+        return getFramesPerBurst(streamIndex);
+    }
+    public native int getFramesPerBurst(int streamIndex);
+
+    public int getSharingMode() {
+        return getSharingMode(streamIndex);
+    }
+    public native int getSharingMode(int streamIndex);
+
+    public int getPerformanceMode() {
+        return getPerformanceMode(streamIndex);
+    }
+    public native int getPerformanceMode(int streamIndex);
+
+    public int getInputPreset() {
+        return getInputPreset(streamIndex);
+    }
+    public native int getInputPreset(int streamIndex);
+
+    public int getSampleRate() {
+        return getSampleRate(streamIndex);
+    }
+    public native int getSampleRate(int streamIndex);
+
+    public int getFormat() {
+        return getFormat(streamIndex);
+    }
+    public native int getFormat(int streamIndex);
+
+    public int getChannelCount() {
+        return getChannelCount(streamIndex);
+    }
+    public native int getChannelCount(int streamIndex);
+
+    public int getDeviceId() {
+        return getDeviceId(streamIndex);
+    }
+    public native int getDeviceId(int streamIndex);
+
+    public int getSessionId() {
+        return getSessionId(streamIndex);
+    }
+    public native int getSessionId(int streamIndex);
+
+    public boolean isMMap() {
+        return isMMap(streamIndex);
+    }
+    public native boolean isMMap(int streamIndex);
+
+    @Override
+    public long getCallbackCount() {
+        return getCallbackCount(streamIndex);
+    }
+    public native long getCallbackCount(int streamIndex);
+
+    @Override
+    public long getFramesWritten() {
+        return getFramesWritten(streamIndex);
+    }
+    public native long getFramesWritten(int streamIndex);
+
+    @Override
+    public long getFramesRead() {
+        return getFramesRead(streamIndex);
+    }
+    public native long getFramesRead(int streamIndex);
+
+    @Override
+    public int getXRunCount() {
+        return getXRunCount(streamIndex);
+    }
+    public native int getXRunCount(int streamIndex);
+
+    @Override
+    public double getLatency() {
+        return getLatency(streamIndex);
+    }
+    public native double getLatency(int streamIndex);
+
+    @Override
+    public double getCpuLoad() {
+        return getCpuLoad(streamIndex);
+    }
+    public native double getCpuLoad(int streamIndex);
+
+    @Override
+    public native void setWorkload(double workload);
+
+    @Override
+    public int getState() {
+        return getState(streamIndex);
+    }
+    public native int getState(int streamIndex);
+
+    public static native void setCallbackReturnStop(boolean b);
+
+    public static native void setUseCallback(boolean checked);
+
+    public static native void setCallbackSize(int callbackSize);
+
+    public static native int getOboeVersionNumber();
+}

Некоторые файлы не были показаны из-за большого количества измененных файлов