Oboe
A library for creating real-time audio apps on Android
|
#include <FullDuplexStream.h>
Public Member Functions | |
void | setInputStream (AudioStream *stream) |
void | setSharedInputStream (std::shared_ptr< AudioStream > &stream) |
AudioStream * | getInputStream () |
void | setOutputStream (AudioStream *stream) |
void | setSharedOutputStream (std::shared_ptr< AudioStream > &stream) |
AudioStream * | getOutputStream () |
virtual Result | start () |
virtual Result | stop () |
virtual ResultWithValue< int32_t > | readInput (int32_t numFrames) |
virtual DataCallbackResult | onBothStreamsReady (const void *inputData, int numInputFrames, void *outputData, int numOutputFrames)=0 |
DataCallbackResult | onAudioReady (AudioStream *, void *audioData, int numFrames) |
void | setNumInputBurstsCushion (int32_t numBursts) |
int32_t | getNumInputBurstsCushion () const |
void | setMinimumFramesBeforeRead (int32_t numFrames) |
int32_t | getMinimumFramesBeforeRead () const |
Public Member Functions inherited from oboe::AudioStreamDataCallback | |
virtual DataCallbackResult | onAudioReady (AudioStream *audioStream, void *audioData, int32_t numFrames)=0 |
FullDuplexStream can be used to synchronize an input and output stream.
For the builder of the output stream, call setDataCallback() with this object.
When both streams are ready, onAudioReady() of the output stream will call onBothStreamsReady(). Callers must override onBothStreamsReady().
To ensure best results, open an output stream before the input stream. Call inputBuilder.setBufferCapacityInFrames(mOutputStream->getBufferCapacityInFrames() * 2). Also, call inputBuilder.setSampleRate(mOutputStream->getSampleRate()).
Callers must call setInputStream() and setOutputStream(). Call start() to start both streams and stop() to stop both streams. Caller is responsible for closing both streams.
Callers should handle error callbacks with setErrorCallback() for the output stream. When an error callback occurs for the output stream, Oboe will stop and close the output stream. The caller is responsible for stopping and closing the input stream. The caller should also reopen and restart both streams when the error callback is ErrorDisconnected. See the LiveEffect sample as an example of this.
|
inline |
Gets the current input stream. This function tries to return the shared input stream if it is set before the raw input stream.
|
inline |
Gets the minimum number of frames in the input stream buffer before calling readInput().
|
inline |
Get the number of bursts left in the input buffer as a cushion.
|
inline |
Gets the current output stream. This function tries to return the shared output stream if it is set before the raw output stream.
|
inline |
Called when the output stream is ready to process audio. This in return calls onBothStreamsReady() when data is available on both streams. Callers should call this function when the output stream is ready. Callers must override onBothStreamsReady().
audioStream | pointer to the associated stream |
audioData | a place to put output data |
numFrames | number of frames to be processed |
|
pure virtual |
Called when data is available on both streams. Caller should override this method. numInputFrames and numOutputFrames may be zero.
inputData | buffer containing input data |
numInputFrames | number of input frames |
outputData | a place to put output data |
numOutputFrames | number of output frames |
|
inlinevirtual |
Reads input from the input stream. Callers should not call this directly as this is called in onAudioReady().
numFrames |
|
inline |
Sets the input stream.
stream | the output stream |
Minimum number of frames in the input stream buffer before calling readInput().
numFrames | number of bursts in the input buffer as a cushion |
This is a cushion between the DSP and the application processor cursors to prevent collisions. Typically 0 for latency measurements or 1 for glitch tests.
numBursts | number of bursts to leave in the input buffer as a cushion |
|
inline |
Sets the output stream.
stream | the output stream |
|
inline |
Sets the input stream. Calling this is mandatory.
stream | the output stream |
|
inline |
Sets the output stream. Calling this is mandatory.
stream | the output stream |
|
inlinevirtual |
Attempts to start both streams. Please call setInputStream() and setOutputStream() before calling this function.
|
inlinevirtual |
Stops both streams. Returns Result::OK if neither stream had an error during close.