Oboe
1.5
A library for creating real-time audio apps on Android
|
#include <LatencyTuner.h>
Public Member Functions | |
LatencyTuner (AudioStream &stream) | |
LatencyTuner (AudioStream &stream, int32_t maximumBufferSize) | |
Result | tune () |
void | requestReset () |
bool | isAtMaximumBufferSize () |
void | setMinimumBufferSize (int32_t bufferSize) |
int32_t | getMinimumBufferSize () const |
void | setBufferSizeIncrement (int32_t sizeIncrement) |
int32_t | getBufferSizeIncrement () const |
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.
|
explicit |
Construct a new LatencyTuner object which will act on the given audio stream
stream | the stream who's latency will be tuned |
|
explicit |
Construct a new LatencyTuner object which will act on the given audio stream.
stream | the stream who's latency will be tuned |
the | maximum buffer size which the tune() operation will set the buffer size to |
bool oboe::LatencyTuner::isAtMaximumBufferSize | ( | ) |
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.
|
inline |
Set the amount the bufferSize will be incremented while tuning. By default, this will be one burst.
Note that AAudio will quantize the buffer size to a multiple of the burstSize. So the final buffer sizes may not be a multiple of this increment.
sizeIncrement |
|
inline |
Set the minimum bufferSize in frames that is used when the tuner is reset. You may wish to call requestReset() after calling this.
bufferSize |
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.