Oboe 1.2 A library for creating real-time audio apps on Android

Public Member Functions | List of all members
oboe::LatencyTuner Class Reference

`#include <LatencyTuner.h>`

## Public Member Functions
| LatencyTuner (AudioStream &stream)
| LatencyTuner (AudioStream &stream, int32_t maximumBufferSize)
Result | tune ()
void | requestReset ()
bool | isAtMaximumBufferSize ()

## Detailed Description

LatencyTuner can be used to dynamically tune the latency of an output stream. It adjusts the stream's bufferSize by monitoring the number of underruns.

This only affects the latency associated with the first level of buffering that is closest to the application. It does not affect low latency in the HAL, or touch latency in the UI.

Call tune() right before returning from your data callback function if using callbacks. Call tune() right before calling write() if using blocking writes.

If you want to see the ongoing results of this tuning process then call stream->getBufferSize() periodically.

## Constructor & Destructor Documentation

## ◆ LatencyTuner() [1/2]

oboe::LatencyTuner::LatencyTuner | ( | AudioStream & | stream | ) |
| explicit

Construct a new LatencyTuner object which will act on the given audio stream

Parameters

  stream | the stream who's latency will be tuned

## ◆ LatencyTuner() [2/2]

oboe::LatencyTuner::LatencyTuner | ( | AudioStream & | stream,
|  | int32_t | maximumBufferSize
| ) |  |
| explicit

Construct a new LatencyTuner object which will act on the given audio stream.

Parameters

  stream | the stream who's latency will be tuned
  the | maximum buffer size which the tune() operation will set the buffer size to

## Member Function Documentation

## ◆ isAtMaximumBufferSize()

bool oboe::LatencyTuner::isAtMaximumBufferSize | ( |  | ) |

Returns
  true if the audio stream's buffer size is at the maximum value. If no maximum value was specified when constructing the LatencyTuner then the value of stream->getBufferCapacityInFrames is used

## ◆ requestReset()

void oboe::LatencyTuner::requestReset | ( |  | ) |

This may be called from another thread. Then tune() will call reset(), which will lower the latency to the minimum and then allow it to rise back up if there are glitches.

This is typically called in response to a user decision to minimize latency. In other words, call this from a button handler.

## ◆ tune()

Result oboe::LatencyTuner::tune | ( |  | ) |

Adjust the bufferSizeInFrames to optimize latency. It will start with a low latency and then raise it if an underrun occurs.

Latency tuning is only supported for AAudio.

Returns
  OK or negative error, ErrorUnimplemented for OpenSL ES

The documentation for this class was generated from the following file:

- include/oboe/LatencyTuner.h