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

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

`#include <AudioStreamCallback.h>`

Inheritance diagram for oboe::AudioStreamErrorCallback:

## Public Member Functions
virtual bool | onError (AudioStream *, Result)
virtual void | onErrorBeforeClose (AudioStream *, Result)
virtual void | onErrorAfterClose (AudioStream *, Result)

## Detailed Description

AudioStreamErrorCallback defines a callback interface for being alerted when a stream has an error or is disconnected using `onError*` methods.

It is used with AudioStreamBuilder::setErrorCallback().

## Member Function Documentation

## ◆ onError()

virtual bool oboe::AudioStreamErrorCallback::onError | ( | AudioStream * | ,
|  | Result |
| ) |  |
| inline virtual

This will be called before other `onError` methods when an error occurs on a stream, such as when the stream is disconnected.

It can be used to override and customize the normal error processing. Use of this method is considered an advanced technique. It might, for example, be used if an app want to use a high level lock when closing and reopening a stream. Or it might be used when an app want to signal a management thread that handles all of the stream state.

If this method returns false it indicates that the stream has *not been stopped and closed by the application. In this case it will be stopped by Oboe in the following way: onErrorBeforeClose() will be called, then the stream will be closed and onErrorAfterClose() will be closed.

If this method returns true it indicates that the stream has been stopped and closed by the application and Oboe will not do this. In that case, the app MUST stop() and close() the stream.

This method will be called on a thread created by Oboe.

Parameters

  audioStream | pointer to the associated stream
  error |

Returns
  true if the stream has been stopped and closed, false if not

## ◆ onErrorAfterClose()

virtual void oboe::AudioStreamErrorCallback::onErrorAfterClose | ( | AudioStream * | ,
|  | Result |
| ) |  |
| inline virtual

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

  audioStream | pointer to the associated stream
  error |

Reimplemented in oboe::StabilizedCallback.

## ◆ onErrorBeforeClose()

virtual void oboe::AudioStreamErrorCallback::onErrorBeforeClose | ( | AudioStream * | ,
|  | Result |
| ) |  |
| inline virtual

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

  audioStream | pointer to the associated stream
  error |

Reimplemented in oboe::StabilizedCallback.

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

- include/oboe/AudioStreamCallback.h