tree: e90c9b87aa299d32f37de7095242dcdc3d7fec7f [path history] [tgz]
  1. AudioClock.h
  2. AudioSourceCaller.cpp
  3. AudioSourceCaller.h
  4. AudioStream.cpp
  5. AudioStreamBuilder.cpp
  6. DataConversionFlowGraph.cpp
  7. DataConversionFlowGraph.h
  8. FilterAudioStream.cpp
  9. FilterAudioStream.h
  10. FixedBlockAdapter.cpp
  11. FixedBlockAdapter.h
  12. FixedBlockReader.cpp
  13. FixedBlockReader.h
  14. FixedBlockWriter.cpp
  15. FixedBlockWriter.h
  16. LatencyTuner.cpp
  17. MonotonicCounter.h
  18. OboeDebug.h
  19. QuirksManager.cpp
  20. QuirksManager.h
  21. README.md
  22. SourceFloatCaller.cpp
  23. SourceFloatCaller.h
  24. SourceI16Caller.cpp
  25. SourceI16Caller.h
  26. StabilizedCallback.cpp
  27. Trace.cpp
  28. Trace.h
  29. Utilities.cpp
  30. 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