Oboe
A library for creating real-time audio apps on Android
Loading...
Searching...
No Matches
Public Member Functions | List of all members
oboe::StabilizedCallback Class Reference
Inheritance diagram for oboe::StabilizedCallback:
oboe::AudioStreamCallback oboe::AudioStreamDataCallback oboe::AudioStreamErrorCallback

Public Member Functions

 StabilizedCallback (AudioStreamCallback *callback)
 
DataCallbackResult onAudioReady (AudioStream *oboeStream, void *audioData, int32_t numFrames) override
 
void onErrorBeforeClose (AudioStream *oboeStream, Result error) override
 
void onErrorAfterClose (AudioStream *oboeStream, Result error) override
 
virtual DataCallbackResult onAudioReady (AudioStream *audioStream, void *audioData, int32_t numFrames)=0
 
- Public Member Functions inherited from oboe::AudioStreamErrorCallback
virtual bool onError (AudioStream *, Result)
 
virtual void onErrorBeforeClose (AudioStream *, Result)
 
virtual void onErrorAfterClose (AudioStream *, Result)
 

Member Function Documentation

◆ onAudioReady()

DataCallbackResult oboe::StabilizedCallback::onAudioReady ( AudioStream audioStream,
void *  audioData,
int32_t  numFrames 
)
overridevirtual

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.

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:

  • allocate memory using, for example, malloc() or new
  • any file operations such as opening, closing, reading or writing
  • any network operations such as streaming
  • use any mutexes or other synchronization primitives
  • sleep
  • oboeStream->stop(), pause(), flush() or close()
  • oboeStream->read()
  • oboeStream->write()

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.

Parameters
audioStreampointer to the associated stream
audioDatabuffer containing input data or a place to put output data
numFramesnumber of frames to be processed
Returns
DataCallbackResult::Continue or DataCallbackResult::Stop

Implements oboe::AudioStreamDataCallback.

◆ onErrorAfterClose()

void oboe::StabilizedCallback::onErrorAfterClose ( AudioStream ,
Result   
)
inlineoverridevirtual

This will be called when an error occurs on a stream, such as when the stream is disconnected, and if onError() returns false (indicating that the error has not already been handled).

The underlying AAudio or OpenSL ES stream will already be stopped AND closed by Oboe. So the underlying stream cannot be referenced. But you can still query most parameters.

This callback could be used to reopen a new stream on another device.

Parameters
audioStreampointer to the associated stream
error

Reimplemented from oboe::AudioStreamErrorCallback.

◆ onErrorBeforeClose()

void oboe::StabilizedCallback::onErrorBeforeClose ( AudioStream ,
Result   
)
inlineoverridevirtual

This will be called when an error occurs on a stream, such as when the stream is disconnected, and if onError() returns false (indicating that the error has not already been handled).

Note that this will be called on a thread created by Oboe.

The underlying stream will already be stopped by Oboe but not yet closed. So the stream can be queried.

Do not close or delete the stream in this method because it will be closed after this method returns.

Parameters
audioStreampointer to the associated stream
error

Reimplemented from oboe::AudioStreamErrorCallback.


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