Oboe
A library for creating real-time audio apps on Android
|
#include <AudioStreamCallback.h>
Public Member Functions | |
virtual DataCallbackResult | onAudioReady (AudioStream *audioStream, void *audioData, int32_t numFrames)=0 |
AudioStreamDataCallback defines a callback interface for moving data to/from an audio stream using onAudioReady
2) being alerted when a stream has an error using onError*
methods
It is used with AudioStreamBuilder::setDataCallback().
|
pure virtual |
A buffer is ready for processing.
For an output stream, this function should render and write numFrames of data in the stream's current data format to the audioData buffer.
For an input stream, this function should read and process numFrames of data from the audioData buffer.
The audio data is passed through the buffer. So do NOT call read() or write() on the stream that is making the callback.
Note that numFrames can vary unless AudioStreamBuilder::setFramesPerCallback() is called. If AudioStreamBuilder::setFramesPerCallback() is NOT called then numFrames should always be <= AudioStream::getFramesPerBurst().
Also note that this callback function should be considered a "real-time" function. It must not do anything that could cause an unbounded delay because that can cause the audio to glitch or pop.
These are things the function should NOT do:
The following are OK to call from the data callback:
If you need to move data, eg. MIDI commands, in or out of the callback function then we recommend the use of non-blocking techniques such as an atomic FIFO.
audioStream | pointer to the associated stream |
audioData | buffer containing input data or a place to put output data |
numFrames | number of frames to be processed |
Implemented in oboe::StabilizedCallback.