tree: 99ba80a2e390cb0d2c834b1152fe50206e32087c [path history] [tgz]
  1. AdpfWrapper.cpp
  2. AdpfWrapper.h
  3. AudioSourceCaller.cpp
  4. AudioSourceCaller.h
  5. AudioStream.cpp
  6. AudioStreamBuilder.cpp
  7. DataConversionFlowGraph.cpp
  8. DataConversionFlowGraph.h
  9. FilterAudioStream.cpp
  10. FilterAudioStream.h
  11. FixedBlockAdapter.cpp
  12. FixedBlockAdapter.h
  13. FixedBlockReader.cpp
  14. FixedBlockReader.h
  15. FixedBlockWriter.cpp
  16. FixedBlockWriter.h
  17. LatencyTuner.cpp
  18. MonotonicCounter.h
  19. OboeDebug.h
  20. OboeExtensions.cpp
  21. QuirksManager.cpp
  22. QuirksManager.h
  23. README.md
  24. SourceFloatCaller.cpp
  25. SourceFloatCaller.h
  26. SourceI16Caller.cpp
  27. SourceI16Caller.h
  28. SourceI24Caller.cpp
  29. SourceI24Caller.h
  30. SourceI32Caller.cpp
  31. SourceI32Caller.h
  32. StabilizedCallback.cpp
  33. Trace.cpp
  34. Trace.h
  35. Utilities.cpp
  36. Version.cpp
src/common/README.md

Notes on Implementation

Latency from Resampling

There are two components of the latency. The resampler itself, and a buffer that is used to adapt the block sizes.

  1. The resampler is an FIR running at the target sample rate. So its latency is the number of taps. From MultiChannelResampler.cpp, numTaps is

    Fastest: 2 Low: 4 Medium: 8 High: 16 Best: 32

For output, the device sampling rate is used, which is typically 48000.For input, the app sampling rate is used.

  1. There is a block size adapter that collects odd sized blocks into larger blocks of the correct size.

The adapter contains one burst of frames, from getFramesPerBurst(). But if the app specifies a particular size using setFramesPerCallback() then that size will be used. Here is some pseudo-code to calculate the latency.

latencyMillis = 0
targetRate = isOutput ? deviceRate : applicationRate
// Add latency from FIR
latencyMillis += numTaps * 1000.0 / targetRate
// Add latency from block size adaptation
adapterSize = (callbackSize > 0) ? callbackSize : burstSize
if (isOutput && isCallbackUsed) latencyMillis += adapterSize * 1000.0 / deviceRate
else if (isInput && isCallbackUsed) latencyMillis += adapterSize * 1000.0 / applicationRate
else if (isInput && !isCallbackUsed) latencyMillis += adapterSize * 1000.0 / deviceRate